Skip to content

Commit 4c43893

Browse files
authored
Merge pull request #3513 from compnerd/export-force-load
IRGen: give the force load symbol export DLL storage
2 parents f2b12aa + eeebf0c commit 4c43893

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

lib/IRGen/IRGenModule.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,13 @@ void IRGenModule::emitAutolinkInfo() {
975975
if (!IRGen.Opts.ForceLoadSymbolName.empty()) {
976976
llvm::SmallString<64> buf;
977977
encodeForceLoadSymbolName(buf, IRGen.Opts.ForceLoadSymbolName);
978-
(void)new llvm::GlobalVariable(Module, Int1Ty, /*constant=*/false,
979-
llvm::GlobalValue::CommonLinkage,
980-
llvm::Constant::getNullValue(Int1Ty),
981-
buf.str());
978+
auto symbol =
979+
new llvm::GlobalVariable(Module, Int1Ty, /*constant=*/false,
980+
llvm::GlobalValue::CommonLinkage,
981+
llvm::Constant::getNullValue(Int1Ty),
982+
buf.str());
983+
if (Triple.isOSBinFormatCOFF())
984+
symbol->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
982985
}
983986
}
984987

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
4+
// RUN: %swift -target i686--windows-msvc -parse-as-library -parse-stdlib -module-name autolink -module-link-name autolink -autolink-force-load -emit-ir -o - %s | FileCheck %s
5+
// RUN: %swift -target i686--windows-itanium -parse-as-library -parse-stdlib -module-name autolink -module-link-name autolink -autolink-force-load -S -o - %s | FileCheck %s -check-prefix CHECK-ASM-GNU
6+
// RUN: %swift -target i686--windows-msvc -parse-as-library -parse-stdlib -module-name autolink -module-link-name autolink -autolink-force-load -S -o - %s | FileCheck %s -check-prefix CHECK-ASM-MSC
7+
8+
// CHECK: @"_swift_FORCE_LOAD_$_autolink" = common dllexport global i1 false
9+
// CHECK-ASM-GNU: .ascii " -export:__swift_FORCE_LOAD_$_autolink,data"
10+
// CHECK-ASM-MSC: .ascii " /EXPORT:__swift_FORCE_LOAD_$_autolink,DATA"
11+

0 commit comments

Comments
 (0)