Ignore duplicate kept GlobalValues

Set WeakAnyLinkage instead of ExternalLinkage to tell the JIT linker
that it should not error on duplicate symbols.
This commit is contained in:
Jonas Hahnfeld 2022-05-23 08:53:31 +02:00 committed by jenkins
parent b721467e15
commit 3bbcfe34b1

View File

@ -59,7 +59,12 @@ namespace {
if (LT == llvm::GlobalValue::InternalLinkage
|| LT == llvm::GlobalValue::PrivateLinkage) {
GV.setLinkage(llvm::GlobalValue::ExternalLinkage);
// We want to keep this GlobalValue around, but have to tell the JIT
// linker that it should not error on duplicate symbols.
// FIXME: Ideally the frontend would never emit duplicate symbols and
// we could just use the old version of saying:
// GV.setLinkage(llvm::GlobalValue::ExternalLinkage);
GV.setLinkage(llvm::GlobalValue::WeakAnyLinkage);
return true; // a change!
}
return false;