-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
[WIP] autoPatchelfHook: search a valid interpreter, or fail #66620
Conversation
Tests finished. It seems that this patch breaks a lot of tools based on autoPatchelfHook. For example
|
@aszlig Spacechem (openlab-aux/vuizvui#18) needs this to patch correclty the 32bit binary rgb2theora used for solution saves. |
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 the pull request :-)
However, besides the comments mentioned, I'm against introducing unnecessary complexity if there is not a really compelling reason to do so. For the Spacechem example you mentioned, can't you just use callPackage_i686
like this, because it seems that the game is 32bit only?
@@ -6,6 +6,8 @@ deployAndroidPackage { | |||
lib.optional (os == "linux") [ pkgs.glibc pkgs.zlib pkgs.ncurses5 pkgs_i686.glibc pkgs_i686.zlib pkgs_i686.ncurses5 ]; | |||
patchInstructions = '' | |||
${lib.optionalString (os == "linux") '' | |||
rm -r $packageBaseDir/{i686,aarch64,mipsel,arm}-linux* |
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.
Cc: @svanderburg
) | ||
|
||
echo "searching an '$(getSoArch "$toPatch")' interpreter for $toPatch" >&2 | ||
for f in "${linkers[@]}"; do |
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.
for f in "${linkers[@]}"; do | |
for interpreter in "${interpreters[@]}"; do |
patchElfInterpreter() { | ||
local toPatch=$1 | ||
local linkers=( \ | ||
"$NIX_CC/nix-support/dynamic-linker" \ |
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.
You don't need to use backslashes for continuations here, besides, why have autoPatchelfLinkers
and linkers
here again?
|
||
gatherLibraries() { | ||
autoPatchelfLibs+=("$1/lib") | ||
if [ -f "$1/nix-support/dynamic-linker" ]; then | ||
autoPatchelfLinkers+=("$1/nix-support/dynamic-linker") |
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.
autoPatchelfLinkers+=("$1/nix-support/dynamic-linker") | |
autoPatchelfLinkers+="$(< "$1/nix-support/dynamic-linker")" |
autoPatchelfLinkers+=("$1/nix-support/dynamic-linker") | ||
fi | ||
if [ -f "$1/nix-support/dynamic-linker-m32" ]; then | ||
autoPatchelfLinkers+=("$1/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.
autoPatchelfLinkers+=("$1/nix-support/dynamic-linker-m32") | |
autoPatchelfLinkers+="$(< "$1/nix-support/dynamic-linker-m32")" |
@@ -55,6 +55,10 @@ stdenv.mkDerivation rec { | |||
substitute usr/share/applications/bitwig-studio.desktop \ | |||
$out/share/applications/bitwig-studio.desktop \ | |||
--replace /usr/bin/bitwig-studio $out/bin/bitwig-studio | |||
|
|||
# We only support x86_64-linux anyway, | |||
# and these files cannot be correctly autoPatchelfHooked |
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.
Why can't they be correctly autoPatchelfHook
ed?
The compelling reason was that I needed it for #65069. Not sure if switching to 32bit would be enough. It seems that the canon capt drivers have both 32 and 64 bits binaries packaged. |
I'm curious if you tried the (somewhat simpler) patch in #51588? |
Not sure how much more simple it is. I did not test it, but the fact that it seemingly does not introduce issues in other packages either means that it is much better than mine, or was just not tested against nixpkgs. Using |
Thank you for your contributions.
|
I marked this as stale due to inactivity. → More info |
The hook is now python https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/auto-patchelf.py |
Motivation for this change
autoPachelfHook
patches everything with the same interpreter(
$NIX_CC/nix-support/dynamic-linker
) even on incompatible binaries.This happens in particular when building with
multiStdenv
.See https://discourse.nixos.org/t/binary-still-not-working-even-when-properly-patchelfed/1570/3?u=layus for details.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
Notify maintainers
cc @tadfisher