Additional patch to Clangs CMake code is required in case LLVM was built with `LLVM_LINK_LLVM_DYLIB=ON`
envgap__root-project__root-18387
01 / FAILURE SIGNATURE
As reported upstream
No identifying execution failure has been captured.
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
07812a04d70b0005b18a521c3bf09c3dd7749e86- Manifest
interpreter/CMakeLists.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
root-project/root #18387 · read the original issue
### 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:
* https://github.com/root-project/root/pull/18386
```diff
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` and `builtin_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:
* https://github.com/root-project/root/issues/1769804 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]