[llvm] [libc] Fix build issues of libc on Windows (PR #102499)
    Sirui Mu via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Aug  8 09:09:12 PDT 2024
    
    
  
https://github.com/Lancern created https://github.com/llvm/llvm-project/pull/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.
>From afaf99a46803fd06403513a6334a63becf9f1fe6 Mon Sep 17 00:00:00 2001
From: Sirui Mu <msrlancern at gmail.com>
Date: Fri, 9 Aug 2024 00:06:45 +0800
Subject: [PATCH] [libc] Fix build issues of libc on Windows
Due to an issue mentioned in llvm/projects/CMakeLists.txt, libc build is
disabled by default when building with clang-cl on Windows. This patch sets
LLVM_FORCE_BUILD_RUNTIME to ON to bypass this limit for libc and make libc build
with clang-cl on Windows.
---
 llvm/cmake/modules/CrossCompile.cmake | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake
index 39b4abaa0d931..e36a71f522d82 100644
--- a/llvm/cmake/modules/CrossCompile.cmake
+++ b/llvm/cmake/modules/CrossCompile.cmake
@@ -71,6 +71,12 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
 
   if("libc" IN_LIST LLVM_ENABLE_PROJECTS AND NOT LIBC_HDRGEN_EXE)
     set(libc_flags -DLLVM_LIBC_FULL_BUILD=ON -DLIBC_HDRGEN_ONLY=ON)
+    if(MSVC)
+      # Due to some issues mentioned in llvm/projects/CMakeLists.txt, libc build is disabled by
+      # default in the cross target when building with MSVC compatible compilers on Windows. Add
+      # LLVM_FORCE_BUILD_RUNTIME to bypass this issue and force its building on Windows.
+      list(APPEND libc_flags -DLLVM_FORCE_BUILD_RUNTIME=ON)
+    endif()
   endif()
 
   add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt
    
    
More information about the llvm-commits
mailing list