Skip to content

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

Merged
guitargeek merged 1 commit into
root-project:v6-42-00-patchesfrom
root-project-bot:BP_6.42_pull_23924
Nov 6, 2026
Merged

guitargeek merged 1 commit into
root-project:v6-42-00-patchesfrom
root-project-bot:BP_6.42_pull_23924

Conversation

@root-project-bot

Copy link
Copy Markdown

Backport of #23924, requested by @guitargeek.

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

(cherry picked from commit 98cd799)
@guitargeek
guitargeek merged commit 9c3c928 into root-project:v6-42-00-patches Nov 6, 2026
34 of 37 checks passed
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