Skip to content

Skip rewriting Mach-O binaries when delete_rpath changes nothing#23079

Merged
MikeMcQuaid merged 1 commit into
Homebrew:mainfrom
hyuraku:skip-rpath-write-when-unchanged
Jul 13, 2026
Merged

Skip rewriting Mach-O binaries when delete_rpath changes nothing#23079
MikeMcQuaid merged 1 commit into
Homebrew:mainfrom
hyuraku:skip-rpath-write-when-unchanged

Conversation

@hyuraku

@hyuraku hyuraku commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

MachOShim#delete_rpath always wrote the whole binary back to disk, even when there was no matching rpath to remove.
This change makes it return early when there is nothing to delete, so it no longer writes the file for a no-op. It now returns the deleted rpath, or nil when nothing was deleted, which matches how Array#delete and Hash#delete behave.
Keg#delete_rpath turns that value into a boolean, so the relocation step no longer codesigns files that were never modified. This resolves the TODO that asked to delay the write! call until we know we are changing the rpaths.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • AI was used to generate or assist with generating this PR.

AI (Claude Code) assisted in writing the code and tests.
I reviewed the change and ran brew lgtm locally

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea/catch!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Jul 13, 2026
Merged via the queue into Homebrew:main with commit 246fa1f Jul 13, 2026
41 checks passed
@hyuraku hyuraku deleted the skip-rpath-write-when-unchanged branch July 13, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants