diff --git a/driver/cl_options.h b/driver/cl_options.h index d638354dea..34856b70fb 100644 --- a/driver/cl_options.h +++ b/driver/cl_options.h @@ -128,6 +128,9 @@ extern cl::list dcomputeTargets; #if defined(LDC_RUNTIME_COMPILE) extern cl::opt enableRuntimeCompile; +inline bool isRuntimeCompileEnabled() { return enableRuntimeCompile; } +#else +inline bool isRuntimeCompileEnabled() { return false; } #endif } #endif diff --git a/driver/linker-gcc.cpp b/driver/linker-gcc.cpp index 323d9976ea..c76fb33131 100644 --- a/driver/linker-gcc.cpp +++ b/driver/linker-gcc.cpp @@ -340,12 +340,10 @@ void ArgsBuilder::build(llvm::StringRef outputPath, args.push_back("-lldc-profile-rt"); } -#if defined(LDC_RUNTIME_COMPILE) - if (opts::enableRuntimeCompile) { + if (opts::isRuntimeCompileEnabled()) { args.push_back("-lldc-jit-rt"); args.push_back("-lldc-jit"); } -#endif // user libs for (auto libfile : *global.params.libfiles) { diff --git a/driver/linker-msvc.cpp b/driver/linker-msvc.cpp index fdcca11e7c..80055960af 100644 --- a/driver/linker-msvc.cpp +++ b/driver/linker-msvc.cpp @@ -118,12 +118,10 @@ int linkObjToBinaryMSVC(llvm::StringRef outputPath, bool useInternalLinker, args.push_back("ws2_32.lib"); } -#if defined(LDC_RUNTIME_COMPILE) - if (opts::enableRuntimeCompile) { + if (opts::isRuntimeCompileEnabled()) { args.push_back("ldc-jit-rt.lib"); args.push_back("ldc-jit.lib"); } -#endif // user libs for (auto libfile : *global.params.libfiles) { diff --git a/driver/main.cpp b/driver/main.cpp index 3170515d47..9eb3ae6ff4 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -944,11 +944,9 @@ void registerPredefinedVersions() { VersionCondition::addPredefinedGlobalIdent("D_ObjectiveC"); } -#if defined(LDC_RUNTIME_COMPILE) - if (opts::enableRuntimeCompile) { + if (opts::isRuntimeCompileEnabled()) { VersionCondition::addPredefinedGlobalIdent("LDC_RuntimeCompilation"); } -#endif // Define sanitizer versions. if (opts::isSanitizerEnabled(opts::AddressSanitizer)) { diff --git a/gen/runtimecompile.cpp b/gen/runtimecompile.cpp index c69cf8db65..9f68021300 100644 --- a/gen/runtimecompile.cpp +++ b/gen/runtimecompile.cpp @@ -630,7 +630,7 @@ void declareRuntimeCompiledFunction(IRState *irs, IrFunction *func) { assert(nullptr != irs); assert(nullptr != func); assert(nullptr != func->getLLVMFunc()); - if (!opts::enableRuntimeCompile) { + if (!opts::isRuntimeCompileEnabled()) { return; } auto srcFunc = func->getLLVMFunc(); @@ -647,7 +647,7 @@ void defineRuntimeCompiledFunction(IRState *irs, IrFunction *func) assert(nullptr != func); assert(nullptr != func->getLLVMFunc()); assert(nullptr != func->rtCompileFunc); - if (!opts::enableRuntimeCompile) { + if (!opts::isRuntimeCompileEnabled()) { return; } auto srcFunc = func->getLLVMFunc(); @@ -670,7 +670,7 @@ void addRuntimeCompiledVar(IRState *irs, IrGlobal *var) { assert(nullptr != var); assert(nullptr != var->value); assert(nullptr != var->V); - if (!opts::enableRuntimeCompile) { + if (!opts::isRuntimeCompileEnabled()) { return; }