[llvm] [cmake] Forward MacOS sysroot to runtimes when not crosscompiling (PR #182501)
Tom Eccles via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 20 06:11:54 PST 2026
https://github.com/tblah created https://github.com/llvm/llvm-project/pull/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.
>From cf9edd19ce5a2e5647cca224a7e04eccf54cbb79 Mon Sep 17 00:00:00 2001
From: Tom Eccles <tom.eccles at arm.com>
Date: Thu, 19 Feb 2026 13:58:25 +0000
Subject: [PATCH] [cmake] Forward MacOS sysroot to runtimes when not
crosscompiling
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.
---
llvm/runtimes/CMakeLists.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index f0ef353a2c66c..16168881ea819 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -4,6 +4,11 @@
# the two files.
set(COMMON_CMAKE_ARGS "-DHAVE_LLVM_LIT=ON;-DCLANG_RESOURCE_DIR=${CLANG_RESOURCE_DIR}")
+set(NATIVE_RUNTIMES_CMAKE_ARGS)
+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 NATIVE_RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}")
+endif()
foreach(proj ${LLVM_ENABLE_RUNTIMES})
set(proj_dir "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
if(IS_DIRECTORY ${proj_dir} AND EXISTS ${proj_dir}/CMakeLists.txt)
@@ -295,6 +300,7 @@ function(runtime_default_target)
-DCMAKE_Fortran_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
${COMMON_CMAKE_ARGS}
+ ${NATIVE_RUNTIMES_CMAKE_ARGS}
${RUNTIMES_CMAKE_ARGS}
${ARG_CMAKE_ARGS}
PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
More information about the llvm-commits
mailing list