Skip to content

Commit 6d2ea53

Browse files
committed
build: workaround cross-compilation for Windows
When cross-compiling the Windows standard library in release mode, we would get undefined symbols due to LLVM invoking `add_definitions(-D_DEBUG)`. This would change the behaviour of certain functions from MSVCRT resulting in undefined symbols. Scrub out the unwanted `-D_DEBUG`.
1 parent 30d1568 commit 6d2ea53

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,13 @@ function(_add_variant_c_compile_flags)
273273
# RTTI as well. This requires a newer SDK though and we do not have
274274
# guarantees on the SDK version currently.
275275
list(APPEND result "-D_HAS_STATIC_RTTI=0")
276+
277+
# NOTE(compnerd) workaround LLVM invoking `add_definitions(-D_DEBUG)` which
278+
# causes failures for the runtime library when cross-compiling due to
279+
# undefined symbols from the standard library.
280+
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
281+
list(APPEND result "-U_DEBUG")
282+
endif()
276283
endif()
277284

278285
if(CFLAGS_ENABLE_ASSERTIONS)

0 commit comments

Comments
 (0)