Skip to content

Commit dbb4f90

Browse files
authored
[compiler-rt] Don't link builtins against the CRT on Windows (#70675)
compiler-rt/builtins doesn't depend on anything from the CRT but currently links against it and embeds a `/defaultlib:msvcrt` in the `.lib` file, forcing anyone linking against it to also link against that specific CRT. This isn't necessary as the end user can just choose which CRT they want to use independently.
1 parent 1d090b8 commit dbb4f90

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

compiler-rt/cmake/builtin-config-ix.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ builtin_check_c_compiler_flag(-fno-profile-generate COMPILER_RT_HAS_FNO_PROFILE_
1818
builtin_check_c_compiler_flag(-fno-profile-instr-generate COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG)
1919
builtin_check_c_compiler_flag(-fno-profile-instr-use COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG)
2020
builtin_check_c_compiler_flag(-Wno-pedantic COMPILER_RT_HAS_WNO_PEDANTIC)
21+
builtin_check_c_compiler_flag(/Zl COMPILER_RT_HAS_ZL_FLAG)
2122

2223
builtin_check_c_compiler_source(COMPILER_RT_HAS_ATOMIC_KEYWORD
2324
"

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,12 @@ else ()
761761

762762
append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS)
763763

764+
# Don't embed directives for picking any specific CRT
765+
if (MSVC)
766+
set(CMAKE_MSVC_RUNTIME_LIBRARY "")
767+
append_list_if(COMPILER_RT_HAS_ZL_FLAG /Zl BUILTIN_CFLAGS)
768+
endif()
769+
764770
# These flags would normally be added to CMAKE_C_FLAGS by the llvm
765771
# cmake step. Add them manually if this is a standalone build.
766772
if(COMPILER_RT_STANDALONE_BUILD)

0 commit comments

Comments
 (0)