[llvm] [cmake] Pass cached library variables only if target matches host (PR #227660)
Raul Tambre via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 04:19:07 PDT 2026
https://github.com/tambry created https://github.com/llvm/llvm-project/pull/227660
If we're building runtimes for say an embedded none triple then LLVMConfig.cmake finding Zst will fail as it will try to create a SHARED target, which isn't possible for baremetal targets.
This came up as due to same changes I switched my runtime builds to define CMAKE_SYSTEM_NAME=Generic. But that brings up the aforementioned shared library target issue.
This coincidentally somewhat relates to [an ongoing RFC](https://discourse.llvm.org/t/rfc-fixing-cmake-system-name-in-cross-compiled-runtimes-builds/91897).
>From 0358c75105e286e2aa996eaa4a0bfd9944695190 Mon Sep 17 00:00:00 2001
From: Raul Tambre <raul at tambre.ee>
Date: Wed, 30 Sep 2026 13:55:46 +0300
Subject: [PATCH] [cmake] Pass cached library variables only if target matches
host
If we're building runtimes for say an embedded none triple then LLVMConfig.cmake finding Zst will
fail as it will try to create a SHARED target, which isn't possible for baremetal targets.
This came up as due to same changes I switched my runtime builds to define CMAKE_SYSTEM_NAME=Generic.
But that brings up the aforementioned shared library target issue.
This coincidentally somewhat relates to an ongoing RFC:
https://discourse.llvm.org/t/rfc-fixing-cmake-system-name-in-cross-compiled-runtimes-builds/91897
---
.../modules/LLVMExternalProjectUtils.cmake | 45 ++++++++++---------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index 32e25567ef57e..e1ac51ed8a40f 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -174,26 +174,31 @@ function(llvm_ExternalProject_Add name source_dir)
set_target_properties(${name}-clear PROPERTIES FOLDER "${ARG_FOLDER}")
endif ()
- set(DEFAULT_PASSTHROUGH_VARIABLES
- LibEdit_INCLUDE_DIRS
- LibEdit_LIBRARIES
- ZLIB_INCLUDE_DIR
- ZLIB_LIBRARY
- ZLIB_LIBRARY_RELEASE
- ZLIB_LIBRARY_DEBUG
- zstd_INCLUDE_DIR
- zstd_LIBRARY
- LIBXML2_LIBRARY
- LIBXML2_INCLUDE_DIR
- CURL_INCLUDE_DIR
- CURL_LIBRARY
- HTTPLIB_INCLUDE_DIR
- HTTPLIB_HEADER_PATH
- Python3_EXECUTABLE
- Python3_LIBRARIES
- Python3_INCLUDE_DIRS
- Python3_RPATH
- )
+ # Add only if the target matches.
+ # Otherwise LLVMConfig.cmake dependency finding will short-circuit to incompatible host system libraries.
+ if("${ARG_TARGET_TRIPLE}" STREQUAL "${LLVM_TARGET_TRIPLE}")
+ set(DEFAULT_PASSTHROUGH_VARIABLES
+ LibEdit_INCLUDE_DIRS
+ LibEdit_LIBRARIES
+ ZLIB_INCLUDE_DIR
+ ZLIB_LIBRARY
+ ZLIB_LIBRARY_RELEASE
+ ZLIB_LIBRARY_DEBUG
+ zstd_INCLUDE_DIR
+ zstd_LIBRARY
+ LIBXML2_LIBRARY
+ LIBXML2_INCLUDE_DIR
+ CURL_INCLUDE_DIR
+ CURL_LIBRARY
+ HTTPLIB_INCLUDE_DIR
+ HTTPLIB_HEADER_PATH
+ Python3_EXECUTABLE
+ Python3_LIBRARIES
+ Python3_INCLUDE_DIRS
+ Python3_RPATH
+ )
+ endif()
+
foreach(variable ${DEFAULT_PASSTHROUGH_VARIABLES})
get_property(is_value_set CACHE ${variable} PROPERTY VALUE SET)
if(${is_value_set})
More information about the llvm-commits
mailing list