Skip to content

Conversation

@LukasBreitwieser
Copy link
Contributor

The current implementation faces issues with accessing header files from external libraries stored in non-system paths when the C++ interpreter tries to resolve them at runtime. This access is necessary under certain conditions even if a corresponding module file exists. Related issues: SPI-2794, #18949

To address this issue, we need to ensure that non-system path includes, which are known at build time, remain accessible at runtime. The proposed solution leverages the existing ROOT_INCLUDE_PATH environment variable.

This commit introduces a new CMake variable DEFAULT_ROOT_INCLUDE_PATH and a helper function IF_NOT_SYSTEM_PATH_APPEND. This function allows us to conditionally append include paths of external libraries to DEFAULT_ROOT_INCLUDE_PATH, for example IF_NOT_SYSTEM_PATH_APPEND("${Vc_INCLUDE_DIR}" DEFAULT_ROOT_INCLUDE_PATH)

The DEFAULT_ROOT_INCLUDE_PATH variable is then utilized to populate the ROOT_INCLUDE_PATH environment variable in the configuration files (thisroot.{sh,csh,fish,bat}).

If the library's include path is dynamically modified between build and run time, the configuration can be updated by patching the thisroot.{sh,csh,fish,bat} files.

@github-actions
Copy link

github-actions bot commented Jun 25, 2025

Test Results

    22 files      22 suites   3d 19h 21m 59s ⏱️
 3 691 tests  3 686 ✅ 0 💤 5 ❌
79 254 runs  79 249 ✅ 0 💤 5 ❌

For more details on these failures, see this check.

Results for commit 8d801f2.

♻️ This comment has been updated with latest results.

Copy link
Member

@hageboeck hageboeck left a comment

Choose a reason for hiding this comment

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

Nice! I added a few comments below

@hageboeck
Copy link
Member

@LukasBreitwieser, what happens when you install (and therefore relocate) ROOT? Given that these paths are system paths, things should continue to work, won't they?

ROOT_INCLUDE_PATH=@DEFAULT_ROOT_INCLUDE_PATH@
export ROOT_INCLUDE_PATH
else
ROOT_INCLUDE_PATH=@DEFAULT_ROOT_INCLUDE_PATH@:$ROOT_INCLUDE_PATH
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you consider this an issue if DEFAULT_ROOT_INCLUDE_PATH is empty? Not just here but in the other shell setups?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this should be an issue. This case is also covered by all GHA runners.

@andresailer
Copy link
Contributor

I am getting an error in the lcg build with this

