From 238b25032c0dc4672d589034d0f2071a58cb914f Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 15 Sep 2026 11:46:32 +0200 Subject: [PATCH 1/2] [interpreter] do not let builtin_clang search again for LLVM if builtin_llvm=OFF Alternative to https://github.com/root-project/root/pull/23160 that does not require any upstream or downstream patches In ROOT, for builtin_llvm=OFF we have the sequence ``` find_package(LLVM) # searchs for system package, which sets DYLIB to ON set(LLVM_LINK_LLVM_DYLIB OFF) # override DYLIB to OFF, we want static add_subdirectory(clang) # this will call find_package LLVM again ``` See https://github.com/root-project/root/pull/13420 Since LLVM22 though, this fails: Even if we call for a second time `set(LLVM_LINK_LLVM_DYLIB OFF)` after the `add_subdirectory` line, it's not enough, because that variable was ON all throughout the child `clang/CMakeLists.txt` and has already configured some stuff with the wrong flag. Avoid the issue by preventing the double-search of LLVM and thus the double overwrite, by temporarily overwriting the find_package(LLVM) calls. Fixes https://github.com/root-project/root/issues/18387 Fixes https://github.com/root-project/root/issues/23155 --- interpreter/CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index 77d5d7f01355d..7fa21284f4fb9 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -393,14 +393,26 @@ else() # Disable linking against shared LLVM set(LLVM_LINK_LLVM_DYLIB OFF) + # To ensure this override stays constant, we need to avoid subdirectories calling find_package(LLVM), + # which would set it to ON again if system was compiled that way + # Define a macro with a toggle flag to override find_package, that will only be visible in this scope, not in parent one. + macro(find_package _package_name) + if(SKIP_FIND_LLVM AND "${_package_name}" STREQUAL "LLVM") + message(STATUS "[ROOT] Prevented secondary find_package(LLVM) call to save overrides.") + else() + _find_package(${_package_name} ${ARGN}) + endif() + endmacro() # Always build LLVM with C++17. It is not necessary to compile with the same # C++ standard as the rest of ROOT and sometimes it doesn't even work. set(_cxx_standard ${CMAKE_CXX_STANDARD}) set(CMAKE_CXX_STANDARD 17) + set(SKIP_FIND_LLVM ON) add_subdirectory(llvm-project/clang EXCLUDE_FROM_ALL) - + set(SKIP_FIND_LLVM OFF) + set(CMAKE_CXX_STANDARD ${_cxx_standard}) endif(builtin_clang) From 80875d868fe08fa1d858cd0948d523b27f805e8f Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Wed, 16 Sep 2026 08:33:04 +0200 Subject: [PATCH 2/2] [cmake] better variable name and commenting to clarify that this is a temporary workaround Co-authored-by: Jonas Rembser --- interpreter/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index 7fa21284f4fb9..ed7242cf3f527 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -396,9 +396,12 @@ else() # To ensure this override stays constant, we need to avoid subdirectories calling find_package(LLVM), # which would set it to ON again if system was compiled that way # Define a macro with a toggle flag to override find_package, that will only be visible in this scope, not in parent one. + # TEMPORARY: remove this workaround once ROOT can link against the shared + # libLLVM.so for builtin_llvm=OFF macro(find_package _package_name) - if(SKIP_FIND_LLVM AND "${_package_name}" STREQUAL "LLVM") - message(STATUS "[ROOT] Prevented secondary find_package(LLVM) call to save overrides.") + if(ROOT_SKIP_FIND_LLVM_WITHIN_CLANG AND "${_package_name}" STREQUAL "LLVM") + message(STATUS "[ROOT] Suppressed find_package(LLVM) at ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}" + " to keep LLVM_LINK_LLVM_DYLIB=OFF.") else() _find_package(${_package_name} ${ARGN}) endif() @@ -409,9 +412,9 @@ else() set(_cxx_standard ${CMAKE_CXX_STANDARD}) set(CMAKE_CXX_STANDARD 17) - set(SKIP_FIND_LLVM ON) + set(ROOT_SKIP_FIND_LLVM_WITHIN_CLANG ON) add_subdirectory(llvm-project/clang EXCLUDE_FROM_ALL) - set(SKIP_FIND_LLVM OFF) + set(ROOT_SKIP_FIND_LLVM_WITHIN_CLANG OFF) set(CMAKE_CXX_STANDARD ${_cxx_standard}) endif(builtin_clang)