mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
Skip ROCm's private LLVM when configuring Iridium
find_package(LLVM CONFIG) also searches <prefix>/llvm/lib/cmake/llvm for every PATH entry, before the system prefixes. With /opt/rocm/bin on PATH it found ROCm's LLVM 22.0.0git, whose llvm-config reports no shared library, and 6d6159b's fallback to the llvm-config on PATH then rejected the system LLVM 23 because its major differs from the ROCm headers, so a fresh configure failed (issue #1). Before find_package, keep LLVM_DIR only if the llvm-config next to it reports a shared library; otherwise, or when LLVM_DIR is unset, use the llvm-config on PATH that does and take its --cmakedir. A working pinned LLVM_DIR is left alone. Checked with a fake ROCm prefix on PATH: plain find_package picks it; the new code picks /usr/lib/cmake/llvm (LLVM 23) on a fresh configure, replaces a cached ROCm LLVM_DIR, and keeps a working cached /usr/lib64/cmake/llvm. A standalone configure of Indium with the fake ROCm on PATH completes with the system LLVM. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
1c30c99e51
commit
e1c8107b59
1 file changed
+47
-3
@@ -8629,10 +8629,53 @@ new file mode 100644
|
||||
+ }
|
||||
+}
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 8d95863..603dc3d 100644
|
||||
index 8d95863..1af3167 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -159,9 +159,33 @@ if (NOT DARLING)
|
||||
@@ -2,6 +2,41 @@ project(indium)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
find_package(Vulkan REQUIRED)
|
||||
+
|
||||
+# Iridium compiles against these LLVM headers and loads the shared libLLVM of the same major at run time, so the LLVM
|
||||
+# found here needs an llvm-config that reports a shared library. find_package also looks in <prefix>/llvm/lib/cmake/llvm
|
||||
+# for every PATH entry, so with /opt/rocm/bin on PATH it picks ROCm's private LLVM ahead of the system one, and a cached
|
||||
+# LLVM_DIR can name an LLVM that was removed since. Unless LLVM_DIR names a usable LLVM, use the llvm-config on PATH.
|
||||
+function(indium_llvm_config_works tool result)
|
||||
+ set(${result} FALSE PARENT_SCOPE)
|
||||
+ execute_process(COMMAND "${tool}" --link-shared --libnames
|
||||
+ OUTPUT_VARIABLE libname RESULT_VARIABLE status ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
+ if (status EQUAL 0 AND libname)
|
||||
+ set(${result} TRUE PARENT_SCOPE)
|
||||
+ endif()
|
||||
+endfunction()
|
||||
+
|
||||
+set(indium_llvm_usable FALSE)
|
||||
+if (LLVM_DIR)
|
||||
+ # <prefix>/lib/cmake/llvm or <prefix>/lib64/cmake/llvm
|
||||
+ get_filename_component(indium_llvm_prefix "${LLVM_DIR}/../../.." ABSOLUTE)
|
||||
+ indium_llvm_config_works("${indium_llvm_prefix}/bin/llvm-config" indium_llvm_usable)
|
||||
+endif()
|
||||
+if (NOT indium_llvm_usable)
|
||||
+ find_program(INDIUM_PATH_LLVM_CONFIG llvm-config)
|
||||
+ if (INDIUM_PATH_LLVM_CONFIG)
|
||||
+ indium_llvm_config_works("${INDIUM_PATH_LLVM_CONFIG}" indium_path_llvm_usable)
|
||||
+ execute_process(COMMAND "${INDIUM_PATH_LLVM_CONFIG}" --cmakedir
|
||||
+ OUTPUT_VARIABLE indium_path_llvm_dir RESULT_VARIABLE indium_status ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
+ if (indium_path_llvm_usable AND indium_status EQUAL 0 AND EXISTS "${indium_path_llvm_dir}")
|
||||
+ if (LLVM_DIR)
|
||||
+ message(STATUS "LLVM_DIR=${LLVM_DIR} has no llvm-config with a shared library; using ${indium_path_llvm_dir}")
|
||||
+ endif()
|
||||
+ set(LLVM_DIR "${indium_path_llvm_dir}" CACHE PATH "The directory containing a CMake configuration file for LLVM." FORCE)
|
||||
+ endif()
|
||||
+ endif()
|
||||
+endif()
|
||||
+
|
||||
find_package(LLVM REQUIRED CONFIG)
|
||||
|
||||
if (DARLING)
|
||||
@@ -158,11 +193,35 @@ if (NOT DARLING)
|
||||
)
|
||||
endif()
|
||||
|
||||
-execute_process(
|
||||
@@ -8667,10 +8710,11 @@ index 8d95863..603dc3d 100644
|
||||
+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.")
|
||||
+ "Install an LLVM with a shared libLLVM, or pass -DLLVM_DIR=<its lib/cmake/llvm directory>.")
|
||||
+endif()
|
||||
|
||||
target_compile_definitions(iridium PRIVATE
|
||||
"HOST_LLVM_LIBNAME=\"${HOST_LLVM_LIBNAME}\""
|
||||
diff --git a/src/iridium/dynamic-llvm.cpp b/src/iridium/dynamic-llvm.cpp
|
||||
index 1b5876e..03af560 100644
|
||||
--- a/src/iridium/dynamic-llvm.cpp
|
||||
|
||||
Reference in new issue
Block a user