From df2a1c5fb307c0d2d4d9493c1831a38cf8a24843 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Mon, 25 Jan 2021 12:03:58 +0100 Subject: [PATCH] Don't touch gvars when compiling for an external back-end. --- src/aotcompile.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp index c95d6430e04dd..5f2d159db2cc0 100644 --- a/src/aotcompile.cpp +++ b/src/aotcompile.cpp @@ -279,7 +279,7 @@ static void jl_ci_cache_lookup(const jl_cgparams_t &cgparams, jl_method_instance // takes the running content that has collected in the shadow module and dump it to disk // this builds the object file portion of the sysimage files for fast startup, and can // also be used be extern consumers like GPUCompiler.jl to obtain a module containing -// all reachable & inferrrable functions. The `policy` flag switches between the defaul +// all reachable & inferrrable functions. The `policy` flag switches between the default // mode `0` and the extern mode `1`. extern "C" JL_DLLEXPORT void *jl_create_native(jl_array_t *methods, const jl_cgparams_t cgparams, int _policy) @@ -404,16 +404,18 @@ void *jl_create_native(jl_array_t *methods, const jl_cgparams_t cgparams, int _p // move everything inside, now that we've merged everything // (before adding the exported headers) - for (GlobalObject &G : clone->global_objects()) { - if (!G.isDeclaration()) { - G.setLinkage(Function::InternalLinkage); - makeSafeName(G); - addComdat(&G); + if (policy != CompilationPolicy::Extern) { + for (GlobalObject &G : clone->global_objects()) { + if (!G.isDeclaration()) { + G.setLinkage(Function::InternalLinkage); + makeSafeName(G); + addComdat(&G); #if defined(_OS_WINDOWS_) && defined(_CPU_X86_64_) - // Add unwind exception personalities to functions to handle async exceptions - if (Function *F = dyn_cast(&G)) - F->setPersonalityFn(juliapersonality_func); + // Add unwind exception personalities to functions to handle async exceptions + if (Function *F = dyn_cast(&G)) + F->setPersonalityFn(juliapersonality_func); #endif + } } }