# define USE_MCJIT 1
#elif defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
# define USE_MCJIT 1
+#endif
+
+#if defined(USE_MCJIT)
+static const bool use_mcjit = USE_MCJIT;
#else
-static bool USE_MCJIT = 0;
+static bool use_mcjit = FALSE;
#endif
FREE(gallivm->module_name);
- if (!USE_MCJIT) {
+ if (!use_mcjit) {
/* Don't free the TargetData, it's owned by the exec engine */
} else {
if (gallivm->target) {
gallivm->module,
gallivm->memorymgr,
(unsigned) optlevel,
- USE_MCJIT,
+ use_mcjit,
&error);
if (ret) {
_debug_printf("%s\n", error);
}
}
- if (!USE_MCJIT) {
+ if (!use_mcjit) {
gallivm->target = LLVMGetExecutionEngineTargetData(gallivm->engine);
if (!gallivm->target)
goto fail;
* complete when MC-JIT is created. So defer the MC-JIT engine creation for
* now.
*/
- if (!USE_MCJIT) {
+ if (!use_mcjit) {
if (!init_gallivm_engine(gallivm)) {
goto fail;
}
if (gallivm_initialized)
return TRUE;
- LLVMLinkInMCJIT();
-#if !defined(USE_MCJIT)
- USE_MCJIT = debug_get_bool_option("GALLIVM_MCJIT", 0);
+
+ /* LLVMLinkIn* are no-ops at runtime. They just ensure the respective
+ * component is linked at buildtime, which is sufficient for its static
+ * constructors to be called at load time.
+ */
+#if defined(USE_MCJIT)
+# if USE_MCJIT
+ LLVMLinkInMCJIT();
+# else
+ LLVMLinkInJIT();
+# endif
+#else
+ use_mcjit = debug_get_bool_option("GALLIVM_MCJIT", FALSE);
LLVMLinkInJIT();
+ LLVMLinkInMCJIT();
#endif
#ifdef DEBUG
util_cpu_caps.has_f16c = 0;
util_cpu_caps.has_fma = 0;
}
- if (HAVE_LLVM < 0x0304 || !USE_MCJIT) {
+ if (HAVE_LLVM < 0x0304 || !use_mcjit) {
/* AVX2 support has only been tested with LLVM 3.4, and it requires
* MCJIT. */
util_cpu_caps.has_avx2 = 0;
debug_printf("Invoke as \"llc -o - %s\"\n", filename);
}
- if (USE_MCJIT) {
+ if (use_mcjit) {
assert(!gallivm->engine);
if (!init_gallivm_engine(gallivm)) {
assert(0);