-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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: fix detection under crossSystem #137351
Conversation
} | ||
|
||
populateCacheWithRecursiveDeps() { | ||
local so found foundso | ||
for so in "${autoPatchelfCachedDeps[@]}"; do | ||
for found in $(getDepsFromSo "$so"); do | ||
for found in $(getDepsFromElfBinary "$so"); 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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.
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
readelf
binary when acrossSystem
is 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
patchelf
to directly analyze theDT_NEEDED
tags in the target files instead, which correctly works across architectures. It also updates the use ofobjdump
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).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 = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)