From 267e7fc093216c4b07c1fa1d864efb4e9a085fed Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Sun, 4 Oct 2026 18:40:27 +0000 Subject: [PATCH] Remove the find_package() override for builtin_clang With builtin_llvm=OFF and builtin_clang=ON, interpreter/CMakeLists.txt sets LLVM_LINK_LLVM_DYLIB to OFF and redefines find_package(), so that Clang's find_package(LLVM) cannot set it back to ON from a distribution's LLVMConfig.cmake. Commands defined with macro() are global, so every later find_package() in ROOT's configuration goes through the override, and a second override anywhere would send find_package() into endless recursion. Nor is the override what keeps libCling static: add_cling_library() passes DISABLE_LLVM_LINK_LLVM_DYLIB, and CppInterOp maps the Clang targets back to static LLVM components. Remove it, but keep CLANG_LINK_CLANG_DYLIB defaulting to OFF as before. Clang derives that default from LLVM_LINK_LLVM_DYLIB, so a build directory first configured with ON could no longer go back to a tree with the override. The option only affects Clang's tools, which ROOT does not build. --- interpreter/CMakeLists.txt | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index fe0a4b4f36a4f..8f6b06bd51e66 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -391,30 +391,16 @@ else() # install-clang-cpp target defined by LLVM's cmake module set(CLANG_LINKS_TO_CREATE clang++ clang-cl) - # 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. - # TEMPORARY: remove this workaround once ROOT can link against the shared - # libLLVM.so for builtin_llvm=OFF - macro(find_package _package_name) - 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() - endmacro() + # Clang defaults this to LLVM_LINK_LLVM_DYLIB, which LLVMConfig.cmake may set to + # ON; ROOT links no Clang tool against libclang-cpp. + set(CLANG_LINK_CLANG_DYLIB OFF CACHE BOOL "Link Clang tools against libclang-cpp") # 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(ROOT_SKIP_FIND_LLVM_WITHIN_CLANG ON) add_subdirectory(llvm-project/clang EXCLUDE_FROM_ALL) - set(ROOT_SKIP_FIND_LLVM_WITHIN_CLANG OFF) set(CMAKE_CXX_STANDARD ${_cxx_standard}) endif(builtin_clang)