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

meson: Fix rpath clearing #95179

Merged
merged 1 commit into from Aug 11, 2020
Merged

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Aug 11, 2020

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 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.

Closes: #95163

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tried building systemd with this patch and readelf -x .dynstr result-lib/lib/libudev.so seems to be ␀-ed out properly
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

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.
@jtojnar
Copy link
Contributor Author

jtojnar commented Aug 11, 2020

Do we target staging or master?

@Mic92
Copy link
Member

Mic92 commented Aug 11, 2020

Good question, its a channel blocker after all. So I would vote for master; @FRidh

@FRidh FRidh changed the base branch from master to staging-next August 11, 2020 15:46
@FRidh
Copy link
Member

FRidh commented Aug 11, 2020

Good question indeed. I didn't create a new staging-next yet so we can just use that.

@FRidh FRidh merged commit e8bfa70 into NixOS:staging-next Aug 11, 2020
Meson breakages automation moved this from To Do to Done Aug 11, 2020
@jtojnar jtojnar deleted the meson-clear-rpath branch August 11, 2020 15:49
@adisbladis
Copy link
Member

adisbladis commented Aug 12, 2020

Cherry-picked to master in 74ea2b2 as this was blocking channels.

Checked with other nixpkgs maintainers in #nixos-dev before cherry-picking.

@FRidh
Copy link
Member

FRidh commented Aug 12, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

meson bug: initrd currently doesn't build, blocking channels
4 participants