Skip to content

Commit 7837db4

Browse files
committed
IRGen: dont use autolink-extract for COFF targets
COFF supports the `.drectve` section for embedding linker directives. LLVM has long supported emitting this section. With this move, ELF shall become the only target needing the autolink-extract functionality.
1 parent 89bebf8 commit 7837db4

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/IRGen/IRGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ void IRGenModule::emitAutolinkInfo() {
879879
switch (TargetInfo.OutputObjectFormat) {
880880
case llvm::Triple::UnknownObjectFormat:
881881
llvm_unreachable("unknown object format");
882+
case llvm::Triple::COFF:
882883
case llvm::Triple::MachO: {
883884
llvm::LLVMContext &ctx = Module.getContext();
884885

@@ -897,7 +898,6 @@ void IRGenModule::emitAutolinkInfo() {
897898
}
898899
break;
899900
}
900-
case llvm::Triple::COFF:
901901
case llvm::Triple::ELF: {
902902
// Merge the entries into null-separated string.
903903
llvm::SmallString<64> EntriesString;

test/IRGen/autolink-coff.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: %swift -target thumbv7--windows-gnu -parse-as-library -parse-stdlib -emit-module-path %t/module.swiftmodule -module-name module -module-link-name module %s
4+
// RUN: %swift -target thumbv7--windows-gnu -parse-as-library -parse-stdlib -module-name autolink -I %t -D MAIN_MODULE -emit-ir -o - %s | FileCheck %s -check-prefix CHECK-GNU-IR
5+
// RUN: %swift -target thumbv7--windows-gnu -parse-as-library -parse-stdlib -module-name autolink -I %t -D MAIN_MODULE -S -o - %s | FileCheck %s -check-prefix CHECK-GNU-ASM
6+
7+
#if MAIN_MODULE
8+
import module
9+
#endif
10+
11+
// CHECK-GNU-IR: !{{[0-9]+}} = !{i32 {{[0-9]+}}, !"Linker Options", [[NODE:![0-9]+]]}
12+
// CHECK-GNU-IR: [[NODE]] = !{[[LIST:![0-9]+]]}
13+
// CHECK-GNU-IR: [[LIST]] = !{!"-lmodule"}
14+
15+
// CHECK-GNU-ASM: .section .drectve
16+
// CHECK-GNU-ASM: .ascii " -lmodule"
17+

0 commit comments

Comments
 (0)