Skip to content

Commit 22fde69

Browse files
committed
cmake: make swiftRemoteMirror export interfaces on Windows
Unfortunately, `swift-reflection-test` links against the *TARGET* library `swiftRemoteMirror`. The linked library is built as a target library, which means that we use the custom library target construction which suffixes the target with a variant spelling. Because the number of variants is really high, we pass along the explicit EXPORTS macro manually. However, we also build the library as a static library for the *HOST*. This means that we need the sources to be aware of whether they are built statically or dyanmically. This is accomplished by means of the `_WINDLL` macro. The target library is shared and is built using the custom wrapper for the library construction, which will create all the variants and then use `_compute_variant_c_flags` which does not get told what type of library is being built, so it assumes static and does not append `_WINDLL`. This results in the shared library not exposing any interfaces on Windows. When this happens, link will helpfully elide the import library. The result of that is that the swift-reflection-test binary will fail to link due to no import library for the RemoteMirror. Explicitly add the -D_WINDLL if appropriate manually after we have computed the C flags. *siiiiiiigh*
1 parent 1a949ea commit 22fde69

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,11 @@ function(_add_swift_library_single target name)
11951195
"${SWIFTLIB_SINGLE_FORCE_BUILD_OPTIMIZED_keyword}"
11961196
RESULT_VAR_NAME c_compile_flags
11971197
)
1198+
if(SWIFTLIB_SINGLE_SDK STREQUAL WINDOWS)
1199+
if(libkind STREQUAL SHARED)
1200+
list(APPEND c_compile_flags -D_WINDLL)
1201+
endif()
1202+
endif()
11981203
_add_variant_link_flags(
11991204
SDK "${SWIFTLIB_SINGLE_SDK}"
12001205
ARCH "${SWIFTLIB_SINGLE_ARCHITECTURE}"

0 commit comments

Comments
 (0)