autoPatchelfHook: fix detection under crossSystem#137351
autoPatchelfHook: fix detection under crossSystem#137351symphorien merged 1 commit intoNixOS:masterfrom
Conversation
There was a problem hiding this comment.
I don't think this change is doing the right thing because the library path isn't evaluated yet. I'll take another pass at this.
There was a problem hiding this comment.
according to man ldd ldd prints all recursive dependencies of the executable while readelf/objdump only print direct dependencies, so that looks like a regression.
There was a problem hiding this comment.
OK, I think I've addressed both of these now. Let me know what you think!
|
Result of 50 packages marked as broken and skipped:
51 packages failed to build:
479 packages skipped due to time constraints:
Note that build failures may predate this PR, and could be nondeterministic or hardware dependent. |
fd5670a to
77afa34
Compare
77afa34 to
61733d1
Compare
In NixOS#84415, autoPatchelfHook was taught to use the correct path to the readelf binary when a crossSystem is specified. Unfortunately, the remainder of the functionality in the script depended on ldd, which only reads ELF files of its own architecture. It has the further unfortunate quality of not reporting any useful error, but rather that the file is not a dynamic executable. This change uses patchelf to directly analyze the DT_NEEDED tags in the target files instead, which correctly works across architectures. It also updates the use of objdump to be prefix-aware $OBJDUMP (which would have been required in the PR mentioned above, but we never made it that far into the script execution).
61733d1 to
b79483d
Compare
symphorien
left a comment
There was a problem hiding this comment.
could build julia_16-bin natively and cross to aarch64. native julia passes its tests, cross julia can run --version in qemu.
|
Just to let you know, I have a few more fixes I'll put into a follow-up PR (I rented a big ol' AWS instance and manually reviewed all of the output of |
|
That PR is #137886, for future onlookers! |
Motivation for this change
In #84415, autoPatchelfHook was taught to use the correct path to the
readelfbinary when acrossSystemis specified. Unfortunately, the remainder of the functionality in the script depended onldd, which only reads ELF files of its own architecture. It has the further unfortunate quality of not reporting any useful error, but rather that the file is not a dynamic executable.This change uses
patchelfto directly analyze theDT_NEEDEDtags in the target files instead, which correctly works across architectures. It also updates the use ofobjdumpto be prefix-aware$OBJDUMP(which would have been required in the PR mentioned above, but we never made it that far into the script execution).Here is an example of a package that can now be properly cross-patched (?, not sure what the terminology for this is):
This binary runs correctly even under aarch64 on the Raspberry Pi when built.
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)