root: fix cling CMake include ordering for external LLVM#932
Open
wdconinc wants to merge 1 commit into
Open
Conversation
With external LLVM (builtin_llvm=OFF), LLVM_INCLUDE_DIRS points to /usr/lib/llvm-20/include which contains cxxabi.h from libc++abi. The unconditional 'include_directories(BEFORE SYSTEM ...)' in interpreter/cling/CMakeLists.txt causes that header to shadow GCC 14's cxxabi.h, producing a hard conflict on __cxa_init_primary_exception (LLVM returns __cxa_exception*; GCC returns __cxa_refcounted_exception*). With builtin_llvm=ON the build-tree LLVM_INCLUDE_DIRS contain no cxxabi.h, so BEFORE SYSTEM is harmless. For external LLVM, BEFORE is not needed because the outer interpreter/CMakeLists.txt already registers the external LLVM include path without BEFORE; only SYSTEM (for warning suppression) is needed. Fixes: eic/containers#288 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
wdconinc
added a commit
to eic/containers
that referenced
this pull request
May 23, 2026
Point to eic/eic-spack#932 which guards the BEFORE flag in interpreter/cling/CMakeLists.txt include_directories to only apply when builtin_llvm=ON. With external LLVM, the unconditional BEFORE caused LLVM's libc++abi cxxabi.h to shadow GCC 14's cxxabi.h, producing a conflicting declaration of __cxa_init_primary_exception. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the EIC Spack overlay for ROOT to avoid a cling build failure when ROOT is built against an external (system) LLVM, by adjusting include directory ordering in cling’s CMake configuration.
Changes:
- Add a ROOT Spack patch that conditionally uses
include_directories(BEFORE ...)only whenbuiltin_llvmis enabled. - Apply the patch only for ROOT
@6.36:builds using external LLVM (~builtin_llvm).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
spack_repo/eic/packages/root/package.py |
Registers the new patch for ROOT builds with external LLVM on versions @6.36:. |
spack_repo/eic/packages/root/cling-cmake-external-llvm-include-order.patch |
Implements the conditional BEFORE include ordering in interpreter/cling/CMakeLists.txt. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wdconinc
added a commit
to eic/containers
that referenced
this pull request
May 23, 2026
Point to eic/eic-spack#932 which guards the BEFORE flag in interpreter/cling/CMakeLists.txt include_directories to only apply when builtin_llvm=ON. With external LLVM, the unconditional BEFORE caused LLVM's libc++abi cxxabi.h to shadow GCC 14's cxxabi.h, producing a conflicting declaration of __cxa_init_primary_exception. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When building ROOT against an external (system-installed) LLVM (
~builtin_llvm), theLLVM_INCLUDE_DIRSpath (e.g./usr/lib/llvm-20/include) contains acxxabi.hfrom libc++abi.The unconditional line in
interpreter/cling/CMakeLists.txt:pushes that directory in front of all system includes, causing LLVM's
cxxabi.hto shadow GCC 14'scxxabi_init_exception.h. This triggers a hard compiler error on__cxa_init_primary_exception: LLVM declares it returning__cxa_exception*, while GCC 14 declares it returning__cxa_refcounted_exception*.Root cause
The
BEFOREflag was introduced (commit3c58e0d3, 2020) to ensure cling's own LLVM headers take priority. This is correct forbuiltin_llvm=ON— the in-treeLLVM_INCLUDE_DIRScontains nocxxabi.h. For external LLVM,BEFOREis not needed (the headers are already registered byinterpreter/CMakeLists.txtwithoutBEFORE) and actively harmful.Fix
Guard the
BEFOREflag withif(builtin_llvm). For external LLVM, use plainSYSTEM(still suppresses warnings) withoutBEFORE.Fixes: eic/containers#288