Skip to content

Commit 904ccca

Browse files
committed
Pull support lib file ext out of getLibPath
1 parent 21445a8 commit 904ccca

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/StringLiterals.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,12 @@ public abstract class StringLiterals {
162162
public static final String J_TYPE_ID = "_typeid";
163163
public static final TruffleString T_TYPE_ID = tsLiteral(J_TYPE_ID);
164164

165-
public static final TruffleString T_EXT_SO = tsLiteral(".so");
166-
public static final TruffleString T_EXT_PYD = tsLiteral(".pyd");
165+
public static final String J_EXT_SO = ".so";
166+
public static final TruffleString T_EXT_SO = tsLiteral(J_EXT_SO);
167+
public static final String J_EXT_PYD = ".pyd";
168+
public static final TruffleString T_EXT_PYD = tsLiteral(J_EXT_PYD);
169+
public static final String J_EXT_DYLIB = ".dylib";
170+
public static final TruffleString T_EXT_DYLIB = tsLiteral(J_EXT_DYLIB);
167171

168172
public static final TruffleString T_NATIVE = tsLiteral("native");
169173

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -155,7 +155,7 @@ public String signature() {
155155
private NFIBz2Support(PythonContext context, NativeLibrary.NFIBackend backend, String noNativeAccessHelp) {
156156
if (context.isNativeAccessAllowed()) {
157157
this.pythonContext = context;
158-
this.typedNativeLib = NativeLibrary.create(SUPPORTING_NATIVE_LIB_NAME, Bz2NativeFunctions.values(),
158+
this.typedNativeLib = NativeLibrary.create(SUPPORTING_NATIVE_LIB_NAME + context.getSoAbi().toJavaStringUncached(), Bz2NativeFunctions.values(),
159159
backend, noNativeAccessHelp, false);
160160
this.available = true;
161161
} else {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -295,7 +295,7 @@ public String signature() {
295295
private NFILZMASupport(PythonContext context, NativeLibrary.NFIBackend backend, String noNativeAccessHelp) {
296296
if (context.isNativeAccessAllowed()) {
297297
this.pythonContext = context;
298-
this.typedNativeLib = NativeLibrary.create(SUPPORTING_NATIVE_LIB_NAME, LZMANativeFunctions.values(),
298+
this.typedNativeLib = NativeLibrary.create(SUPPORTING_NATIVE_LIB_NAME + context.getSoAbi().toJavaStringUncached(), LZMANativeFunctions.values(),
299299
backend, noNativeAccessHelp, true);
300300
this.available = true;
301301
} else {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -268,8 +268,8 @@ public String signature() {
268268
private NFIZlibSupport(PythonContext context, NativeLibrary.NFIBackend backend, String noNativeAccessHelp) {
269269
if (context.isNativeAccessAllowed()) {
270270
this.pythonContext = context;
271-
this.typedNativeLib = NativeLibrary.create(SUPPORTING_NATIVE_LIB_NAME, ZlibNativeFunctions.values(),
272-
backend, noNativeAccessHelp, true);
271+
this.typedNativeLib = NativeLibrary.create(SUPPORTING_NATIVE_LIB_NAME + PythonContext.getSupportExt(),
272+
ZlibNativeFunctions.values(), backend, noNativeAccessHelp, true);
273273
this.available = true;
274274
} else {
275275
this.pythonContext = null;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private Object loadLibrary(PythonContext context) {
258258
private static String getLibPath(PythonContext context, String name) {
259259
CompilerAsserts.neverPartOfCompilation();
260260
TruffleFile homePath = context.getEnv().getInternalTruffleFile(context.getCAPIHome().toJavaStringUncached());
261-
TruffleFile file = homePath.resolve(name + context.getSoAbi().toJavaStringUncached());
261+
TruffleFile file = homePath.resolve(name);
262262
return file.getPath();
263263
}
264264

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___ANNOTATIONS__;
4040
import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___FILE__;
4141
import static com.oracle.graal.python.nodes.SpecialMethodNames.T_INSERT;
42+
import static com.oracle.graal.python.nodes.StringLiterals.J_EXT_DYLIB;
43+
import static com.oracle.graal.python.nodes.StringLiterals.J_EXT_PYD;
44+
import static com.oracle.graal.python.nodes.StringLiterals.J_EXT_SO;
4245
import static com.oracle.graal.python.nodes.StringLiterals.J_LLVM_LANGUAGE;
4346
import static com.oracle.graal.python.nodes.StringLiterals.T_DASH;
4447
import static com.oracle.graal.python.nodes.StringLiterals.T_DOT;
@@ -2476,6 +2479,15 @@ public long getDeserializationId(TruffleString fileName) {
24762479
return deserializationId.computeIfAbsent(fileName, f -> new AtomicLong()).incrementAndGet();
24772480
}
24782481

2482+
@TruffleBoundary
2483+
public static String getSupportExt() {
2484+
return switch (getPythonOS()) {
2485+
case PLATFORM_DARWIN -> J_EXT_DYLIB;
2486+
case PLATFORM_WIN32 -> J_EXT_PYD;
2487+
default -> J_EXT_SO;
2488+
};
2489+
}
2490+
24792491
@TruffleBoundary
24802492
public TruffleString getSoAbi() {
24812493
if (soABI == null) {

0 commit comments

Comments
 (0)