File tree Expand file tree Collapse file tree 4 files changed +16
-4
lines changed Expand file tree Collapse file tree 4 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -1075,6 +1075,7 @@ struct IRLinkage {
1075
1075
static const IRLinkage Internal;
1076
1076
1077
1077
static const IRLinkage ExternalImport;
1078
+ static const IRLinkage ExternalWeakImport;
1078
1079
static const IRLinkage ExternalExport;
1079
1080
};
1080
1081
Original file line number Diff line number Diff line change @@ -981,8 +981,12 @@ void IRGenModule::addLinkLibrary(const LinkLibrary &linkLib) {
981
981
encodeForceLoadSymbolName (buf, linkLib.getName ());
982
982
auto ForceImportThunk =
983
983
Module.getOrInsertFunction (buf, llvm::FunctionType::get (VoidTy, false ));
984
- ApplyIRLinkage (IRLinkage::ExternalImport)
985
- .to (cast<llvm::GlobalValue>(ForceImportThunk));
984
+
985
+ const IRLinkage IRL =
986
+ llvm::Triple (Module.getTargetTriple ()).isOSBinFormatCOFF ()
987
+ ? IRLinkage::ExternalImport
988
+ : IRLinkage::ExternalWeakImport;
989
+ ApplyIRLinkage (IRL).to (cast<llvm::GlobalValue>(ForceImportThunk));
986
990
987
991
buf += " _$" ;
988
992
appendEncodedName (buf, IRGen.Opts .ModuleName );
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ const IRLinkage IRLinkage::ExternalImport = {
57
57
llvm::GlobalValue::DLLImportStorageClass,
58
58
};
59
59
60
+ const IRLinkage IRLinkage::ExternalWeakImport = {
61
+ llvm::GlobalValue::ExternalWeakLinkage,
62
+ llvm::GlobalValue::DefaultVisibility,
63
+ llvm::GlobalValue::DLLImportStorageClass,
64
+ };
65
+
60
66
const IRLinkage IRLinkage::ExternalExport = {
61
67
llvm::GlobalValue::ExternalLinkage,
62
68
llvm::GlobalValue::DefaultVisibility,
Original file line number Diff line number Diff line change 13
13
// RUN: %target-swift-frontend -emit-module -parse-stdlib -o %t -module-name someModule -module-link-name module %S/../Inputs/empty.swift -autolink-force-load
14
14
// RUN: %target-swift-frontend -emit-ir -lmagic %s -I %t > %t/force-load.txt
15
15
// RUN: %FileCheck %s < %t/force-load.txt
16
- // RUN: %FileCheck -check-prefix= FORCE-LOAD-CLIENT %s < %t/force-load.txt
16
+ // RUN: %FileCheck -check-prefix FORCE-LOAD-CLIENT -check-prefix FORCE-LOAD-CLIENT-%target-object-format %s < %t/force-load.txt
17
17
18
18
// RUN: %target-swift-frontend -emit-ir -parse-stdlib -module-name someModule -module-link-name module %S/../Inputs/empty.swift | %FileCheck --check-prefix=NO-FORCE-LOAD %s
19
19
// RUN: %target-swift-frontend -emit-ir -parse-stdlib -module-name someModule -module-link-name module %S/../Inputs/empty.swift -autolink-force-load | %FileCheck --check-prefix=FORCE-LOAD %s
@@ -49,5 +49,6 @@ import someModule
49
49
// FORCE-LOAD-CLIENT: @llvm.used = appending global [{{[0-9]+}} x i8*] [
50
50
// FORCE-LOAD-CLIENT: i8* bitcast (void ()** @"_swift_FORCE_LOAD_$_module_$_autolinking" to i8*)
51
51
// FORCE-LOAD-CLIENT: ], section "llvm.metadata"
52
- // FORCE-LOAD-CLIENT: declare {{(dllimport )?}}void @"_swift_FORCE_LOAD_$_module"()
52
+ // FORCE-LOAD-CLIENT-MACHO: declare extern_weak {{(dllimport )?}}void @"_swift_FORCE_LOAD_$_module"()
53
+ // FORCE-LOAD-CLIENT-COFF: declare extern {{(dllimport )?}}void @"_swift_FORCE_LOAD_$_module"()
53
54
You can’t perform that action at this time.
0 commit comments