Closed as not planned
Closed as not planned
Description
Description
Additional patches to Clangs CMake code are required in case LLVM was built with LLVM_LINK_LLVM_DYLIB=ON
, similar to the patches that were done in ROOT here:
diff --git a/interpreter/llvm-project/clang/CMakeLists.txt b/interpreter/llvm-project/clang/CMakeLists.txt
index 5f2b7f064d..3a2e593aa7 100644
--- a/interpreter/llvm-project/clang/CMakeLists.txt
+++ b/interpreter/llvm-project/clang/CMakeLists.txt
@@ -29,6 +29,15 @@ if(CLANG_BUILT_STANDALONE)
endif()
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
+
+ # Disable linking against shared LLVM. We have to do this after
+ # find_package(LLVM), which overwrites LLVM_LINK_LLVM_DYLIB to what it was
+ # set when building LLVM. Clang needs to link LLVM statically, otherwise it
+ # won't work for Cling. By doing forcing this, we can build Clang on top of
+ # existing LLVM builds even they were built with LLVM_LINK_LLVM_DYLIB=ON,
+ # which is usually the case for system packages.
+ set(LLVM_LINK_LLVM_DYLIB FALSE)
+
list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
# Turn into CACHE PATHs for overwritting
Where should this patch go? Would it be reasonable to do it in our fork of LLVM and then sync ROOT with it?
https://github.com/root-project/llvm-project
@hahnjo, your advice would be very appreciated here!
Reproducer
- take LLVM build with
LLVM_LINK_LLVM_DYLIB=ON
(usually the case for the system packages) - build patched Clang for ROOT standalone
- try to build ROOT with
builtin_llvm=OFF
andbuiltin_clang=OFF
Only with the patch in the Clang CMakeLists.txt, it works for me.
Additional context
See also this issue for some context on why it is necessary to statically link against LLVM:
Metadata
Metadata
Assignees
Type
Projects
Status
Issues