Skip to content

[CMake] do not let builtin_clang search again for LLVM if builtin_llvm=OFF - #23371

Merged
guitargeek merged 2 commits into
root-project:masterfrom
ferdymercury:refindLLVM
Sep 16, 2026
Merged

guitargeek merged 2 commits into
root-project:masterfrom
ferdymercury:refindLLVM

Conversation

@ferdymercury

@ferdymercury ferdymercury commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

This Pull request:

Changes or fixes:

Alternative to #23160 that does not require any upstream or downstream patches to Clang.

This is a temporary solution, since building with LLVM.so is broken at the moment. (#20903 (comment)). It can be removed later if at some point that issue gets fixed.

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 #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.

Reproducer

docker run -it registry.cern.ch/root-ci/ubuntu2604:buildready
apt update
apt install llvm-22-dev libedit-dev libpolly-22-dev
git clone https://github.com/root-project/root root_src && cd root_src
git checkout master
mkdir build && cd build
cmake -Dbuiltin_llvm=OFF -Dminimal=ON ..
grep -r LLVM.so *

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

Fixes #18387
Fixes #23155

…in_llvm=OFF

Alternative to root-project#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 root-project#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 root-project#18387
Fixes root-project#23155
@ferdymercury
ferdymercury marked this pull request as ready for review September 15, 2026 11:14
@ferdymercury ferdymercury added this to the 6.42.00 milestone Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 11h 49m 21s ⏱️
 3 879 tests  3 879 ✅ 0 💤 0 ❌
76 327 runs  76 327 ✅ 0 💤 0 ❌

Results for commit 80875d8.

♻️ This comment has been updated with latest results.

@guitargeek guitargeek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this new solution attempt, looks great!

  • Fixes the builtin_llvm=OFF configuration without an additional LLVM/Clang patch, handling the problem from the ROOT side. @hahnjo is explicitly fine with that (#18387 (comment))
  • Overriding find_package is a common practice, but it might cause problems for vcpkg o n Windows (see #8633). But since we're restricting this override to the builtin_llvm=OFF configuration that is typically not used on Windows, this is fine for a temporary workaround that we'll carry until we can link against shared LLVM

I just have a few minor change requests that should be addressed before I can approve this PR.

Comment thread interpreter/CMakeLists.txt Outdated
Comment thread interpreter/CMakeLists.txt Outdated
Comment thread interpreter/CMakeLists.txt
Comment thread interpreter/CMakeLists.txt Outdated
Comment thread interpreter/CMakeLists.txt Outdated
to clarify that this is a temporary workaround

Co-authored-by: Jonas Rembser <jonas.rembser@cern.ch>

@guitargeek guitargeek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! See my previous comment for thorough review (#23371 (review))

@guitargeek
guitargeek merged commit 4de3462 into root-project:master Sep 16, 2026
61 of 65 checks passed
@guitargeek guitargeek changed the title [interpreter] do not let builtin_clang search again for LLVM if builtin_llvm=OFF [CMake] do not let builtin_clang search again for LLVM if builtin_llvm=OFF Sep 16, 2026
@ferdymercury
ferdymercury deleted the refindLLVM branch September 16, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants