keg_relocate: skip running patchelf on bun binaries - #23589
Merged
Conversation
The `.bun` section needs to occur at a specific location. Upstream does support relocating interpreter (at least via NixOS/patchelf) but either patchelf.rb or RUNPATH relocation results in broken binary.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Linux keg relocation so that bottling (placeholder relocation) skips running patchelf on ELF binaries that are known to be corrupted by it (specifically those containing a .bun section), while also renaming the internal relocation keyword to be broader than the previous skip_protodesc_cold flag.
Changes:
- Rename the
relocate_dynamic_linkagekeyword fromskip_protodesc_cold:towith_placeholders:across Keg relocation implementations. - On Linux, skip RPATH/interpreter relocation (and thus avoid invoking
patchelf) for ELF files whose section list includesprotodesc_coldor.bunwhen doing placeholder relocation. - Update the placeholder-relocation call site to pass the new keyword.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Library/Homebrew/keg_relocate.rb | Renames the relocation keyword and updates the placeholder-relocation call site. |
| Library/Homebrew/extend/os/mac/keg_relocate.rb | Keeps macOS override signature in sync with the renamed keyword (no behavioral change). |
| Library/Homebrew/extend/os/linux/keg_relocate.rb | Adds the .bun-section skip (and refactors the skip flag) to avoid patchelf for affected binaries during bottling. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
carlocab
approved these changes
Aug 20, 2026
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
.bunsection needs to occur at a specific location. Upstream does support relocating interpreter (at least via NixOS/patchelf) but either patchelf.rb or RUNPATH relocation results in broken binary.Was originally going to handle with
skip_relocate_dynamic_linkage#22442As wanted to check if newer bun helped, but looks like relocation doesn't work in 1.4.0 even after
Should still be easy to check locally in future if a patchelf.rb upgrade helps by undoing this skip and running
brew install bun && brew bottle bun && brew test bun.Also want to get this in before
bundependents start propagating gzip hack.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?