This reduces the surface area of our `Kernel` monkeypatch and removes
the need to `include Kernel` in a bunch of modules.
While we're here, also move `Kernel#require?` to `Homebrew` and fully
scope the calls to it.
We removed this exclusion in #20423 because it broke pouring of existing
bottles, which still need relocation.
Let's skip relocation only when bottling, to avoid breaking existing
bottles that need to be relocated when pouring.
This needs to be handled more carefully. It probably works fine for
bottles built *after* this change was added, but it breaks bottles built
before this exclusion was added.
Let's remove it for now to limit the extent of the breakage.
We have multiple formulae (e.g. `ola`, `openvino`, `opencv`, `or-tools`,
`pytorch`) that seem to be broken by `patchelf.rb` on x86_64 Linux.[^1] The
common thread seems to be the presence of a `protodesc_cold` section in
the ELF header.
Let's avoid breaking these bottles by skipping relocation when a binary
file has a `protodesc_cold` section. It will probably hurt
relocatability of these bottles, but that's better shipping broken
binaries.
[^1]: https://github.com/Homebrew/homebrew-core/pull/210860#issue-2918569212
Fixes#18556 by using RUSTC_WRAPPER instead of setting RUSTFLAGS directly.
This allows Homebrew's optimization flags to coexist with .cargo/config.toml
settings, preventing build failures when projects have their own Rust
configuration.
- Add rustc_wrapper shim that clears RUSTFLAGS and prepends HOMEBREW_RUSTFLAGS
- Update both std and super environments to use RUSTC_WRAPPER
- Store Homebrew's rustflags in HOMEBREW_RUSTFLAGS instead of RUSTFLAGS
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Carlo Cabrera <github@carlo.cab>
`ensure_formula_installed!` requires the `Formula` class to be loaded
before being called to work properly.
Let's guarantee that instead by implementing it as an instance method of
the `Formula` class.
See discussion at #20358.
This does the same as #20356 for `ensure_formula_installed!`. See
discussion at #20352.
Unfortunately, one must still `require "formula"` before using this
method because of the `returns(Formula)`, but tightening the type
signature is generally a good idea anyway.
Closes#20352.
Allowing either `Formula`e or `String`s in these methods leads to errors
at runtime when one hasn't done `require "formula"` yet.
Let's tighten these up so that they only accept `Formula` arguments to
guarantee that `require "formula"` has been done before they are called.
For callers that need to pass a `String`, we update them to call a
version of these methods that accepts only `String`s.
See discussion at #20352.