Skip to content

Commit 72196c9

Browse files
committed
[cmake] Build Swift host libraries with -DCLANG_BUILD_STATIC on Windows
By default (`CLANG_BUILD_STATIC` and `CLANG_EXPORTS` not defined) some Clang visibility macros expand to `__declspec(dllimport)`. Swift depends on Clang statically, so needs to turn these macros off.
1 parent 23eb9d6 commit 72196c9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@ function(_add_host_variant_c_compile_flags target)
269269
target_compile_options(${target} PRIVATE
270270
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-U_DEBUG>)
271271
endif()
272+
273+
# Swift host libraries are always linked with Clang libraries statically,
274+
# so turn off Clang visibility macros for both the library and its
275+
# consumers.
276+
#target_compile_definitions(${target} PUBLIC
277+
# $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:CLANG_BUILD_STATIC>)
278+
#if(TARGET "obj.${target}")
279+
# target_compile_definitions("obj.${target}" PUBLIC
280+
# $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:CLANG_BUILD_STATIC>)
281+
#endif()
272282
endif()
273283
274284
if(SWIFT_HOST_VARIANT_SDK STREQUAL "ANDROID")

lib/APIDigester/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ add_swift_host_library(swiftAPIDigester STATIC
77
target_link_libraries(swiftAPIDigester PRIVATE
88
swiftIDE)
99

10+
target_link_libraries(swiftAPIDigester INTERFACE
11+
clangAST
12+
clangLex
13+
clangSema)
14+
1015
set_swift_llvm_is_available(swiftAPIDigester)

0 commit comments

Comments
 (0)