-
Notifications
You must be signed in to change notification settings - Fork 425
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
Continued incorrect rpath fixups for libraries symlinked into $PREFIX/lib
#5198
Comments
@mbargull would be interested in your thoughts here as you wrestled with this code path recently. How might we make this better? |
I'd assume |
conda-forge/cuda-feedstock#10 ( and conda-forge/cuda-nvtx-feedstock#2 ) has background where incorrect system libraries are loaded due to bad RPATH fixup caused by this issue.
Unforunately not.
As we can see on the last line the Now if we go into
|
Thanks for the details. We can condense this to a self-contained test like so: #> mkdir ./bin ./lib ./lib/sub
#> printf %s 'int status() { return 0; }' |
#> ${CC} -x c - -s -shared -nostdlib -o ./lib/libstatus.so
#> printf %s 'extern int status(); int call() { return status(); }' |
#> ${CC} -x c - -s -shared -nostdlib '-Wl,-rpath,$ORIGIN/..' -L./lib -lstatus -o ./lib/sub/libcall.so
#> ln -rs ./lib/sub/libcall.so ./lib/
#> printf %s 'extern int call(); int main() { return call(); }' |
#> ${CC} -x c - -s '-Wl,-rpath,$ORIGIN/../lib' -L./lib -lcall -o ./bin/run
#> ./bin/run && echo ok || echo fail
ok
#> LD_TRACE_LOADED_OBJECTS=1 ./bin/run
linux-vdso.so.1 => (0x00007fff4f1de000)
libcall.so => /home/conda/work/bin/../lib/libcall.so (0x00007f36b977e000)
libc.so.6 => /lib64/libc.so.6 (0x00007f36b9000000)
libstatus.so => /home/conda/work/bin/../lib/libstatus.so (0x00007f36b9776000)
/lib64/ld-linux-x86-64.so.2 (0x00007f36b9400000)
#> printf %s 'int status() { return 1; }' |
#> ${CC} -x c - -s -shared -nostdlib -o ./libstatus.so
#> ./bin/run && echo ok || echo fail
fail
#> LD_TRACE_LOADED_OBJECTS=1 ./bin/run
linux-vdso.so.1 => (0x00007fff73364000)
libcall.so => /home/conda/work/bin/../lib/libcall.so (0x00007f741a081000)
libc.so.6 => /lib64/libc.so.6 (0x00007f7419a00000)
libstatus.so => /home/conda/work/bin/../lib/../libstatus.so (0x00007f741a079000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7419e00000) It would make sense to put in some post processing check for symlinks to libraries and at least warn the user with a message suggesting how to alleviate potential issues, e.g., switch binary and symlink location to have a rpaths go down instead of up in the filesystem or keep the absolute path (i.e., skip binary relocation). |
@mbargull I agree with this! That kind of diagnostic have ensured we avoided issues, and would help in making sure we ( and other packages ) don't generate bad RPATH entries. |
Checklist
What happened?
Extension of #5179 and #5181
The computed RPATH entires that conda-build generates always uses the concrete library, and not what ever representation that exists in
$PREFIX/lib
. This is important as$ORIGIN
is evaluated without going through symlinks.So if you have
$PREFIX/lib/library.so
which symlinks to$PREFIX/lib/nested/deeply/library.so
you will compute an RPATH entry of$ORIGIN/../../
. When$PREFIX/lib/library.so
is loaded it will now search for libraries outside the conda env. With extra manipulation and some luck, you can craft aRPATH
entries that will load items from the users/lib
( mainly libgcc_s.so )Here is a conda-build test based offf of
_rpath_symlink
that showcases the problem ( https://github.com/robertmaynard/conda-build/tree/add_cuda_toolkit_layout_symlink_test ):I believe that the correct approach to rpath fixup on linux is that we expect the loading of libraries to always occur from
$PREFIX/lib
. So in that case we need something like a two pass approach:$PREFIX/lib
to a RPATH entry of$ORIGIN
. We record the fully resolved paths of each of these librariesConda Info
No response
Conda Config
No response
Conda list
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: