From: Lang Hames Date: Fri, 2 Aug 2019 19:43:20 +0000 (+0000) Subject: [ORC] Turn on symbol-flags overrides for LLJIT on Windows by default. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cf5eb41c9a6838f5fb13d49d7867c88426ea3b39;p=llvm [ORC] Turn on symbol-flags overrides for LLJIT on Windows by default. libObject does not apply the Exported flag to symbols in COFF object files, which can lead to assertions when the symbol flags initially derived from IR added to the JIT clash with the flags seen by the JIT linker. Both RTDyldObjectLinkingLayer and ObjectLinkingLayer have a workaround for this: they can be told to override the flags seen by the linker with the flags attached to the materialization responsibility object that was passed down to the linker. This patch modifies LLJIT's setup code to enable this override by default on platforms where COFF is the default object format. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367712 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ExecutionEngine/Orc/LLJIT.h b/include/llvm/ExecutionEngine/Orc/LLJIT.h index 0aac1916423..b1e47d77557 100644 --- a/include/llvm/ExecutionEngine/Orc/LLJIT.h +++ b/include/llvm/ExecutionEngine/Orc/LLJIT.h @@ -184,8 +184,8 @@ private: class LLJITBuilderState { public: - using ObjectLinkingLayerCreator = - std::function(ExecutionSession &)>; + using ObjectLinkingLayerCreator = std::function( + ExecutionSession &, const Triple &TT)>; using CompileFunctionCreator = std::function( diff --git a/lib/ExecutionEngine/Orc/LLJIT.cpp b/lib/ExecutionEngine/Orc/LLJIT.cpp index 94323632391..14b3b6ac7f6 100644 --- a/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -64,12 +64,18 @@ LLJIT::createObjectLinkingLayer(LLJITBuilderState &S, ExecutionSession &ES) { // If the config state provided an ObjectLinkingLayer factory then use it. if (S.CreateObjectLinkingLayer) - return S.CreateObjectLinkingLayer(ES); + return S.CreateObjectLinkingLayer(ES, S.JTMB->getTargetTriple()); // Otherwise default to creating an RTDyldObjectLinkingLayer that constructs // a new SectionMemoryManager for each object. auto GetMemMgr = []() { return llvm::make_unique(); }; - return llvm::make_unique(ES, std::move(GetMemMgr)); + auto ObjLinkingLayer = + llvm::make_unique(ES, std::move(GetMemMgr)); + + if (S.JTMB->getTargetTriple().isOSBinFormatCOFF()) + ObjLinkingLayer->setOverrideObjectFlagsWithResponsibilityFlags(true); + + return ObjLinkingLayer; } Expected