Skip to content

Commit e0e3555

Browse files
committed
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 7bb2064 commit e0e3555

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
@@ -1388,8 +1388,12 @@ getIRLinkage(const UniversalLinkageInfo &info, SILLinkage linkage,
13881388
case SILLinkage::Private:
13891389
// In case of multiple llvm modules (in multi-threaded compilation) all
13901390
// private decls must be visible from other files.
1391+
// We use LinkOnceODR instead of External here because private lazy protocol
1392+
// witness table accessors could be emitted by two different IGMs during
1393+
// IRGen into different object files and the linker would complain about
1394+
// duplicate symbols.
13911395
if (info.HasMultipleIGMs)
1392-
return RESULT(External, Hidden, Default);
1396+
return RESULT(LinkOnceODR, Hidden, Default);
13931397
return RESULT(Internal, Default, Default);
13941398

13951399
case SILLinkage::PublicExternal: {

0 commit comments

Comments
 (0)