feat: reduce calls to patchelf - #704
Conversation
patchelf is called multiple times to update soname, remove/replace needed, update RPATH. This can be done in a single command line call allowing for faster patching and reducing the chance of running into a patchelf issue with multiple updates to a single ELF file.
There was a problem hiding this comment.
Pull request overview
This PR refactors ELF patching so multiple modifications (SONAME, DT_NEEDED changes, RPATH updates) can be applied with fewer patchelf invocations, reducing repair time and minimizing repeated writes to the same ELF.
Changes:
- Introduces
ElfPatcherstate tracking (ElfUpdateInfo) and a batchedPatchelf.apply_updates()implementation. - Updates wheel repair flow to queue edits and apply them once at the end, including handling script-to-shim moves via
update_elf_path. - Adjusts unit tests to validate queued-update behavior instead of asserting multiple subprocess calls.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
tests/unit/test_repair.py |
Reworks RPATH-append tests to validate queued state in ElfPatcher rather than mocking subprocess calls. |
tests/unit/test_elfpatcher.py |
Adds overlap-validation tests for queued DT_NEEDED changes; updates Patchelf invocation expectations to match batching. |
src/auditwheel/repair.py |
Queues patch operations during repair and applies them once; updates update tracking when ELF scripts are moved. |
src/auditwheel/patcher.py |
Adds queued-update infrastructure and implements batched patchelf execution via apply_updates(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
This PR comes from the investigation regarding the use lief-patchelf in #664 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #704 +/- ##
==========================================
+ Coverage 95.74% 95.91% +0.16%
==========================================
Files 23 23
Lines 1928 1981 +53
Branches 361 374 +13
==========================================
+ Hits 1846 1900 +54
Misses 46 46
+ Partials 36 35 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
patchelf is called multiple times to update soname, remove/replace needed, update RPATH.
This can be done in a single command line call allowing for faster patching and reducing the chance of running into a patchelf issue with multiple updates to a single ELF file.