|
20 | 20 | import java.util.concurrent.ConcurrentHashMap;
|
21 | 21 |
|
22 | 22 | import com.oracle.truffle.api.CompilerDirectives;
|
| 23 | +import com.oracle.truffle.api.TruffleOptions; |
23 | 24 | import com.oracle.truffle.api.interop.InteropException;
|
24 | 25 | import com.oracle.truffle.api.interop.InteropLibrary;
|
| 26 | +import org.graalvm.nativeimage.ProcessProperties; |
25 | 27 | import org.graalvm.shadowed.org.jcodings.Encoding;
|
26 | 28 | import org.graalvm.shadowed.org.jcodings.EncodingDB;
|
27 | 29 | import org.truffleruby.RubyContext;
|
@@ -134,11 +136,16 @@ private void initializeLocaleEncoding(TruffleNFIPlatform nfi, NativeConfiguratio
|
134 | 136 | // LC_CTYPE is set according to environment variables (LC_ALL, LC_CTYPE, LANG).
|
135 | 137 | // HotSpot does setlocale(LC_ALL, "") and Native Image does nothing.
|
136 | 138 | // We match CRuby by doing setlocale(LC_ALL, "C") and setlocale(LC_CTYPE, "").
|
137 |
| - // This is notably important for Prism to be able to parse floating-point numbers: |
138 |
| - // https://github.com/ruby/prism/issues/2638 |
139 |
| - // It also affects C functions that depend on the locale in C extensions, so best to follow CRuby here. |
140 |
| - LibRubySignal.loadLibrary(language.getRubyHome(), Platform.LIB_SUFFIX); |
141 |
| - LibRubySignal.setupLocale(); |
| 139 | + // This also affects C functions that depend on the locale in C extensions, so best to follow CRuby here. |
| 140 | + // Change the strict minimum if embedded because setlocale() is process-wide. |
| 141 | + if (context.getOptions().EMBEDDED) { |
| 142 | + if (TruffleOptions.AOT) { |
| 143 | + ProcessProperties.setLocale("LC_CTYPE", ""); |
| 144 | + } |
| 145 | + } else { |
| 146 | + LibRubySignal.loadLibrary(language.getRubyHome(), Platform.LIB_SUFFIX); |
| 147 | + LibRubySignal.setupLocale(); |
| 148 | + } |
142 | 149 |
|
143 | 150 | final String localeEncodingName;
|
144 | 151 | final String detector;
|
|
0 commit comments