-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Make non-system include paths accessible at runtime #19179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make non-system include paths accessible at runtime #19179
Conversation
fdc4019 to
4c0e474
Compare
Test Results 22 files 22 suites 3d 19h 21m 59s ⏱️ For more details on these failures, see this check. Results for commit 8d801f2. ♻️ This comment has been updated with latest results. |
There was a problem hiding this 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
|
@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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
I am getting an error in the lcg build with this |
|
What do you practically mean by: ? |
|
Thank you all for your comments!
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 @andresailer |
6feedf8 to
8d5fa90
Compare
7c876fb to
b418258
Compare
|
Reported CI test failures also present on yesterdays ROOT Main nightly. @andresailer I sent a PR for lcgcmake. |
|
I think for me this is fine as it is. Thanks! |
ec6ae3c to
e18a505
Compare
e18a505 to
848a6f0
Compare
|
What is the status here? Is this going to get merged soon? |
848a6f0 to
1e15e33
Compare
There was a problem hiding this 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
| 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} |
There was a problem hiding this comment.
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:
| 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}} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
c378442 to
f23735b
Compare
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.
f23735b to
8d801f2
Compare
…re on stacks as reported by Andre Sailer on root-project#19179
…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]>
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_PATHenvironment variable.This commit introduces a new CMake variable
DEFAULT_ROOT_INCLUDE_PATHand a helper functionIF_NOT_SYSTEM_PATH_APPEND. This function allows us to conditionally append include paths of external libraries toDEFAULT_ROOT_INCLUDE_PATH, for exampleIF_NOT_SYSTEM_PATH_APPEND("${Vc_INCLUDE_DIR}" DEFAULT_ROOT_INCLUDE_PATH)The
DEFAULT_ROOT_INCLUDE_PATHvariable is then utilized to populate theROOT_INCLUDE_PATHenvironment 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.