mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This is a workaround for Visual Studio's link causing corruption with incremental linking. The markers for the metadata are padded out incorrectly, resulting in load time failures. With this, it is possible to link with link and use the generated binaries on Windows x86_64.
18 lines
991 B
CMake
18 lines
991 B
CMake
|
|
# clang-cl interprets paths starting with /U as macro undefines, so we need to
|
|
# put a -- before the input file path to force it to be treated as a path.
|
|
string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
|
|
string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}")
|
|
|
|
# NOTE(compnerd) incremental linking is known to cause corruption in the
|
|
# protocol conformance tables. Avoid using incremental links with Visual
|
|
# Studio.
|
|
foreach(TYPE EXE SHARED MODULE)
|
|
foreach(BUILD DEBUG RELWITHDEBINFO)
|
|
string(REPLACE "/INCREMENTAL:YES" "" CMAKE_${TYPE}_LINKER_FLAGS_${BUILD} "${CMAKE_${TYPE}_LINKER_FLAGS_${BUILD}}")
|
|
string(REPLACE "/INCREMENTAL" "" CMAKE_${TYPE}_LINKER_FLAGS_${BUILD} "${CMAKE_${TYPE}_LINKER_FLAGS_${BUILD}}")
|
|
set(CMAKE_${TYPE}_LINKER_FLAGS_${BUILD} ${CMAKE_${TYPE}_LINKER_FLAGS_${BUILD}} CACHE STRING "Flags used by the linker during builds." FORCE)
|
|
endforeach()
|
|
endforeach()
|
|
|