[llvm] [cmake] Pass cached library variables only if target matches host (PR #227660)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 05:22:09 PDT 2026


================
@@ -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}")
----------------
jhuber6 wrote:

Do we need the check to be this strict? E.g. `x86_64-unknown-linux-gnu` vs `x86_64-pc-linux-gnu` will fail as written.

https://github.com/llvm/llvm-project/pull/227660


More information about the llvm-commits mailing list