Skip to content

[CMake] Only report include dirs known to cling as compiler defaults - #23924

Merged
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:report-include-directories-fix
Nov 6, 2026
Merged

guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:report-include-directories-fix

Conversation

@guitargeek

@guitargeek guitargeek commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Since b304aa5 ("Drop system headers from cling command line"), rootcling does not promote compiler default include directories to -I, assuming that cling adds them by itself. Cling, however, only adds the C++ standard library directories (queried from the compiler at startup), its own builtin headers and the system directories that the clang driver adds for the sysroot.

The CMAKE__IMPLICIT_INCLUDE_DIRECTORIES that ROOT reports to rootcling as compiler defaults can contain more than that: the compiler wrappers of Nix or Spack and environment variables like CPATH inject the include directories of all dependencies into the implicit search path of the compiler. Cling does not search these at runtime, so dropping them from the rootcling command line and from the dictionary payload breaks the dictionary generation and the runtime interpreter for headers that include dependency headers, e.g.:

REveElement.hxx:27:10: fatal error: 'nlohmann/json.hpp' file not found

Only report the directories that cling knows about as compiler default include directories, so that the other ones are still passed as -I:

  • the C++ standard library directories,
  • the builtin header directories of the compiler,
  • the sysroot directories that the clang driver adds, see AddClangSystemIncludeArgs() in clang/lib/Driver/ToolChains/Linux.cpp and Darwin.cpp. The sysroot is CMAKE_SYSROOT, or on macOS the SDK path that CMake resolves from CMAKE_OSX_SYSROOT (which may be empty or a bare SDK name) and passes to the compiler as -isysroot,
  • the C library directories that the builtin clang is configured with (C_INCLUDE_DIRS), which may not be under the sysroot, e.g. on Nix.

🤖 Done with the help of AI

Fixes a regression introduced by:

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 12h 16m 0s ⏱️
 3 884 tests  3 883 ✅ 0 💤 1 ❌
76 028 runs  76 027 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit a74c68d.

♻️ This comment has been updated with latest results.

guitargeek added a commit to guitargeek/nixpkgs that referenced this pull request Nov 2, 2026
…ules workaround

Update to the current head of ROOT PR 23877. The fix for the openui5
install rule is part of the PR now.

The compiledata.sh and cling include directory fixes were upstreamed
as root-project/root@1b6d33beb82 and root-project/root#23924, so fetch
them from there instead of carrying local copies.

Also apply root-project/root#23923, which generates the Darwin std
modulemap from the libc++ of the compiler instead of the one in the
SDK. This was the reason for disabling runtime_cxxmodules on Darwin.
Since b304aa5 ("Drop system headers from cling command line"),
rootcling does not promote compiler default include directories to -I,
assuming that cling adds them by itself. Cling, however, only adds the
C++ standard library directories (queried from the compiler at startup),
its own builtin headers and the system directories that the clang driver
adds for the sysroot.

The CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES that ROOT reports to
rootcling as compiler defaults can contain more than that: the compiler
wrappers of Nix or Spack and environment variables like CPATH inject the
include directories of all dependencies into the implicit search path of
the compiler. Cling does not search these at runtime, so dropping them
from the rootcling command line and from the dictionary payload breaks
the dictionary generation and the runtime interpreter for headers that
include dependency headers, e.g.:

  REveElement.hxx:27:10: fatal error: 'nlohmann/json.hpp' file not found

Only report the directories that cling knows about as compiler default
include directories, so that the other ones are still passed as -I:

- the C++ standard library directories,
- the builtin header directories of the compiler,
- the sysroot directories that the clang driver adds, see
  AddClangSystemIncludeArgs() in clang/lib/Driver/ToolChains/Linux.cpp
  and Darwin.cpp. The sysroot is CMAKE_SYSROOT, or on macOS the SDK path
  that CMake resolves from CMAKE_OSX_SYSROOT (which may be empty or a
  bare SDK name) and passes to the compiler as -isysroot,
- the C library directories that the builtin clang is configured with
  (C_INCLUDE_DIRS), which may not be under the sysroot, e.g. on Nix.

🤖 Done with the help of AI
@guitargeek
guitargeek force-pushed the report-include-directories-fix branch from 6e3c6df to a74c68d Compare November 3, 2026 16:08
@guitargeek guitargeek added this to the 6.42.00 milestone Nov 5, 2026

@bellenot bellenot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I trust you

@guitargeek
guitargeek merged commit 98cd799 into root-project:master Nov 6, 2026
32 of 34 checks passed
@guitargeek
guitargeek deleted the report-include-directories-fix branch November 6, 2026 08:58
@guitargeek

Copy link
Copy Markdown
Contributor Author

/backport to 6.42

@root-project-bot

Copy link
Copy Markdown

Preparing to backport PR #23924 to branch 6.42 requested by guitargeek

@root-project-bot

Copy link
Copy Markdown

This PR has been backported to branch 6.42: #24023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants