Skip to content
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 the executables' RUNPATH relative instead of absolute #996

Closed
sschuberth opened this issue Nov 13, 2023 · 4 comments
Closed

Make the executables' RUNPATH relative instead of absolute #996

sschuberth opened this issue Nov 13, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@sschuberth
Copy link

Executables created by rtx seem to set the ELF's RUNPATH to an absolute path inside $RTX_DATA_DIR/installs, see e.g.

$ readelf -d ~/.local/share/rtx/installs/python/3.11.3/bin/python3.11

Dynamic section at offset 0x2dd8 contains 27 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libpython3.11.so.1.0]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000001d (RUNPATH)            Library runpath: [/home/sebastian/.local/share/rtx/installs/python/3.11.3/lib]

This hurts relocating e.g. ~/.local/share/rtx/installs/python to somewhere else as SO files would not be found anymore, also see #512.

To solve this, could RUNPATH be set to a relative path instead?

@sschuberth sschuberth added the enhancement New feature or request label Nov 13, 2023
@jdx
Copy link
Owner

jdx commented Nov 13, 2023

rtx does not create python runtimes. That is done by python-build.

@sschuberth
Copy link
Author

The same issue occurs e.g. with ruby, which is an rtx core plugin, or?

Anyway, instead of reaching out to each individual plugin authors, maybe rtx could do some post-processing on ELFs to consistently patch them to use relative RUNPATHs?

@jdx
Copy link
Owner

jdx commented Nov 14, 2023

for ruby the issue is inside of ruby-build, not the core plugin

@sschuberth
Copy link
Author

FYI, this is the post-processing I'm now doing:

# Patch the RUNPATH to be relative in order to make relocated executables work.
find ~/.local/share/rtx/installs -type f -executable -exec sh -c 'file $1 | grep -q " ELF "' sh {} \; -print \
    | xargs patchelf --set-rpath '$ORIGIN'/../lib

This works better than expected, so I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants