mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
Fall back to a matching llvm-config when the cached LLVM_DIR is stale
A leftover LLVM_DIR can point at a removed LLVM whose llvm-config exists but whose library is gone, which made configure fail on LLVM 23 hosts. Try the tools-dir llvm-config, then the one on PATH, and accept only one that matches the header major and reports a shared library. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
5a5a8c4022
commit
6d6159b594
1 file changed
+34
-7
@@ -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
|
||||
|
||||
Reference in new issue
Block a user