Skip to content

Commit f33b990

Browse files
authored
Merge pull request #24242 from bob-wilson/rdar50110036
References to _swift_FORCE_LOAD* symbols should be weak
2 parents cdb9fb4 + dd94a9f commit f33b990

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

include/swift/IRGen/Linking.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,7 @@ struct IRLinkage {
11271127
static const IRLinkage Internal;
11281128

11291129
static const IRLinkage ExternalImport;
1130+
static const IRLinkage ExternalWeakImport;
11301131
static const IRLinkage ExternalExport;
11311132
};
11321133

lib/IRGen/IRGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ void IRGenModule::addLinkLibrary(const LinkLibrary &linkLib) {
985985
encodeForceLoadSymbolName(buf, linkLib.getName());
986986
auto ForceImportThunk =
987987
Module.getOrInsertFunction(buf, llvm::FunctionType::get(VoidTy, false));
988-
ApplyIRLinkage(IRLinkage::ExternalImport)
988+
ApplyIRLinkage(IRLinkage::ExternalWeakImport)
989989
.to(cast<llvm::GlobalValue>(ForceImportThunk));
990990

991991
buf += "_$";

lib/IRGen/Linking.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ const IRLinkage IRLinkage::ExternalImport = {
5757
llvm::GlobalValue::DLLImportStorageClass,
5858
};
5959

60+
const IRLinkage IRLinkage::ExternalWeakImport = {
61+
llvm::GlobalValue::ExternalWeakLinkage,
62+
llvm::GlobalValue::DefaultVisibility,
63+
llvm::GlobalValue::DLLImportStorageClass,
64+
};
65+
6066
const IRLinkage IRLinkage::ExternalExport = {
6167
llvm::GlobalValue::ExternalLinkage,
6268
llvm::GlobalValue::DefaultVisibility,

test/Serialization/autolinking.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ import someModule
4646
// FORCE-LOAD-CLIENT: @llvm.used = appending global [{{[0-9]+}} x i8*] [
4747
// FORCE-LOAD-CLIENT: i8* bitcast (void ()** @"_swift_FORCE_LOAD_$_module_$_autolinking" to i8*)
4848
// FORCE-LOAD-CLIENT: ], section "llvm.metadata"
49-
// FORCE-LOAD-CLIENT: declare {{(dllimport )?}}void @"_swift_FORCE_LOAD_$_module"()
49+
// FORCE-LOAD-CLIENT: declare extern_weak {{(dllimport )?}}void @"_swift_FORCE_LOAD_$_module"()
5050

0 commit comments

Comments
 (0)