93
93
94
94
public abstract class CExtContext {
95
95
96
- private static final TruffleLogger LOGGER = CApiContext .getLogger (CExtContext .class );
96
+ // Due to the cycle CExtContext -> CApiContext < CExtContext this needs to be done lazily
97
+ private static TruffleLogger LOGGER ;
98
+
99
+ private static TruffleLogger getLogger () {
100
+ if (LOGGER == null ) {
101
+ LOGGER = CApiContext .getLogger (CExtContext .class );
102
+ }
103
+ return LOGGER ;
104
+ }
97
105
98
106
public static final CExtContext LAZY_CONTEXT = new CExtContext (null , null ) {
99
107
@ Override
@@ -325,12 +333,10 @@ public static Object loadCExtModule(Node location, PythonContext context, Module
325
333
if (loaded ) {
326
334
String name = spec .name .toJavaStringUncached ();
327
335
if (!isForcedLLVM (name ) && (nativeModuleOption .equals ("all" ) || moduleMatches (name , nativeModuleOption .split ("," )))) {
328
- if (cApiContext .supportsNativeBackend ) {
329
- GraalHPyContext .loadJNIBackend ();
330
- LOGGER .config ("loading module " + spec .path + " as native" );
331
- boolean panama = PythonOptions .UsePanama .getValue (PythonContext .get (null ).getEnv ().getOptions ());
332
- library = GraalHPyContext .evalNFI (context , (panama ? "with panama " : "" ) + "load \" " + spec .path + "\" " , "load " + spec .name );
333
- }
336
+ GraalHPyContext .loadJNIBackend ();
337
+ getLogger ().config ("loading module " + spec .path + " as native" );
338
+ boolean panama = PythonOptions .UsePanama .getValue (PythonContext .get (null ).getEnv ().getOptions ());
339
+ library = GraalHPyContext .evalNFI (context , (panama ? "with panama " : "" ) + "load \" " + spec .path + "\" " , "load " + spec .name );
334
340
}
335
341
} else {
336
342
cApiContext .supportsNativeBackend = false ;
@@ -342,12 +348,12 @@ public static Object loadCExtModule(Node location, PythonContext context, Module
342
348
try {
343
349
if (InteropLibrary .getUncached (library ).getLanguage (library ).toString ().startsWith ("class com.oracle.truffle.nfi" )) {
344
350
if (cApiContext .supportsNativeBackend ) {
345
- LOGGER .config ("loading module " + spec .path + " as native (no bitcode found)" );
351
+ getLogger () .config ("loading module " + spec .path + " as native (no bitcode found)" );
346
352
} else {
347
353
throw PRaiseNode .raiseUncached (null , SystemError , ErrorMessages .CANNOT_MULTICONTEXT );
348
354
}
349
355
} else {
350
- LOGGER .config ("loading module " + spec .path + " as llvm bitcode" );
356
+ getLogger () .config ("loading module " + spec .path + " as llvm bitcode" );
351
357
}
352
358
} catch (UnsupportedMessageException e ) {
353
359
throw CompilerDirectives .shouldNotReachHere (e );
0 commit comments