[llvm] 6ad1db6 - [cmake] Forward MacOS sysroot to runtimes when not crosscompiling (#182501)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 7 08:22:24 PDT 2026


Author: Tom Eccles
Date: 2026-05-07T15:22:18Z
New Revision: 6ad1db6ff7fc1bd7ce7b88e0df38c0fd9fbbdeea

URL: https://github.com/llvm/llvm-project/commit/6ad1db6ff7fc1bd7ce7b88e0df38c0fd9fbbdeea
DIFF: https://github.com/llvm/llvm-project/commit/6ad1db6ff7fc1bd7ce7b88e0df38c0fd9fbbdeea.diff

LOG: [cmake] Forward MacOS sysroot to runtimes when not crosscompiling (#182501)

The LLVM build documentation says that setting CMAKE_OSX_SYSROOT should
be sufficient to correctly configure the sysroot, however this flag was
not forwarded to the build of runtimes: leading to failures in flang-rt
tests. https://llvm.org/docs/CMake.html#apple-osx

It is not safe to forward this flag in general because the runtime might
be cross-compiled. In this case I have tried to do this only for native
builds. My intention here is not to make the build more complex than
currently documented.

Added: 
    

Modified: 
    llvm/runtimes/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 7d0ee620dcffa..74c4940a1534c 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -4,6 +4,10 @@
 # the two files.
 
 set(COMMON_CMAKE_ARGS "-DHAVE_LLVM_LIT=ON;-DCLANG_RESOURCE_DIR=${CLANG_RESOURCE_DIR}")
+if(APPLE AND CMAKE_OSX_SYSROOT AND (LLVM_TARGET_TRIPLE STREQUAL LLVM_HOST_TRIPLE))
+  # Only propagate the host sysroot for native runtimes builds.
+  list(APPEND RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}")
+endif()
 foreach(proj ${LLVM_ENABLE_RUNTIMES})
   string(TOUPPER "${proj}" canon_name)
   STRING(REGEX REPLACE "-" "_" canon_name ${canon_name})


        


More information about the llvm-commits mailing list