diff --git a/patches/metal--deps--indium.patch b/patches/metal--deps--indium.patch index 45fd9b6..7d92c48 100644 --- a/patches/metal--deps--indium.patch +++ b/patches/metal--deps--indium.patch @@ -8462,16 +8462,43 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d95863..603dc3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -159,9 +159,10 @@ if (NOT DARLING) +@@ -159,9 +159,33 @@ if (NOT DARLING) endif() - execute_process( +-execute_process( - COMMAND llvm-config --link-shared --libnames -+ COMMAND "${LLVM_TOOLS_BINARY_DIR}/llvm-config" --link-shared --libnames - OUTPUT_VARIABLE HOST_LLVM_LIBNAME - OUTPUT_STRIP_TRAILING_WHITESPACE -+ COMMAND_ERROR_IS_FATAL ANY - ) +- OUTPUT_VARIABLE HOST_LLVM_LIBNAME +- OUTPUT_STRIP_TRAILING_WHITESPACE +-) ++# Use an llvm-config of the same major as the headers found above. A stale cached LLVM_DIR can point at ++# a removed LLVM whose llvm-config exists but whose library is gone, so fall back to the one on PATH. ++set(HOST_LLVM_LIBNAME "") ++foreach(candidate IN ITEMS "${LLVM_TOOLS_BINARY_DIR}/llvm-config" llvm-config) ++ execute_process( ++ COMMAND "${candidate}" --version ++ OUTPUT_VARIABLE candidate_version ++ RESULT_VARIABLE candidate_status ++ ERROR_QUIET ++ OUTPUT_STRIP_TRAILING_WHITESPACE ++ ) ++ if (candidate_status EQUAL 0 AND candidate_version MATCHES "^${LLVM_VERSION_MAJOR}\\.") ++ execute_process( ++ COMMAND "${candidate}" --link-shared --libnames ++ OUTPUT_VARIABLE HOST_LLVM_LIBNAME ++ RESULT_VARIABLE candidate_status ++ ERROR_QUIET ++ OUTPUT_STRIP_TRAILING_WHITESPACE ++ ) ++ if (candidate_status EQUAL 0 AND HOST_LLVM_LIBNAME) ++ break() ++ endif() ++ set(HOST_LLVM_LIBNAME "") ++ endif() ++endforeach() ++if (NOT HOST_LLVM_LIBNAME) ++ message(FATAL_ERROR "No working llvm-config for LLVM ${LLVM_VERSION} (LLVM_DIR=${LLVM_DIR}). " ++ "Remove LLVM_DIR from the CMake cache or install the matching LLVM.") ++endif() target_compile_definitions(iridium PRIVATE diff --git a/src/iridium/dynamic-llvm.cpp b/src/iridium/dynamic-llvm.cpp