From e4f4453259944676143697e44a83e9a13badaa6e Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Thu, 2 Jan 2025 11:47:54 +0100 Subject: [PATCH 1/5] [cling] Prevent builtin_llvm with builtin_clang=OFF --- interpreter/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index 162235343e66c..be084a734f9f7 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -2,6 +2,10 @@ set(CMAKE_MODULE_PATH "") #--- Check if we need to build llvm and clang ------------------------------------------------------ +if (builtin_llvm AND NOT builtin_clang) + message(FATAL_ERROR "Cannot enable builtin LLVM, but provide external Clang") +endif() + if (NOT builtin_clang) message(WARNING "Due to ROOT-specific patches you need a special version of clang. You cannot use vanilla clang.") endif() From da1a710c403340db19bc1ae3f3b9ffa925f4a737 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Thu, 2 Jan 2025 12:01:33 +0100 Subject: [PATCH 2/5] [interpreter/cling] Consistently set and use CLANG_CMAKE_DIR For standard CMake, Clang_DIR should include the lib/cmake/clang subdirectory suffix. This currently works only because Clad defines HINTS itself. --- interpreter/CMakeLists.txt | 6 +++--- interpreter/cling/CMakeLists.txt | 3 ++- interpreter/cling/cmake/modules/CMakeLists.txt | 2 +- interpreter/cling/tools/plugins/clad/CMakeLists.txt | 6 +----- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index be084a734f9f7..aadfc932aabc3 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -462,18 +462,18 @@ endif(builtin_llvm) if (builtin_clang) if (builtin_llvm) - # For builtin LLVM this is set in interpreter/llvm-project/llvm/CMakeLists.txt set(Clang_DIR "${LLVM_BINARY_DIR}/tools/clang/") else() set(Clang_DIR "${CMAKE_BINARY_DIR}/interpreter/llvm-project/clang/") - set(Clang_Config_ExtraPathHints "${Clang_DIR}cmake/modules/CMakeFiles") endif() set(CLANG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/interpreter/llvm-project/clang/include ${Clang_DIR}/include CACHE STRING "Clang include directories.") + # FIXME: This is due to a downstream patch! + set(CLANG_CMAKE_DIR "${Clang_DIR}/lib/cmake/clang/") else() - set(Clang_DIR "${LLVM_BINARY_DIR}/lib/cmake/clang/") + set(CLANG_CMAKE_DIR "${LLVM_BINARY_DIR}/lib/cmake/clang/") endif() # Reset the compiler flags after compiling LLVM and Clang diff --git a/interpreter/cling/CMakeLists.txt b/interpreter/cling/CMakeLists.txt index 710de930b4ac4..c15ae096a30a6 100644 --- a/interpreter/cling/CMakeLists.txt +++ b/interpreter/cling/CMakeLists.txt @@ -23,7 +23,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) find_package(Clang REQUIRED CONFIG) message(STATUS "Found supported version: Clang ${CLANG_PACKAGE_VERSION}") - message(STATUS "Using ClangConfig.cmake in: ${Clang_DIR}") + message(STATUS "Using ClangConfig.cmake in: ${CLANG_CMAKE_DIR}") find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) @@ -111,6 +111,7 @@ else() list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") include(${LLVMCONFIG_FILE}) endif() + set(CLANG_CMAKE_DIR "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang") if (NOT CLANG_INCLUDE_DIRS) set (CLANG_INCLUDE_DIRS "${LLVM_MAIN_SRC_DIR}/tools/clang/include") if (NOT EXISTS ${CLANG_INCLUDE_DIRS}) diff --git a/interpreter/cling/cmake/modules/CMakeLists.txt b/interpreter/cling/cmake/modules/CMakeLists.txt index e28220db6a06b..4de71a0994783 100644 --- a/interpreter/cling/cmake/modules/CMakeLists.txt +++ b/interpreter/cling/cmake/modules/CMakeLists.txt @@ -13,7 +13,7 @@ export(TARGETS ${CLING_EXPORTS} FILE ${cling_cmake_builddir}/ClingTargets.cmake) # Generate ClingConfig.cmake for the build tree. set(CLING_CONFIG_CMAKE_DIR "${cling_cmake_builddir}") -set(CLING_CONFIG_CLANG_CMAKE_DIR "${clang_cmake_builddir}") +set(CLING_CONFIG_CLANG_CMAKE_DIR "${CLANG_CMAKE_DIR}") set(CLING_CONFIG_EXPORTS_FILE "${cling_cmake_builddir}/ClingTargets.cmake") set(CLING_CONFIG_INCLUDE_DIRS "${CLING_SOURCE_DIR}/include" diff --git a/interpreter/cling/tools/plugins/clad/CMakeLists.txt b/interpreter/cling/tools/plugins/clad/CMakeLists.txt index 3c70d00a10f3b..6c5c145da40f9 100644 --- a/interpreter/cling/tools/plugins/clad/CMakeLists.txt +++ b/interpreter/cling/tools/plugins/clad/CMakeLists.txt @@ -46,10 +46,6 @@ if (CMAKE_CXX_STANDARD) list(APPEND _clad_extra_cmake_args -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}) endif(CMAKE_CXX_STANDARD) -if (Clang_DIR) - list(APPEND _clad_extra_cmake_args -DClang_DIR=${Clang_DIR} -DClang_CONFIG_EXTRA_PATH_HINTS=${Clang_Config_ExtraPathHints}) -endif(Clang_DIR) - if (LLVM_FORCE_USE_OLD_TOOLCHAIN) list(APPEND _clad_extra_cmake_args -DLLVM_FORCE_USE_OLD_TOOLCHAIN=${LLVM_FORCE_USE_OLD_TOOLCHAIN}) endif(LLVM_FORCE_USE_OLD_TOOLCHAIN) @@ -94,7 +90,7 @@ ExternalProject_Add( -DCMAKE_CXX_FLAGS=${CLAD_CXX_FLAGS} -DCMAKE_INSTALL_PREFIX=${clad_install_dir}/plugins -DLLVM_DIR=${LLVM_BINARY_DIR} - -DCLANG_INCLUDE_DIRS=${CLANG_INCLUDE_DIRS} + -DClang_DIR=${CLANG_CMAKE_DIR} ${_clad_extra_cmake_args} # FIXME # Building with 1 core is a temporary workaround for #16654 and has to be From 2e03918903be3cf565e36180714d348111e38983 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Thu, 2 Jan 2025 12:06:12 +0100 Subject: [PATCH 3/5] [interpreter] Rename variable as CLANG_BINARY_DIR This is the name used in the Clang build system. --- interpreter/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index aadfc932aabc3..9e1a9c9a12357 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -462,16 +462,16 @@ endif(builtin_llvm) if (builtin_clang) if (builtin_llvm) - set(Clang_DIR "${LLVM_BINARY_DIR}/tools/clang/") + set(CLANG_BINARY_DIR "${LLVM_BINARY_DIR}/tools/clang/") else() - set(Clang_DIR "${CMAKE_BINARY_DIR}/interpreter/llvm-project/clang/") + set(CLANG_BINARY_DIR "${CMAKE_BINARY_DIR}/interpreter/llvm-project/clang/") endif() set(CLANG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/interpreter/llvm-project/clang/include - ${Clang_DIR}/include + ${CLANG_BINARY_DIR}/include CACHE STRING "Clang include directories.") # FIXME: This is due to a downstream patch! - set(CLANG_CMAKE_DIR "${Clang_DIR}/lib/cmake/clang/") + set(CLANG_CMAKE_DIR "${CLANG_BINARY_DIR}/lib/cmake/clang/") else() set(CLANG_CMAKE_DIR "${LLVM_BINARY_DIR}/lib/cmake/clang/") endif() From eccee952e0506edfe777b46214d51210db56a4d2 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Thu, 2 Jan 2025 12:08:53 +0100 Subject: [PATCH 4/5] [cling] Use CMAKE_CURRENT_{SOURCE,BINARY}_DIR This is clearer and should also help in case ROOT is built as a subdirectory itself. --- interpreter/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index 9e1a9c9a12357..c31473d6cc348 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -56,7 +56,7 @@ set(LLVM_FORCE_USE_OLD_TOOLCHAIN ON CACHE BOOL "") set(CMAKE_DISABLE_FIND_PACKAGE_CUDA ON) # will be set again in case NOT builtin_llvm -set(LLVM_DIR "${CMAKE_BINARY_DIR}/interpreter/llvm-project/llvm") +set(LLVM_DIR "${CMAKE_CURRENT_BINARY_DIR}/llvm-project/llvm") if (clad) set(CLING_BUILD_PLUGINS ON) endif() @@ -239,8 +239,8 @@ if(builtin_llvm) unset(CMAKE_MESSAGE_LOG_LEVEL) endif() - set(LLVM_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/interpreter/llvm-project/llvm/include - ${CMAKE_BINARY_DIR}/interpreter/llvm-project/llvm/include + set(LLVM_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/llvm-project/llvm/include + ${CMAKE_CURRENT_BINARY_DIR}/llvm-project/llvm/include CACHE STRING "LLVM include directories." ) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/llvm-project/llvm/cmake/modules") @@ -464,10 +464,10 @@ if (builtin_clang) if (builtin_llvm) set(CLANG_BINARY_DIR "${LLVM_BINARY_DIR}/tools/clang/") else() - set(CLANG_BINARY_DIR "${CMAKE_BINARY_DIR}/interpreter/llvm-project/clang/") + set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/llvm-project/clang/") endif() set(CLANG_INCLUDE_DIRS - ${CMAKE_SOURCE_DIR}/interpreter/llvm-project/clang/include + ${CMAKE_CURRENT_SOURCE_DIR}/llvm-project/clang/include ${CLANG_BINARY_DIR}/include CACHE STRING "Clang include directories.") # FIXME: This is due to a downstream patch! @@ -521,7 +521,7 @@ if (builtin_cling) add_subdirectory(cling EXCLUDE_FROM_ALL) add_dependencies(CLING ${CLING_LIBRARIES}) - set(CLING_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/interpreter/cling/include CACHE STRING "") + set(CLING_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/cling/include CACHE STRING "") From 27c18ce1294574b95c602cb8ab619b3e28e5b067 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Thu, 2 Jan 2025 12:15:30 +0100 Subject: [PATCH 5/5] [interpreter] Revert patch to move ClangConfig.cmake Commit 8a45c096f1 already modified the setup of ClingConfig.cmake, this reverts the second part of commit 2b283ccf3a and removes one downstream patch from our Clang sources. --- interpreter/CMakeLists.txt | 3 +-- interpreter/llvm-project/clang/cmake/modules/CMakeLists.txt | 2 +- interpreter/llvm-project/llvm-project.tag | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index c31473d6cc348..52f8eb8439e4b 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -470,8 +470,7 @@ if (builtin_clang) ${CMAKE_CURRENT_SOURCE_DIR}/llvm-project/clang/include ${CLANG_BINARY_DIR}/include CACHE STRING "Clang include directories.") - # FIXME: This is due to a downstream patch! - set(CLANG_CMAKE_DIR "${CLANG_BINARY_DIR}/lib/cmake/clang/") + set(CLANG_CMAKE_DIR "${CMAKE_BINARY_DIR}/lib/cmake/clang/") else() set(CLANG_CMAKE_DIR "${LLVM_BINARY_DIR}/lib/cmake/clang/") endif() diff --git a/interpreter/llvm-project/clang/cmake/modules/CMakeLists.txt b/interpreter/llvm-project/clang/cmake/modules/CMakeLists.txt index 9a3ffb0ee624a..d2d68121371bf 100644 --- a/interpreter/llvm-project/clang/cmake/modules/CMakeLists.txt +++ b/interpreter/llvm-project/clang/cmake/modules/CMakeLists.txt @@ -9,7 +9,7 @@ include(FindPrefixFromConfig) set(CLANG_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/clang" CACHE STRING "Path for CMake subdirectory for Clang (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/clang')") # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below. -set(clang_cmake_builddir "${CLANG_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang") +set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang") # Keep this in sync with llvm/cmake/CMakeLists.txt! set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING diff --git a/interpreter/llvm-project/llvm-project.tag b/interpreter/llvm-project/llvm-project.tag index e06c311eb1fb0..b6c5cd7502d0a 100644 --- a/interpreter/llvm-project/llvm-project.tag +++ b/interpreter/llvm-project/llvm-project.tag @@ -1 +1 @@ -ROOT-llvm18-20250117-01 \ No newline at end of file +ROOT-llvm18-20250121-01