Skip to content

Commit 534d589

Browse files
committed
IRGen: internalise well known types with static linking
When statically linking the standard library ensure that we emit the well known metadata and accessors with internal linkage. This fixes a number of warnings about incorrect DLL storage when building Foundation on Windows for static linking.
1 parent 1484f1c commit 534d589

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,16 +3963,20 @@ IRGenModule::getAddrOfLLVMVariable(LinkEntity entity,
39633963
// inside the standard library with the definition being in the runtime
39643964
// preventing the normal detection from identifying that this is module
39653965
// local.
3966-
if (getSwiftModule()->isStdlibModule())
3966+
//
3967+
// If we are statically linking the standard library, we need to internalise
3968+
// the symbols.
3969+
if (getSwiftModule()->isStdlibModule() ||
3970+
Context.getStdlibModule()->isStaticLibrary())
39673971
if (entity.isTypeKind() &&
39683972
(IsWellKnownBuiltinOrStructralType(entity.getType()) ||
39693973
entity.getType() == kAnyFunctionType))
39703974
if (auto *GV = dyn_cast<llvm::GlobalValue>(var))
3971-
if (GV->hasDLLImportStorageClass())
3972-
ApplyIRLinkage({llvm::GlobalValue::ExternalLinkage,
3973-
llvm::GlobalValue::DefaultVisibility,
3974-
llvm::GlobalValue::DefaultStorageClass})
3975-
.to(GV);
3975+
if (GV->hasDLLImportStorageClass())
3976+
ApplyIRLinkage({llvm::GlobalValue::ExternalLinkage,
3977+
llvm::GlobalValue::DefaultVisibility,
3978+
llvm::GlobalValue::DefaultStorageClass})
3979+
.to(GV);
39763980

39773981
// Install the concrete definition if we have one.
39783982
if (definition && definition.hasInit()) {

0 commit comments

Comments
 (0)