[mlir] ExecutionEngine needs special handling for COFF binaries

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D97141
This commit is contained in:
Kern Handa 2021-02-21 01:20:37 -08:00
parent 16a50c9e64
commit 3c4cdd0b6a

View File

@ -255,6 +255,15 @@ Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
if (engine->perfListener)
objectLayer->registerJITEventListener(*engine->perfListener);
// COFF format binaries (Windows) need special handling to deal with
// exported symbol visibility.
// cf llvm/lib/ExecutionEngine/Orc/LLJIT.cpp LLJIT::createObjectLinkingLayer
llvm::Triple targetTriple(llvm::Twine(llvmModule->getTargetTriple()));
if (targetTriple.isOSBinFormatCOFF()) {
objectLayer->setOverrideObjectFlagsWithResponsibilityFlags(true);
objectLayer->setAutoClaimResponsibilityForObjectSymbols(true);
}
// Resolve symbols from shared libraries.
for (auto libPath : sharedLibPaths) {
auto mb = llvm::MemoryBuffer::getFile(libPath);