Skip to content

Commit

Permalink
[ORC] Turn on symbol-flags overrides for LLJIT on Windows by default.
Browse files Browse the repository at this point in the history
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.

llvm-svn: 367712
  • Loading branch information
lhames committed Aug 2, 2019
1 parent fae0a60 commit cb39127
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
Expand Up @@ -184,8 +184,8 @@ class LLLazyJIT : public LLJIT {

class LLJITBuilderState {
public:
using ObjectLinkingLayerCreator =
std::function<std::unique_ptr<ObjectLayer>(ExecutionSession &)>;
using ObjectLinkingLayerCreator = std::function<std::unique_ptr<ObjectLayer>(
ExecutionSession &, const Triple &TT)>;

using CompileFunctionCreator =
std::function<Expected<IRCompileLayer::CompileFunction>(
Expand Down
10 changes: 8 additions & 2 deletions llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
Expand Up @@ -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<SectionMemoryManager>(); };
return llvm::make_unique<RTDyldObjectLinkingLayer>(ES, std::move(GetMemMgr));
auto ObjLinkingLayer =
llvm::make_unique<RTDyldObjectLinkingLayer>(ES, std::move(GetMemMgr));

if (S.JTMB->getTargetTriple().isOSBinFormatCOFF())
ObjLinkingLayer->setOverrideObjectFlagsWithResponsibilityFlags(true);

return ObjLinkingLayer;
}

Expected<IRCompileLayer::CompileFunction>
Expand Down

0 comments on commit cb39127

Please sign in to comment.