-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[core] Avoid ROOTSYS in TSystem include path
#20823
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
Conversation
|
Were you able to test this with a relocated install? (i.e. installed in |
|
Yes, that works without problem (checked both with |
Test Results 22 files 22 suites 3d 18h 6m 41s ⏱️ For more details on these failures, see this check. Results for commit 2770792. ♻️ This comment has been updated with latest results. |
Using environment variables like `ROOTSYS` in the include paths stored in TSystem - which are used in ACLiC - is problematic if we want to move away from such environment variables. This commit suggests to figure out instead the actual `ROOTSYS` path with `gROOT->GetRootSys()`, and then fill it into the TSystem include path. This makes ALiC work reliably even if `ROOTSYS` is not defined as an environment variable. The code is further simplified by using private preprocessor macros defined at compile time to pass around the `CMAKE_INSTALL_INCLUDEDIR`.
fa6dde1 to
12cc9df
Compare
|
@pcanal, thanks for your suggestions. I have implemented them. |
pcanal
left a comment
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.
LGTM. Thanks.
This introduces a new helper macro that is used in several places in ROOT.
12cc9df to
2770792
Compare
|
This breaks when CMAKE_INSTALL_INCLUDEDIR is an absolute path, since it always prepends the rootsys directory, even if the path is not a relative path. root/core/foundation/src/FoundationUtils.cxx Lines 181 to 194 in 6ecf2d7
and ROOTINCDIR in turn is defined by incdir: Line 12 in 6ecf2d7
and the definition of incdir was removed from cmake/modules/RootConfiguration.cmake by this PR. This also means that TROOT::GetIncludeDir() is broken, since it calls ROOT::FoundationUtils::GetIncludeDir(): Lines 3101 to 3106 in 6ecf2d7
So please revert this. Then change the initialization for fInclude to "-I" + TROOT::GetIncludeDir(). This I think will achieve thw desired result without breaking a lot of other things. |
I was aware of this limitation, but tolerated it because the path is conventionally relative. Having I agree with your other observations, but I think the conclusion should be different. I think root/core/foundation/src/FoundationUtils.cxx Line 191 in 6ecf2d7
I'll make a PR to show what I mean |
|
Using absolute paths is the standard practice for package builds in distributions, so this not working will be disruptive. The current cmake files allow both - prepending the prefix already in cmake in case the paths are relative: root/cmake/modules/RootConfiguration.cmake Lines 42 to 51 in 6ecf2d7
and following lines. (The definition of incdir was here before too). These paths are only used for gnu-install builds. The non-gnuinstall builds assume that the relative install path are the same as the relative build paths. Not using TROOT::GetIncludeDir() to initialize fInclude would result in code duplication and repeating the intricate logic for handling relative and absolute paths and different settings of ROOTIGNOREPREFIX in more than one place. Granted, the current TROOT::GetIncludeDir() doesn't allow using another value for CMAKE_INSTALL_INCLUDEDIR than "include" for a non-gnuinstall build. Up to this point non-gnuistall builds never allowed changing the default relative paths and the GetXxxDir() functions always used the same relative paths as in the build directory for non-gnuinstall builds. So the ROOTIGNOREPREFIX did not have to be checked for non-gnuinstall builds, since the relative paths are the same for the build and install trees in this case. If you start allowing changing the install paths for non-gnuinstall builds you also need to start checking the ROOTIGNOREPREFIX for them as is currently doen for the gnuinstall builds. On the other hand the gnuinstall builds have a hardcoded install directories and can not be relocated. In my opinion, fInclude shou be initialized using GetIncludeDir() as every other place that requires the include directory in the code does it. Any improvements, like allowing non-default values for paths in non-gnuinstall builds should be implemented in the GetXxxDir() functions, so that such changes only have to be implemented in one place. |
Okay fair enough, I don't see why but if that's widely done then we should account for it. That's easy: we can just infer the relative path, from
Yes, absolutely. Sorry I was not clear enough, I meant to imply that I'm suggesting this followup PR:
We have started to allow that, and explicitly do that in the build of the Python wheels. However, I don't see why we need to check the I think the only use of But the possible differences in the relative header/library/etc dirs between install and build tree are indeed a problem that needs to be addressed, while keeping both build and install tree relocatable. My goal for this is to introduce some other mechanism to auto-detect that, so that tests don't need to explicitly set |
Using environment variables like
ROOTSYSin the include paths stored in TSystem - which are used in ACLiC - is problematic if we want to move away from such environment variables.This commit suggests to figure out instead the actual
ROOTSYSpath withgROOT->GetRootSys(), and then fill it into the TSystem include path. This makes ALiC work reliably even ifROOTSYSis not defined as an environment variable.The code is further simplified by using private preprocessor macros defined at compile time to pass around the
CMAKE_INSTALL_INCLUDEDIR.For illustration, here is the output of
root_build/bin/root -b -q -e "gSystem->GetIncludePath()"on my system before and after this PR. Before:After:
(const char *) "-I/home/rembserj/code/root/root_install/include"Or, if running
bin/rootin the build tree:(const char *) "-I/home/rembserj/code/root/root_build/include"Spinoff from this PR, where I want to use ACLiC for some dictionary generation at test time, without
ROOTSYSin the environment: