Skip to content

Commit 0ed83ff

Browse files
committed
Preload libjsig when running lkql_jit in JVM mode on Linux
1 parent 844f1f2 commit 0ed83ff

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

lkql_jit/cli/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@
7070
<version>0.1</version>
7171
</dependency>
7272

73+
<dependency>
74+
<groupId>com.adacore</groupId>
75+
<artifactId>langkit_support</artifactId>
76+
<version>${config.langkit_supportVersion}</version>
77+
</dependency>
78+
7379
<dependency>
7480
<groupId>com.adacore.lkql_jit</groupId>
7581
<artifactId>options</artifactId>

lkql_jit/cli/src/main/java/com/adacore/lkql_jit/cli/LKQLMain.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package com.adacore.lkql_jit.cli;
77

8+
import com.adacore.langkit_support.NativeTools;
89
import java.util.concurrent.Callable;
910
import picocli.CommandLine;
1011
import picocli.CommandLine.Command;
@@ -39,6 +40,17 @@ public Integer call() throws Exception {
3940
}
4041

4142
public static void main(String[] args) {
43+
// Start by unsetting the "LD_PRELOAD" environment variable to make
44+
// sure child processes aren't impacted by it.
45+
try {
46+
NativeTools.setenv("LD_PRELOAD", "");
47+
} catch (Throwable t) {
48+
System.err.println("Error while calling the 'setenv' function");
49+
t.printStackTrace();
50+
System.exit(1);
51+
}
52+
53+
// Then call the main processing function
4254
int rc = new CommandLine(new LKQLMain()).execute(args);
4355
System.exit(rc);
4456
}

lkql_jit/standalone/lkql.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
"PATH" if os.name == "nt" else "LD_LIBRARY_PATH", ""
5959
)
6060

61+
# Add "libjsig.so" to the LD_PRELOAD on Linux to avoid SIGILL errors
62+
env = dict(os.environ)
63+
if os.name != "nt":
64+
env |= {"LD_PRELOAD": P.join(graal_home, "lib", "libjsig.so")}
65+
6166
# Run the full Java command
6267
subprocess.run(
6368
[
@@ -102,5 +107,6 @@
102107
['--engine.CompileImmediately=true']
103108
if args.compile_immediately
104109
else []
105-
)
110+
),
111+
env=env
106112
)

0 commit comments

Comments
 (0)