Skip to content

Commit 0c2c741

Browse files
committed
[GR-48239] Do not set (DY)LD_LIBRARY_PATH if not running with LLVM.
2 parents 2714c3f + 70feeda commit 0c2c741

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalPythonModuleBuiltins.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
import static com.oracle.graal.python.nodes.StringLiterals.J_LLVM_LANGUAGE;
5151
import static com.oracle.graal.python.nodes.StringLiterals.T_COLON;
5252
import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING;
53+
import static com.oracle.graal.python.nodes.StringLiterals.T_LLVM_LANGUAGE;
54+
import static com.oracle.graal.python.nodes.StringLiterals.T_NATIVE;
5355
import static com.oracle.graal.python.nodes.StringLiterals.T_PATH;
5456
import static com.oracle.graal.python.nodes.StringLiterals.T_STRICT;
5557
import static com.oracle.graal.python.nodes.StringLiterals.T_SURROGATEESCAPE;
@@ -254,6 +256,7 @@ public void postInitialize(Python3Core core) {
254256
mod.setAttribute(tsLiteral("executable_list"), executableList);
255257
mod.setAttribute(tsLiteral("ForeignType"), core.lookupType(PythonBuiltinClassType.ForeignObject));
256258
mod.setAttribute(tsLiteral("use_system_toolchain"), context.getOption(PythonOptions.UseSystemToolchain));
259+
mod.setAttribute(tsLiteral("ext_mode"), context.getOption(PythonOptions.NativeModules) ? T_NATIVE : T_LLVM_LANGUAGE);
257260

258261
if (!context.getOption(PythonOptions.EnableDebuggingBuiltins)) {
259262
mod.setAttribute(tsLiteral("dump_truffle_ast"), PNone.NO_VALUE);

graalpython/lib-graalpython/sulong_support.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@
3838
# SOFTWARE.
3939

4040
# Set library search path so that binaries built with sulong toolchain can find libc++.so
41-
import os, sys
42-
if sys.platform == "linux":
43-
var = "LD_LIBRARY_PATH"
44-
elif sys.platform == "darwin":
45-
var = "DYLD_LIBRARY_PATH"
46-
elif sys.platform == "win32":
47-
var = "PATH"
48-
path = os.environ.get(var, '')
49-
sulong_path = os.pathsep.join(__graalpython__.get_toolchain_paths('LD_LIBRARY_PATH'))
50-
os.environ[var] = f"{path}{os.pathsep}{sulong_path}" if path else sulong_path
41+
if __graalpython__.ext_mode == "llvm":
42+
import os, sys
43+
if sys.platform == "linux":
44+
var = "LD_LIBRARY_PATH"
45+
elif sys.platform == "darwin":
46+
var = "DYLD_LIBRARY_PATH"
47+
elif sys.platform == "win32":
48+
var = "PATH"
49+
path = os.environ.get(var, '')
50+
sulong_path = os.pathsep.join(__graalpython__.get_toolchain_paths('LD_LIBRARY_PATH'))
51+
os.environ[var] = f"{path}{os.pathsep}{sulong_path}" if path else sulong_path

0 commit comments

Comments
 (0)