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
binutils: Enable new dtags in a way that works with binutils 2.30. #43531
Conversation
cc @Ericson2314 |
I haven't looked into this but
|
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.
Great work! Agreed re test.
Something I didn't really do, but should probably be done, is to make sure the other patches aren't also broken. I wonder if checking patch validity is something that can be generalized in nixpkgs. |
I'm confused. I wrote a test:
and it seems to work as expected even without this patch. |
If you |
In the final binary it is:
But right after compiling it is:
I suppose the |
Interesting. That could explain the inconsistency I was seeing. Particularly, if I built my http://github.com/rotaerk/vulkanTest project with nix-build, the resulting binary contained RUNPATH, and ran fine. But if I built it using This ultimately was made to work without my binutils patch (leaving the RPATH in place) just by switching NixOS to nixos-unstable-small. I believe this is because it brought the OpenGL driver provided by NixOS up to a version that was in sync with the one in my targeted nixpkgs. But the issue with binutils still stands, regardless, and was a convenient accidental discovery. |
Yes, makes sense. I double-checked patchelf documentation and it indeed states:
The patch looks fine but it could use a commit message (including this new patchelf discovery). |
How about this for a commit message? (I'll change the commit after it's looked over.)
|
Yes, sounds good. |
In 3027bca, binutils was upgraded from 2.28.1 to 2.30. However, in 2.30, the ldmain.c file within binutils, which the nixpkgs new-dtags.patch file is meant to modify, was changed in such a way that the patch no longer works. As a result, the new dtags are not actually enabled, and binaries are built with RPATH set instead of RUNPATH, thereby preventing LD_LIBRARY_PATH from overriding this built-in path. This change corrects this. The patch file is no longer necessary because binutils's ldmain.c now sets link_info.new_dtags based on the configuration flags. This was probably not noticed immediately because, when the derivation is built with nix-build, the fixupPhase runs patchelf --shrink-rpath. patchelf converts any RPATH in the binary into RUNPATH (unless --force-rpath is specified). Of course, if the binary is built without nix-build (such as in a nix-shell), this never occurs, and any RPATH in the binary is left in place.
1becfe5
to
b06b01f
Compare
The latest binutils upgrade silently broke this until it was fixed by NixOS#43531. So add a test.
#44301 adds a test. |
The latest binutils upgrade silently broke this until it was fixed by NixOS#43531. So add a test.
Motivation for this change
In 3027bca, binutils was upgraded from 2.28.1 to 2.30. However, in 2.30, the ldmain.c file within binutils, which the nixpkgs new-dtags.patch file is meant to modify, was changed in such a way that the patch no longer works. As a result, the new dtags are not actually enabled, and binaries are built with RPATH set instead of RUNPATH, thereby preventing LD_LIBRARY_PATH from overriding this built-in path. This change corrects this. The patch file is no longer necessary because binutils's ldmain.c now sets
link_info.new_dtags
based on the configuration flags.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)