diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp index 21ebe82c8a71a..4c50407f562cc 100644 --- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -946,8 +946,18 @@ Expected> LLJIT::createObjectLinkingLayer(LLJITBuilderState &S, ExecutionSession &ES) { // If the config state provided an ObjectLinkingLayer factory then use it. - if (S.CreateObjectLinkingLayer) - return S.CreateObjectLinkingLayer(ES); + if (S.CreateObjectLinkingLayer) { + auto Layer = S.CreateObjectLinkingLayer(ES); + if (Layer && S.JTMB->getTargetTriple().isOSBinFormatCOFF()) { + auto *RTDyldLayer = + dyn_cast_or_null(Layer.get().get()); + if (RTDyldLayer) { + RTDyldLayer->setOverrideObjectFlagsWithResponsibilityFlags(true); + RTDyldLayer->setAutoClaimResponsibilityForObjectSymbols(true); + } + } + return Layer; + } // Otherwise default to creating an RTDyldObjectLinkingLayer that constructs // a new SectionMemoryManager for each object.