Swift: Enable SwiftMixLib Test on Windows

The SwiftMixLib test was failing on Windows due to a missing link
against swiftCore. On macOS and Linux, there are mechanisms for
extracting the libraries that the object depends on and passing that to
the linker so that the library dependencies don't need to be listed
explicitly. The Windows Swift toolchain does not have this mechanism.

In the future, it would likely make sense for CMake to pass some of the
implicitly required libraries for linking Swift via
`CMAKE_Swift_IMPLICIT_LINK_LIBRARIES`. Unlike the normal mechanisms
though, these libraries would need to be passed even when the link
language is Swift.

For now though, we should get the test up and running again.

Fixes: #25573
This commit is contained in:
Evan Wilde 2024-08-16 15:48:58 -07:00
parent 48c0b01197
commit 0b0c70d1bf
No known key found for this signature in database
2 changed files with 12 additions and 7 deletions

View File

@ -34,13 +34,6 @@ if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "nvhpc_")
)
endif()
if ("$ENV{CMAKE_CONFIGURATION}" STREQUAL "windows_vs2022_x64_ninja")
list(APPEND test_exclusions
# FIXME(#25573): This test failure needs further investigation.
"^SwiftMixLib$"
)
endif()
string(REPLACE ";" "|" test_exclusions "${test_exclusions}")
if (test_exclusions)
set(test_exclusions "(${test_exclusions})")

View File

@ -10,3 +10,15 @@ target_link_libraries(Swifty PUBLIC SwiftMixedLib)
add_executable(c_main main.c)
target_link_libraries(c_main PUBLIC SwiftMixedLib)
if(WIN32)
# TODO: On macOS and Linux, Swift has mechanism for determining what libraries
# an object, or objects from a static archive, need to link against,
# which is how the Swift driver is able to determine that `c_main`
# needs to link swiftCore. Windows does not have this mechanism.
# Eventually CMake should learn how to do this, explicitly forwarding
# the required library to the link command when linking a static
# archive containing Swift sources into something else, even if the
# linker language is Swift.
target_link_libraries(c_main PRIVATE swiftCore)
endif()