diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-09-09 09:01:17 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-09-09 09:01:17 +0000 |
commit | f9ef3ff6e2ee04c09e09e68d6ffcafc094485c1e (patch) | |
tree | 84051c2e3cc48297e330441dd7215326d26599a0 /llvm/lib/Linker/LinkModules.cpp | |
parent | d545c2ce5ad1891282e8818b47ffe557c76a86b4 (diff) |
Diffstat (limited to 'llvm/lib/Linker/LinkModules.cpp')
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 97d6f8cd8075..efdbc49cdf47 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -177,9 +177,25 @@ bool ModuleLinker::computeResultingSelectionKind(StringRef ComdatName, // Go with Dst. LinkFromSrc = false; break; - case Comdat::SelectionKind::NoDeduplicate: - return emitError("Linking COMDATs named '" + ComdatName + - "': nodeduplicate has been violated!"); + case Comdat::SelectionKind::NoDeduplicate: { + const GlobalVariable *DstGV; + const GlobalVariable *SrcGV; + if (getComdatLeader(DstM, ComdatName, DstGV) || + getComdatLeader(*SrcM, ComdatName, SrcGV)) + return true; + + if (SrcGV->isWeakForLinker()) { + // Go with Dst. + LinkFromSrc = false; + } else if (DstGV->isWeakForLinker()) { + // Go with Src. + LinkFromSrc = true; + } else { + return emitError("Linking COMDATs named '" + ComdatName + + "': nodeduplicate has been violated!"); + } + break; + } case Comdat::SelectionKind::ExactMatch: case Comdat::SelectionKind::Largest: case Comdat::SelectionKind::SameSize: { |