Skip to content

Commit 5bbe1ee

Browse files
Palezrschatz
authored andcommitted
Load C extensions with RTLD_GLOBAL.
1 parent 7e07d2b commit 5bbe1ee

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

mx.truffleruby/suite.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
"truffle:TRUFFLE_NFI",
237237
"regex:TREGEX",
238238
"sulong:SULONG_API",
239+
"sulong:SULONG_NFI",
239240
# Libraries, keep in sync with TRUFFLERUBY.exclude and truffle_jars (in mx_truffleruby.py)
240241
"sdk:JLINE3",
241242
"truffleruby:JCODINGS",
@@ -434,6 +435,7 @@
434435
"truffle:TRUFFLE_NFI",
435436
"regex:TREGEX",
436437
"sulong:SULONG_API",
438+
"sulong:SULONG_NFI",
437439
],
438440
"exclude": [ # Keep in sync with org.truffleruby dependencies and truffle_jars in mx_truffleruby.py
439441
"sdk:JLINE3",

src/main/java/org/truffleruby/language/loader/FeatureLoader.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -505,17 +505,12 @@ public Object loadCExtLibrary(String feature, String path, Node currentNode) {
505505
try {
506506
final TruffleFile truffleFile = FileLoader.getSafeTruffleFile(language, context, path);
507507
FileLoader.ensureReadable(context, truffleFile, currentNode);
508-
509-
final Source source;
510-
try {
511-
source = Source.newBuilder("llvm", truffleFile).build();
512-
} catch (IOException e) {
513-
throw new RaiseException(context, context.getCoreExceptions().loadError(e, path, currentNode));
514-
}
515-
508+
final Source source = Source
509+
.newBuilder("nfi", "with llvm load (RTLD_GLOBAL) '" + path + "'",
510+
"load RTLD_GLOBAL with Sulong through NFI")
511+
.build();
516512
final Object library = context.getEnv().parseInternal(source).call();
517-
518-
final Object embeddedABIVersion = getEmbeddedABIVersion(path, library);
513+
final Object embeddedABIVersion = getEmbeddedABIVersion(library);
519514
DispatchNode.getUncached().call(context.getCoreLibrary().truffleCExtModule, "check_abi_version",
520515
embeddedABIVersion, path);
521516

@@ -525,7 +520,7 @@ public Object loadCExtLibrary(String feature, String path, Node currentNode) {
525520
}
526521
}
527522

528-
private Object getEmbeddedABIVersion(String expandedPath, Object library) {
523+
private Object getEmbeddedABIVersion(Object library) {
529524
final Object abiVersionFunction;
530525
try {
531526
abiVersionFunction = InteropLibrary.getFactory().getUncached(library).readMember(library,

0 commit comments

Comments
 (0)