Skip to content

Commit 0a1abdc

Browse files
committed
build: attempt to repair Windows debug builds
The debug build of the standard library on Windows does not generate the import library for SwiftOnoneSupport which prevents the build of debug programs against the debug runtime. Because the linker must find the import library in order to satisfy the forced link that we emit for the link against the SwiftOnoneSupport library, without this, the build is not usable. Furthermore, this requires a debug build of the runtime since in the optimized build, the interfaces that this library provides are not provided by swiftCore and this supplements the library to allow building the debug program.
1 parent 4ee879e commit 0a1abdc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

stdlib/public/SwiftOnoneSupport/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,19 @@ add_swift_target_library(swiftSwiftOnoneSupport ${SWIFT_STDLIB_LIBRARY_BUILD_TYP
99
SWIFT_COMPILE_FLAGS "-parse-stdlib" "-Xllvm" "-sil-inline-generics=false" "-Xfrontend" "-validate-tbd-against-ir=none" "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
1010
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
1111
INSTALL_IN_COMPONENT stdlib)
12+
if(CMAKE_BUILD_TYPE STREQUAL Debug AND WINDOWS IN_LIST SWIFT_SDKS)
13+
# When building in Debug mode, the standard library provides the symbols that
14+
# we need and as such SwiftOnoneSupport does not need to provide any exported
15+
# interfaces. This results in the import library beinging elided. However,
16+
# we explicitly link against the SwiftOnoneSupport library when building
17+
# programs in Debug mode, and need the import library to be generated even if
18+
# nothing is exported. Because we will still generate the DLL, create an
19+
# empty import library.
20+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/SwiftOnoneSupport.def
21+
"LIBRARY SwiftOnoneSupport\n"
22+
"EXPORTS")
23+
foreach(architecture ${SWIFT_SDK_WINDOWS_ARCHITECTURES})
24+
target_sources(swiftSwiftOnoneSupport-windows-${architecture} PRIVATE
25+
${CMAKE_CURRENT_BINARY_DIR}/SwiftOnoneSupport.def)
26+
endforeach()
27+
endif()

0 commit comments

Comments
 (0)