Use weak_odr linkage when reusing definitions across codegen units
When reuing a definition across codegen units, we obviously cannot use internal linkage, but using external linkage means that we can end up with multiple conflicting definitions of a single symbol across multiple crates. Since the definitions should all be equal semantically, we can use weak_odr linkage to resolve the situation. Fixes #32518
This commit is contained in:
@@ -1189,3 +1189,16 @@ extern "C" void LLVMRustPositionBuilderAtStart(LLVMBuilderRef B, LLVMBasicBlockR
|
||||
auto point = unwrap(BB)->getFirstInsertionPt();
|
||||
unwrap(B)->SetInsertPoint(unwrap(BB), point);
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustSetComdat(LLVMModuleRef M, LLVMValueRef V, const char *Name) {
|
||||
Triple TargetTriple(unwrap(M)->getTargetTriple());
|
||||
GlobalObject *GV = unwrap<GlobalObject>(V);
|
||||
if (!TargetTriple.isOSBinFormatMachO()) {
|
||||
GV->setComdat(unwrap(M)->getOrInsertComdat(Name));
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustUnsetComdat(LLVMValueRef V) {
|
||||
GlobalObject *GV = unwrap<GlobalObject>(V);
|
||||
GV->setComdat(nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user