forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit
/DEFAULTLIB
directive for #pragma comment(lib, ...)
in a C m…
…odule. This is important, for example, for linking correctly to the C++ standard library on Windows, which uses `#pragma comment(lib, ...)` in its headers to specify the correct library to link against.
- Loading branch information
1 parent
c230622
commit 6bf0f26
Showing
5 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#pragma comment(lib, "transitive-module") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "autolink-coff-c-pragma-transitive.h" | ||
|
||
#pragma comment(lib, "module") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module AutolinkCoffCPragma { | ||
header "autolink-coff-c-pragma.h" | ||
export * | ||
} | ||
|
||
module AutolinkCoffCPragmaTransitive { | ||
header "autolink-coff-c-pragma-transitive.h" | ||
export * | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Tests that a `#pragma comment(lib, ...)` in a C header imported as a module | ||
// causes a corresponding `/DEFAULTLIB` directive to be emitted. | ||
// | ||
// We test that this is true also for C headers included transitively from | ||
// another C header. | ||
|
||
// RUN: %swift -module-name Swift -target x86_64-unknown-windows-msvc -I %S/Inputs -emit-ir %s -parse-stdlib -parse-as-library -disable-legacy-type-info | %FileCheck %s -check-prefix=CHECK-MSVC-IR | ||
// RUN: %swift -module-name Swift -target x86_64-unknown-windows-msvc -I %S/Inputs -S %s -parse-stdlib -parse-as-library -disable-legacy-type-info | %FileCheck %s -check-prefix=CHECK-MSVC-ASM | ||
|
||
// REQUIRES: CODEGENERATOR=X86 | ||
|
||
import AutolinkCoffCPragma | ||
|
||
// CHECK-MSVC-IR: !llvm.linker.options = !{!{{[0-9]+}}, !{{[0-9]+}}} | ||
// CHECK-MSVC-IR-DAG: !{{[0-9]+}} = !{!"/DEFAULTLIB:module.lib"} | ||
// CHECK-MSVC-IR-DAG: !{{[0-9]+}} = !{!"/DEFAULTLIB:transitive-module.lib"} | ||
|
||
// CHECK-MSVC-ASM: .section .drectve | ||
// CHECK-MSVC-ASM-DAG: .ascii " /DEFAULTLIB:module.lib" | ||
// CHECK-MSVC-ASM-DAG: .ascii " /DEFAULTLIB:transitive-module.lib" |