Skip to content

Commit 5ff0707

Browse files
committed
[swift-4.0-branch] IRGen: Use link_once instead of external for private decls
We can get duplicate symbols for accessors IRGen creates per IGM instance e.g for lazy protocol witness table accessors. (A better but more risky fix is to hoist the caching of the accessors to IRGenerator so that we only generate them once per module to begin with) Yes I owe a test case here ... rdar://31988578
1 parent 856c0c7 commit 5ff0707

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,8 +1393,12 @@ getIRLinkage(const UniversalLinkageInfo &info, SILLinkage linkage,
13931393
case SILLinkage::Private:
13941394
// In case of multiple llvm modules (in multi-threaded compilation) all
13951395
// private decls must be visible from other files.
1396+
// We use LinkOnceODR instead of External here because private lazy protocol
1397+
// witness table accessors could be emitted by two different IGMs during
1398+
// IRGen into different object files and the linker would complain about
1399+
// duplicate symbols.
13961400
if (info.HasMultipleIGMs)
1397-
return RESULT(External, Hidden, Default);
1401+
return RESULT(LinkOnceODR, Hidden, Default);
13981402
return RESULT(Internal, Default, Default);
13991403

14001404
case SILLinkage::PublicExternal: {

0 commit comments

Comments
 (0)