Skip to content

shims/super/cc: Keep dependency -L flags ahead of superenv paths - #23821

Merged
p-linnane merged 1 commit into
mainfrom
homebrew-ruby-shims-super-cc-fix
Sep 6, 2026
Merged

p-linnane merged 1 commit into
mainfrom
homebrew-ruby-shims-super-cc-fix

Conversation

@krehel

@krehel krehel commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

the cc shim canonicalises -L arguments before deduplicating them against HOMEBREW_LIBRARY_PATHS, so an explicit -L for a keg-only dependency now matches the shim's own entry and is dropped. The shim then appends its own -L flags in dependency-declaration order, and the formula loses control of which directory the linker searches first.


  • 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 brew benchmark results.
  • 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?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Fable 5.1 with manual review and testing.


portable-ruby sets XLDFLAGS=-L<portable-libxcrypt>/lib to link libcrypt.a
statically, but glibc@2.13 is declared first and ships libcrypt.so.1. The
4.0.6_1 Linux bottles vendored by #23703 link it dynamically, so brew update
fails on Linux hosts without libcrypt.so.1 (e.g. Fedora):

`bin/ruby: error while loading shared libraries: libcrypt.so.1: cannot open shared object file`

Reproducing

Shipped bottle, on any host with Docker (or use macOS container):

docker run --rm fedora:44 bash -c 'curl -sL -H "Authorization: Bearer QQ==" https://ghcr.io/v2/homebrew/core/portable-ruby/blobs/sha256:b192f87e0d0596dd7bb2e7ef91e7bae323ec879b405e1b778ee8d14798208e0f | tar xz -C /tmp && /tmp/portable-ruby/4.0.6_1/bin/ruby --version'

arm64_linux: d0f04d327063be7ef72703c0e621eca33bc9bf388025d36671758ebac230364d

End to end on Fedora 44: brew install --build-from-source portable-ruby with
HOMEBREW_NO_INSTALL_FROM_API=1 produces a bin/ruby with no libcrypt
dependency. With the shim reverted, configure fails at cannot compute sizeof (long long) because its -lcrypt-linked test binary cannot load
libcrypt.so.1.

@krehel
krehel requested review from a team and a balanced review from Copilot September 5, 2026 21:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused implementation correctly preserves explicit linker ordering and includes regression coverage.

Pull request overview

Preserves formula-defined linker search precedence in the cc shim.

Changes:

  • Keeps explicit -L flags that overlap with superenv library paths.
  • Adds regression coverage for linker path ordering.
File summaries
File Description
Library/Homebrew/shims/super/cc Adjusts library-path deduplication.
Library/Homebrew/test/shims/super/cc_spec.rb Tests explicit path precedence.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread Library/Homebrew/shims/super/cc Resolved
the `cc` shim canonicalises `-L` arguments before deduplicating
them against `HOMEBREW_LIBRARY_PATHS`, so an explicit `-L` for a
keg-only dependency now matches the shim's own entry and is dropped.
The shim then appends its own `-L` flags in dependency-declaration
order, and the formula loses control of which directory the linker
searches first.
@krehel
krehel force-pushed the homebrew-ruby-shims-super-cc-fix branch from 828356d to d7b311f Compare September 5, 2026 22:43
@krehel krehel changed the title shims/super/cc: keep explicit -L flags ahead of superenv paths shims/super/cc: Keep dependency -L flags ahead of superenv paths Sep 5, 2026

@p-linnane p-linnane left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @krehel! I'll open a revision bump for Portable Ruby once this is merged.

@p-linnane
p-linnane added this pull request to the merge queue Sep 6, 2026
Merged via the queue into main with commit 29b882c Sep 6, 2026
52 checks passed
@p-linnane
p-linnane deleted the homebrew-ruby-shims-super-cc-fix branch September 6, 2026 00:35

@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.

Thanks!

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.

4 participants