avoid rpath'ing default search paths#44686
Conversation
0059405 to
9dfc766
Compare
|
This still needs fixes for CMakePackage which doesn't follow the code path that filters the rpaths. |
9dfc766 to
0ceab05
Compare
afe0f6d to
12616de
Compare
|
I realize that this may break cmake packages that do not hit the compiler wrapper due to |
|
I rebased this PR on develop and I'm seeing the following build error |
|
So far this PR seems to be working well for me on gentoo. This change c4dd67b got me back up and running after I rebased this on a more recent develop What can I test / provide that can help push this PR forward? Being able to use spack with ease on gentoo would let me ditch |
0fa9693 to
b548924
Compare
|
OK, so the CMake solution of the PR is to use |
20f497c to
ad4a42e
Compare
On sysroot systems like gentoo prefix, as well as nix/guix, our "is system path" logic is broken cause it's static. If glibc is recent enough, we can query the dynamic loader's default search paths, which is a much more robust way to avoid registering rpaths to "system" dirs.
ad4a42e to
3ecc2e4
Compare
Closes #40848
On sysroot systems like gentoo prefix, as well as nix/guix, our "is
system path" logic is broken cause it's static.
Talking about "the system paths" is not helpful, we have to talk
about default search paths of the dynamic linker instead.
If glibc is recent enough, we can query the dynamic loader's default
search paths, which is a much more robust way to avoid registering
rpaths to system dirs, which can shadow Spack dirs.
This PR adds an additional filter on rpaths the compiler wrapper
adds, dropping rpaths that are default search paths. The PR does
not remove any of the original
is_system_pathcode, which isquestionable code, but can't hurt much.
(In a follow up PR we could look to register rpaths based only on
the default search paths of the dynamic linker, and get rid of
is_system_path. I don't want to make too many changes at thesame time.)
This fixes issues where build systems run just-built executables
linked against their not-yet-installed libraries, typically:
which happens in
perl,python, and other non-cmake packages.If a default path is rpath'ed, it takes precedence over
LD_LIBRARY_PATH, and a system library gets loaded insteadof the just-built library in the stage dir, breaking the build. If
default paths are not rpath'ed, then LD_LIBRARY_PATH takes
precedence, as is desired.
This PR additionally fixes an inconsistency in rpaths between
cmake and non-cmake packages. The cmake build system
computed rpaths by itself, but used a different order than
computed for the compiler wrapper. In fact it's not necessary
to compute rpaths at all, since we let cmake do that thanks to
CMAKE_INSTALL_RPATH_USE_LINK_PATH. This covers rpathsfor all dependencies. The only install rpaths we need to set are
<install prefix>/{lib,lib64}, which cmake unfortunately omits,although it could also know these. Also, cmake does not
delete rpaths added by the toolchain (i.e. Spack's compiler
wrapper), so I don't think it should be controversial to simplify
things.