-
-
Notifications
You must be signed in to change notification settings - Fork 15.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
rewrite autoPatchelfHook in python #149731
Conversation
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 a lot for the effort! This btw. would probably also make it less ugly to use it standalone, extend it or even move it out of tree one day.
I added a few comments here and there, some of them are rather nit-picky and opinionated so feel free to ignore them.
Speaking of nit-picky: I'd also generally prefer to be in line with PEP-8, eg. using snake case instead of camelCase names for functions and variables. The reason is that it's more consistent with other Python code in nixpkgs and also matches that of most Python FOSS libraries out there.
Most of the comments also assume the use of pathlib.Path
and I also usually tend use type annotations.
Anyway, as mentioned, these are just personal opinions.
If it comes to functionality: Have you actually tested this against software using autoPatchelfHook
and checked whether it produces different results? Especially when it comes to androidenv
, since the latter uses some of the provided shell functions we had so far.
I fail to properly test this on androidenv. Accessing the 25.* tools version is not trivial. nix-review is funny: "1059 packages updated" |
Most reverse deps failed to build
Report |
@Artturin yes, fixed, thanks. I used a generator that kept a reference to a stream that was closed before the actual use of the generator. A this stage I am quite confident that we are reaching the end of WIP. nix-review manages to build everything, except for some rare cases like discordchatexporter-cli which fails now because I am more eager at finding the interpreter file. It did not fail before because the package contains no path to fix. I kept the failure as I think we should not litter the code with autoPatchelfHooks. That is also why I added a warning when nothing was patched. I would like to make it an error, but there are surprisingly quite a few packages that use autoPatchelfHook with nothing to patch. I think most of these use cases are invalid, but there are some valid corner cases. |
@aszlig, @Artturin Would you mind giving this one a second pass ? I think it matured well enough. At least it builds a lot a lot of things correctly in nix-review. Attention points:
|
P.S. I am not against type annotations, but I did not manage to get |
And another fix 🎉. Does this ever end ? |
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.
Mostly nitpicks from me, however I'm adding @svanderburg to the reviewers since he's built something similar for patching the Android SDK back then, which is why autoPatchelfHook
can be used in a standalone way in order to support that use case. Since I'm not familiar with Android SDK packaging in nixpkgs, he's a better canidate for making sure that it still works after we merge this very pull request.
See also his blog post, particularly the Follow up
section.
For maximum performance it would be cool if patching the individual files would be handled by a thread pool or process pool. But I am happy to do this in a follow up PR. |
If we do run into issues with say the sdk and it is not easily fixable we can always revert. |
Thanks everyone for the review process. It has been a pleasant experience. |
After being rewritten in NixOS#149731, this hook can fail on Mach-O binaries. Since patching ELF files on Darwin doesn't make much sense anyway, we'll mark this as Linux-exclusive.
With the re-implementation in Python merged[1], it no longer makes sense for me to track issues and pull requests. I did this originally because people were forgetting (rightfully so) to run tests against all that proprietary stuff we have in nixpkgs that is using autoPatchelfHook. We still can't test these automatically but with me no longer being the author of the code, I hereby drop my entry in CODEOWNERS and instead replace it with layus, who's the author of the rewrite. [1]: #149731 Signed-off-by: aszlig <aszlig@nix.build>
Motivation for this change
Fixes #148547
Things done
Reimplemented autoPatchelfHook in python for readability, proper cache dicts and speed!
/cc @aszlig sorry for pinging twice in a row. I would really appreciate your feedback on the implementation. For now it resides in a separate hook for ease of testing. It should replace the old one before merge.
In particular, the logic is now more clear, but maybe not the right one. And addAutoPatchelfSearchPath semantincs is broken, but works with all nixpkgs examples.