[100%] Generating tutorials/hsimple.root
root.exe: /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/ROOT-default-root-include-path/src/ROOT/default-root-include-path/interpreter/llvm-project/clang/lib/Serialization/ASTReader.cpp:4332: clang::ASTReader::ASTReadResult clang::ASTReader::ReadModuleMapFileBlock(RecordData&, ModuleFile&, const ModuleFile*, unsigned int): Assertion `M && M->Name == F.ModuleName && "found module with different name"' failed.

https://lcgapp-services.cern.ch/cdash/build/98193/files

@pcanal
Copy link
Member

pcanal commented Jun 27, 2025

What do you practically mean by:

If the library's include path is dynamically modified between build and run time, the configuration can be updated by patching the thisroot.{sh,csh,fish,bat} files.

?

@LukasBreitwieser
Copy link
Contributor Author

Thank you all for your comments!

@hageboeck

@LukasBreitwieser, what happens when you install (and therefore relocate) ROOT? Given that these paths are system paths, things should continue to work, won't they?

Yes this works. Only third party include paths (i.e., include paths outside the root src/build/install directories) should be added. Perhaps a good idea to add additional checks for these conditions.

@pcanal
If the include path (to e.g. Vc) at runtime is different to the one at build time, which might happen for spack installations using its binary cache.
In that case the thisroot.* files must be patched.

@andresailer
Thank you for running the lcg build. Will investigate the failure.

@LukasBreitwieser LukasBreitwieser force-pushed the default-root-include-path branch from 6feedf8 to 8d5fa90 Compare July 28, 2025 10:06
@LukasBreitwieser LukasBreitwieser force-pushed the default-root-include-path branch from 7c876fb to b418258 Compare August 6, 2025 09:23
@LukasBreitwieser
Copy link
Contributor Author

Reported CI test failures also present on yesterdays ROOT Main nightly.

@andresailer I sent a PR for lcgcmake.
I ran the dev3 lcgcmake build on alma9 and root-tests passed. Do you want to check the other stacks too?

@andresailer
Copy link
Contributor

I think for me this is fine as it is. Thanks!

@LukasBreitwieser LukasBreitwieser force-pushed the default-root-include-path branch 2 times, most recently from ec6ae3c to e18a505 Compare August 22, 2025 17:33
@LukasBreitwieser LukasBreitwieser force-pushed the default-root-include-path branch from e18a505 to 848a6f0 Compare September 4, 2025 09:35
@andresailer
Copy link
Contributor

What is the status here? Is this going to get merged soon?

@andresailer
Copy link
Contributor

The tests added in #19667
are not working in the nightly tests because

ROOT_INCLUDE_PATH=${CMAKE_BINARY_DIR}/tutorials/io/tree

overwrites our existing ROOT_INCLUDE_PATH. So would be nice if this here is merged, or we need a fix in that other line.

Copy link
Member

@hageboeck hageboeck left a comment

Choose a reason for hiding this comment

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

Please see a possible oversight below, but otherwise, LGTM!

+don't forget to squash, please. 🙂

CMakeLists.txt Outdated
Comment on lines 594 to 585
set(hsimple_cmd COMMAND ROOT_INCLUDE_PATH="${DEFAULT_ROOT_INCLUDE_PATH}" ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}:$ENV{${ld_library_path}}
ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a small oversight:

Suggested change
set(hsimple_cmd COMMAND ROOT_INCLUDE_PATH="${DEFAULT_ROOT_INCLUDE_PATH}" ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}:$ENV{${ld_library_path}}
ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
set(hsimple_cmd COMMAND ROOT_INCLUDE_PATH="${DEFAULT_ROOT_INCLUDE_PATH}" ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}:$ENV{${ld_library_path}}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the additional unquoted ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH} actually made things work. Because the quotes get escaped by cmake and then things no longer work.

Copy link
Member

Choose a reason for hiding this comment

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

This might well be the case. @LukasBreitwieser ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can tell you things definitely do not work (https://lcgapp-services.cern.ch/cdash/build/119422/files) and if I drop the quotes things are working.

@LukasBreitwieser LukasBreitwieser force-pushed the default-root-include-path branch from c378442 to f23735b Compare October 10, 2025 10:18
The current implementation faces issues with accessing header files
from external libraries stored in non-system paths when the C++
interpreter tries to resolve them at runtime. This access is necessary
under certain conditions even if a corresponding module file exists.

To address this issue, we need to ensure that non-system path includes,
which are known at build time, remain accessible at runtime. The
proposed solution leverages the existing `ROOT_INCLUDE_PATH` environment
variable.

This commit introduces a new CMake variable `DEFAULT_ROOT_INCLUDE_PATH`
and a helper function `BUILD_ROOT_INCLUDE_PATH`. This function allows
us to append include paths of external libraries to `BUILD_ROOT_INCLUDE_PATH`,
for example:
`DEFAULT_ROOT_INCLUDE_PATH("${Vc_INCLUDE_DIR}" DEFAULT_ROOT_INCLUDE_PATH)`

The `DEFAULT_ROOT_INCLUDE_PATH` variable is then utilized to populate the
`ROOT_INCLUDE_PATH` environment variable in the configuration files
(`thisroot.{sh,csh,fish,bat}`).

If the library's include path is dynamically modified between build and
run time, the configuration can be updated by patching the
`thisroot.{sh,csh,fish,bat}` files.
@LukasBreitwieser LukasBreitwieser force-pushed the default-root-include-path branch from f23735b to 8d801f2 Compare October 10, 2025 12:32
@dpiparo dpiparo merged commit 301e078 into root-project:master Oct 11, 2025
87 of 96 checks passed
LukasBreitwieser pushed a commit to LukasBreitwieser/root that referenced this pull request Oct 13, 2025
LukasBreitwieser added a commit that referenced this pull request Oct 14, 2025
…re on stacks (#20098)

as reported by Andre Sailer on #19179
CMake escapes the quotes when the command is executed (at least on Linux) which renders the 
ROOT_INCLUDE_PATH broken

Co-authored-by: Lukas Johannes Breitwieser <Lukas Johannes Breitwieser>
Co-authored-by: Andre Sailer <[email protected]>
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.

5 participants