Files
swift-mirror/test/IRGen/autolink-coff-c-pragma.swift
Martin Boehme 6bf0f26ecd Emit /DEFAULTLIB directive for #pragma comment(lib, ...) in a C module.
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.
2020-05-20 15:28:12 +02:00

21 lines
1.0 KiB
Swift

// 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"