-
-
Notifications
You must be signed in to change notification settings - Fork 268
Closed
Labels
llvmRelated to LLVMRelated to LLVM
Description
When using LLD with -flto=thin
, we are running into the problem that each D module's call to ldc.register_dso
in llvm.global_ctors
is not folded into one call. We are relying on LLVM functionality where if a D module's ldc.register_dso
is "discarded" because of another module's ldc.register_dso
overriding it, then the entry in llvm.global_ctors
is also discarded. This is apparently happening with ld.gold
, but not with ld.lld
.
It's related to this work: #2870
Strangely, when I manually put the ctor/dtor in .init_array
/.fini_array
sections, the symbols are not merged either (not with bfd, gold, or lld). That is, replacing
Lines 367 to 368 in 2ec2fd7
llvm::appendToGlobalCtors(gIR->module, registerDSO, 65535, registerDSO); | |
llvm::appendToGlobalDtors(gIR->module, registerDSO, 65535, registerDSO); |
const auto dsoCtor = defineDSOGlobal("ldc.dso_ctor", registerDSO);
const auto dsoDtor = defineDSOGlobal("ldc.dso_dtor", registerDSO);
gIR->usedArray.push_back(dsoCtor);
gIR->usedArray.push_back(dsoDtor);
dsoCtor->setSection(".init_array");
dsoDtor->setSection(".fini_array");
Metadata
Metadata
Assignees
Labels
llvmRelated to LLVMRelated to LLVM