[llvm] [cmake] Forward MacOS sysroot to runtimes when not crosscompiling (PR #182501)
Tom Eccles via llvm-commits
llvm-commits at lists.llvm.org
Thu May 7 07:52:12 PDT 2026
https://github.com/tblah updated https://github.com/llvm/llvm-project/pull/182501
>From 4253b70470ea9f765c255e72e00bc8dc2e0b6955 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 1/3] [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 7d0ee620dcffa..94eb9df28a8e9 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})
string(TOUPPER "${proj}" canon_name)
STRING(REGEX REPLACE "-" "_" canon_name ${canon_name})
@@ -298,6 +303,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
>From eecf1093c29471b858252d955db72c533a9ac2e9 Mon Sep 17 00:00:00 2001
From: Tom Eccles <tom.eccles at arm.com>
Date: Fri, 20 Feb 2026 16:33:26 +0000
Subject: [PATCH 2/3] Fix variable setting
---
llvm/runtimes/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 94eb9df28a8e9..bac1f0a03728b 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -4,7 +4,7 @@
# the two files.
set(COMMON_CMAKE_ARGS "-DHAVE_LLVM_LIT=ON;-DCLANG_RESOURCE_DIR=${CLANG_RESOURCE_DIR}")
-set(NATIVE_RUNTIMES_CMAKE_ARGS)
+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}")
>From f2cb7524f3439e8373ef9d6feffd01e20b975749 Mon Sep 17 00:00:00 2001
From: Tom Eccles <tom.eccles at arm.com>
Date: Thu, 23 Apr 2026 15:56:03 +0100
Subject: [PATCH 3/3] Use RUNTIMES_CMAKE_ARGS
---
llvm/runtimes/CMakeLists.txt | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index bac1f0a03728b..74c4940a1534c 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -4,10 +4,9 @@
# 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}")
+ list(APPEND RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}")
endif()
foreach(proj ${LLVM_ENABLE_RUNTIMES})
string(TOUPPER "${proj}" canon_name)
@@ -303,7 +302,6 @@ 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