Select the native architecture's dynamic linker on Linux - #23622
Open
p-linnane wants to merge 2 commits into
Open
Select the native architecture's dynamic linker on Linux#23622p-linnane wants to merge 2 commits into
p-linnane wants to merge 2 commits into
Conversation
Signed-off-by: Patrick Linnane <patrick@linnane.io>
Signed-off-by: Patrick Linnane <patrick@linnane.io>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Linux dynamic linker selection so Homebrew doesn’t accidentally choose a foreign-architecture loader (e.g., x86_64) on multi-arch systems where the native loader (e.g., arm64) is present, preventing broken execution of native binaries. It also hardens brew tests so OS-specific filtering can’t lead to “successful” runs where no specs actually execute.
Changes:
- Key
OS::Linux::Ld::DYNAMIC_LINKERSbyHardware::CPU.archand search only native-arch candidates insystem_ld_so. - Add/adjust Linux
Ldspecs to cover native-vs-foreign loader preference. - Update
brew teststo warn+return for--changedwhen OS filtering removes all tests, and to error for explicit invocations that result in no runnable tests; add corresponding unit tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Library/Homebrew/os/linux/ld.rb | Restricts dynamic linker discovery to native-architecture candidates. |
| Library/Homebrew/test/os/linux/ld_spec.rb | Updates/extends specs to validate native linker preference behavior. |
| Library/Homebrew/dev-cmd/tests.rb | Adds handling for OS-filtered empty test sets (warn for --changed, error otherwise). |
| Library/Homebrew/test/dev-cmd/tests_spec.rb | Adds coverage for brew tests behavior when OS filtering removes all runnable specs. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
krehel
approved these changes
Aug 22, 2026
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.
On ARM64 Linux with amd64 multi-arch libc installed,
OS::Linux::Ld.system_ld_soreturned the first executable path from a flat, cross-architecture list, so$HOMEBREW_PREFIX/lib/ld.sowas symlinked to/lib64/ld-linux-x86-64.so.2and ARM binaries stopped running. Reported in discussion #6179.DYNAMIC_LINKERSis now keyed byHardware::CPU.archand only the native architecture's candidates are searched, so a foreign loader can no longer be selected when the native one is missing.The second commit fixes something that surfaced while testing the first.
brew tests --changedcould select a spec that OS filtering then removed, leaving RSpec invoked with an empty file list and failingbrew lgtmon macOS.--changednow warns and returns, while every other invocation fails, including an explicit--onlyfor a spec the current OS filters out, rather than exiting green without running anything.brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Opus 5) drafted the implementation and tests; I reviewed the diff, verified the new tests fail without the fix and pass with it, and ran
brew lgtm --onlineplus targeted specs.