Files
swift-mirror/cmake/modules/ClangClCompileRules.cmake
Saleem Abdulrasool 4a557df091 build: avoid incremental links with link.exe
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.
2018-02-12 09:53:21 -08:00

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()