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
meson: Fix rpath clearing #95179
meson: Fix rpath clearing #95179
Conversation
Meson allows projects to set `build_rpath` property, containing paths that will be added during build but will be removed when installing. When Meson removes build_rpath from `DT_RUNPATH` entry, it just writes the shorter ␀-terminated new rpath over the old one to reduce the risk of potentially breaking the ELF files (when the linker does string de-duplication or something). But this can cause much bigger problem for Nix, as it can produce cut-in-half-by-␀ store path references. For example, in systemd’s libudev, it was removing three `$ORIGIN`-relative paths from $ORIGIN/../libsystemd:$ORIGIN/../basic:$ORIGIN/../shared:…␀ resulting in the following `DT_RUNPATH` entry: …␀store/v589pqjhvxrj73g3r0xb41yr84z5pwb7-gcc-9.3.0-lib/lib␀ We previously handled this in `fix-rpath.patch` but the method we prevent Meson from removing paths added to rpath through `NIX_LDFLAGS` was changed during 0.55.0 update and I forgot about this second purpose of the patch. Let’s re-add this clearing code, as it worked without issues for a long time.
Do we target staging or master? |
Good question, its a channel blocker after all. So I would vote for master; @FRidh |
Good question indeed. I didn't create a new staging-next yet so we can just use that. |
Cherry-picked to master in 74ea2b2 as this was blocking channels. Checked with other nixpkgs maintainers in |
Good! Hydra is almost done rebuilding anyway. To clarify why I put it in staging-next. Critical fixes can go directly to master, although that of course means during a day or so people will have to build a lot themselves so if its not critical its not preferred. In this case, staging-next was inactive (it was just merged into master, hence the failure), so pushing it there allows Hydra to build everything without affecting master users. |
Motivation for this change
Meson allows projects to set
build_rpath
property, containing paths that will be added during build but will be removed when installing.When Meson removes build_rpath from
DT_RUNPATH
entry, it just writes the shorter ␀-terminated new rpath over the old one to reduce the risk of potentially breaking the ELF files (when the linker does string de-duplication or something). But this can cause much bigger problem for Nix, as it can produce cut-in-half-by-␀ store path references.For example, in systemd’s libudev, it was removing three
$ORIGIN
-relative paths fromresulting in the following
DT_RUNPATH
entry:We previously handled this in
fix-rpath.patch
but the method we prevent Meson from removing paths added to rpath throughNIX_LDFLAGS
was changed during 0.55.0 update and I forgot about this second purpose of the patch.Let’s re-add this clearing code, as it worked without issues for a long time.
Closes: #95163
Things done
sandbox
innix.conf
on non-NixOS linux)systemd
with this patch andreadelf -x .dynstr result-lib/lib/libudev.so
seems to be ␀-ed out properlynix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)