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
autoPatchelfHook: Use alternative interpreters in multilib envs #51588
Conversation
pkgs/top-level/all-packages.nix
Outdated
substitutions = rec { | ||
ld = "${stdenv.cc}/nix-support/dynamic-linker"; | ||
ld32 = if stdenv.hostPlatform.is32bit then ld | ||
else "${stdenv_32bit.cc}/nix-support/dynamic-linker-m32"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A shortcut in stdenv.cc.bintools
(like the existing dynamicLinker
) would remove the reliance on this output, as it's probably only supported for GCC libc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR, this is something I missed when writing the implementation in the first place.
However, as pointed out in my comments, I don't like the approach of hardcoding of the various stdenv variants into the shell hook as it makes certain assumptions on the architectures in use.
c1f5eff
to
d020c62
Compare
@aszlig This has been redone with your suggestions in mind; namely, searching through interpreters in Thank you for the help! |
Are there any updates on this pull request, please? |
This pull request has been mentioned on Nix community. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review-may-2019/3032/41 |
Thank you for your contributions.
|
@tadfisher: Damn, I'm sorry for not getting back to you. Was swamped in notifications and only recently (a few months ago) overhauled the notification settings. Apparently the branch had merge conflicts, so if you still want to get this in, can you please rebase and reopen? (and yes, this time I should get the notifications, sorry again...) |
Motivation for this change
autoPatchelfHook
correctly restricts the architecture of libraries patched into RPATH, but it does not check that the correct dynamic linker is used for INTERP; instead, it always applies the host's native dynamic linker. This can result in 32-bit binaries usingld-linux-x86-64.so.2
on x86-64 systems, for example.This change passes in both the native and 32-bit linkers for the host platform (note that these can be the same depending on the platform).autoPatchelfFile
then applies the 32-bit linker for ELF32 files, and the native linker otherwise.This change searches for interpreters in
$NIX_CC/nix-support
that support the architecture of the patched binary. When building in a multilib stdenv, only a matching interpreter will be patched, otherwise the build fails (with an appropriate error message).Mixed 32- and 64-bit binaries can now be patched automatically by
autoPatchelfHook
with no manual fixup needed. I tested existing packages (which are not mixed) usingnox-review
on an x86-64 machine, and also by buildingnixpkgs.pkgsi686Linux.<pkg>
for the smattering of packages using this hook that build on i686 natively.cc @aszlig
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)