|
57 | 57 | import com.oracle.graal.python.builtins.PythonBuiltins;
|
58 | 58 | import com.oracle.graal.python.builtins.modules.PythonCextBuiltinsFactory.DefaultCheckFunctionResultNodeGen;
|
59 | 59 | import com.oracle.graal.python.builtins.objects.PNone;
|
60 |
| -import com.oracle.graal.python.builtins.objects.PythonAbstractObjectFactory.PInteropGetAttributeNodeGen; |
61 | 60 | import com.oracle.graal.python.builtins.objects.bytes.PBytes;
|
62 | 61 | import com.oracle.graal.python.builtins.objects.bytes.PBytesLike;
|
63 | 62 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.AsPythonObjectNodeGen;
|
|
117 | 116 | import com.oracle.truffle.api.interop.UnsupportedMessageException;
|
118 | 117 | import com.oracle.truffle.api.interop.UnsupportedTypeException;
|
119 | 118 | import com.oracle.truffle.api.library.CachedLibrary;
|
120 |
| -import com.oracle.truffle.api.nodes.LanguageInfo; |
121 | 119 | import com.oracle.truffle.api.source.Source;
|
122 | 120 | import com.oracle.truffle.api.source.Source.SourceBuilder;
|
123 |
| -import com.oracle.truffle.llvm.api.Toolchain; |
124 | 121 |
|
125 | 122 | @CoreFunctions(defineModule = "_imp")
|
126 | 123 | public class ImpModuleBuiltins extends PythonBuiltins {
|
@@ -341,7 +338,7 @@ private Object loadDynamicModuleWithSpec(String name, String path, InteropLibrar
|
341 | 338 | String basename = name.substring(name.lastIndexOf('.') + 1);
|
342 | 339 | TruffleObject sulongLibrary;
|
343 | 340 | try {
|
344 |
| - String extSuffix = ExtensionSuffixesNode.getSoAbi(context); |
| 341 | + String extSuffix = context.getSoAbi(); |
345 | 342 | CallTarget callTarget = env.parseInternal(Source.newBuilder(LLVM_LANGUAGE, context.getPublicTruffleFileRelaxed(path, extSuffix)).build());
|
346 | 343 | sulongLibrary = (TruffleObject) callTarget.call();
|
347 | 344 | } catch (SecurityException e) {
|
@@ -443,7 +440,7 @@ private void ensureCapiWasLoaded(String name, String path) throws IOException, I
|
443 | 440 | Env env = context.getEnv();
|
444 | 441 | CompilerDirectives.transferToInterpreterAndInvalidate();
|
445 | 442 |
|
446 |
| - String libPythonName = "libpython" + ExtensionSuffixesNode.getSoAbi(context); |
| 443 | + String libPythonName = "libpython" + context.getSoAbi(); |
447 | 444 | TruffleFile homePath = env.getInternalTruffleFile(context.getCAPIHome());
|
448 | 445 | TruffleFile capiFile = homePath.resolve(libPythonName);
|
449 | 446 | Object capi;
|
@@ -481,7 +478,7 @@ private GraalHPyContext ensureHPyWasLoaded(PythonContext context, String name, S
|
481 | 478 | Env env = context.getEnv();
|
482 | 479 | CompilerDirectives.transferToInterpreterAndInvalidate();
|
483 | 480 |
|
484 |
| - String libPythonName = "libhpy" + ExtensionSuffixesNode.getSoAbi(context); |
| 481 | + String libPythonName = "libhpy" + context.getSoAbi(); |
485 | 482 | TruffleFile homePath = env.getInternalTruffleFile(context.getCAPIHome());
|
486 | 483 | TruffleFile capiFile = homePath.resolve(libPythonName);
|
487 | 484 | try {
|
@@ -703,34 +700,7 @@ public abstract static class ExtensionSuffixesNode extends PythonBuiltinNode {
|
703 | 700 | @Specialization
|
704 | 701 | Object run(
|
705 | 702 | @CachedContext(PythonLanguage.class) PythonContext ctxt) {
|
706 |
| - String soAbi = getSoAbi(ctxt); |
707 |
| - return factory().createList(new Object[]{soAbi, HPY_SUFFIX, ".so", ".dylib", ".su"}); |
708 |
| - } |
709 |
| - |
710 |
| - @TruffleBoundary |
711 |
| - public static String getSoAbi(PythonContext ctxt) { |
712 |
| - PythonModule sysModule = ctxt.getCore().lookupBuiltinModule("sys"); |
713 |
| - Object implementationObj = ReadAttributeFromObjectNode.getUncached().execute(sysModule, "implementation"); |
714 |
| - // sys.implementation.cache_tag |
715 |
| - String cacheTag = (String) PInteropGetAttributeNodeGen.getUncached().execute(implementationObj, "cache_tag"); |
716 |
| - // sys.implementation._multiarch |
717 |
| - String multiArch = (String) PInteropGetAttributeNodeGen.getUncached().execute(implementationObj, "_multiarch"); |
718 |
| - |
719 |
| - Env env = ctxt.getEnv(); |
720 |
| - LanguageInfo llvmInfo = env.getInternalLanguages().get(GraalPythonModuleBuiltins.LLVM_LANGUAGE); |
721 |
| - Toolchain toolchain = env.lookup(llvmInfo, Toolchain.class); |
722 |
| - String toolchainId = toolchain.getIdentifier(); |
723 |
| - |
724 |
| - // only use '.dylib' if we are on 'Darwin-native' |
725 |
| - String soExt; |
726 |
| - if ("darwin".equals(PythonUtils.getPythonOSName()) && "native".equals(toolchainId)) { |
727 |
| - soExt = ".dylib"; |
728 |
| - } else { |
729 |
| - soExt = ".so"; |
730 |
| - } |
731 |
| - |
732 |
| - return "." + cacheTag + "-" + toolchainId + "-" + multiArch + soExt; |
| 703 | + return factory().createList(new Object[]{ctxt.getSoAbi(), HPY_SUFFIX, ".so", ".dylib", ".su"}); |
733 | 704 | }
|
734 | 705 | }
|
735 |
| - |
736 | 706 | }
|
0 commit comments