Skip to content

Commit 50fef82

Browse files
committed
Fixed posix support initialization
1 parent 94b61a1 commit 50fef82

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/EmulatedPosixSupport.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,11 @@ public EmulatedPosixSupport(PythonContext context, boolean useNfiForSocketFd) {
262262
}
263263

264264
@Override
265-
public void postInitialize() {
266-
environ.putAll(System.getenv());
265+
public void setEnv(Env env) {
266+
super.setEnv(env);
267+
if (!ImageInfo.inImageBuildtimeCode()) {
268+
environ.putAll(System.getenv());
269+
}
267270
}
268271

269272
@ExportMessage

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/LoggingPosixSupport.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ public void setEnv(Env env) {
103103
delegate.setEnv(env);
104104
}
105105

106-
@Override
107-
public void postInitialize() {
108-
delegate.postInitialize();
109-
}
110-
111106
@ExportMessage
112107
final String getBackend(
113108
@CachedLibrary("this.delegate") PosixSupportLibrary lib) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
import com.oracle.truffle.api.nodes.Node;
7878
import com.oracle.truffle.api.source.Source;
7979
import com.oracle.truffle.llvm.api.Toolchain;
80+
import org.graalvm.nativeimage.ImageInfo;
8081

8182
/**
8283
* Implementation that invokes the native POSIX functions directly using NFI. This requires either
@@ -303,10 +304,14 @@ public NFIPosixSupport(PythonContext context, String nfiBackend) {
303304
this.context = context;
304305
this.nfiBackend = nfiBackend;
305306
this.cachedFunctions = new AtomicReferenceArray<>(PosixNativeFunction.values().length);
307+
setEnv(context.getEnv());
306308
}
307309

308310
@Override
309311
public void setEnv(Env env) {
312+
if (ImageInfo.inImageBuildtimeCode()) {
313+
return;
314+
}
310315
// Java NIO (and TruffleFile) do not expect/support changing native working directory since
311316
// it is inherently thread-unsafe operation. It is not defined how NIO behaves when native
312317
// cwd changes, thus we need to prevent TruffleFile from resolving relative paths using

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PosixSupport.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,4 @@ public abstract class PosixSupport {
4646
public void setEnv(@SuppressWarnings("unused") Env env) {
4747
// nop
4848
}
49-
50-
public void postInitialize() {
51-
}
5249
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public boolean isInitialized() {
450450
}
451451

452452
public void initialize() {
453-
initalizePosixSupport();
453+
initializePosixSupport();
454454
core.initialize(this);
455455
setupRuntimeInformation(false);
456456
core.postInitialize();
@@ -463,7 +463,6 @@ public void initialize() {
463463

464464
public void patch(Env newEnv) {
465465
setEnv(newEnv);
466-
posixSupport.postInitialize();
467466
setupRuntimeInformation(true);
468467
core.postInitialize();
469468
importSiteIfForced();
@@ -562,7 +561,7 @@ private void setupRuntimeInformation(boolean isPatching) {
562561
isInitialized = true;
563562
}
564563

565-
private void initalizePosixSupport() {
564+
private void initializePosixSupport() {
566565
String option = getLanguage().getEngineOption(PythonOptions.PosixModuleBackend);
567566
PosixSupport result;
568567
// The resources field will be removed once all posix builtins go through PosixSupport

0 commit comments

Comments
 (0)