Skip to content

Commit 6b78e94

Browse files
authored
[libc][CMake] Fix build issues of libc on Windows (#102499)
Due to an issue mentioned in `llvm/projects/CMakeLists.txt`, libc build is disabled by default when building with `clang-cl` on Windows. This PR sets `LLVM_FORCE_BUILD_RUNTIME` to `ON` to bypass this limit for libc and make libc build with `clang-cl` on Windows.
1 parent 876ee11 commit 6b78e94

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/cmake/modules/CrossCompile.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
7171

7272
if("libc" IN_LIST LLVM_ENABLE_PROJECTS AND NOT LIBC_HDRGEN_EXE)
7373
set(libc_flags -DLLVM_LIBC_FULL_BUILD=ON -DLIBC_HDRGEN_ONLY=ON)
74+
if(MSVC)
75+
# Due to some issues mentioned in llvm/projects/CMakeLists.txt, libc build is disabled by
76+
# default in the cross target when building with MSVC compatible compilers on Windows. Add
77+
# LLVM_FORCE_BUILD_RUNTIME to bypass this issue and force its building on Windows.
78+
list(APPEND libc_flags -DLLVM_FORCE_BUILD_RUNTIME=ON)
79+
endif()
7480
endif()
7581

7682
add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt

0 commit comments

Comments
 (0)