diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 5c59b25a..88c4f377 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -36,7 +36,9 @@ bool LLVM_D_InitRuntime() Logger::println("*** Initializing D runtime declarations ***"); LOG_SCOPE; - LLVM_D_BuildRuntimeModule(); + if (!M) + LLVM_D_BuildRuntimeModule(); + return true; } diff --git a/gen/toir.cpp b/gen/toir.cpp index 8270fbc0..5cd18f4f 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -2585,8 +2585,8 @@ void obj_includelib(const char* lib) void backend_init() { - // now lazily loaded - //LLVM_D_InitRuntime(); + // LLVM_D_InitRuntime is done in Module::genLLVMModule + // since it requires the semantic pass to be done } void backend_term() diff --git a/gen/toobj.cpp b/gen/toobj.cpp index f1306988..e459d1bc 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -134,6 +134,8 @@ llvm::Module* Module::genLLVMModule(Ir* sir) error("is missing 'class ClassInfo'"); fatal(); } + + LLVM_D_InitRuntime(); // process module members for (int k=0; k < members->dim; k++) {