To avoid missing symbols when mixing newer LLVM headers with older Apple
libc++, inject a __config_site that sets vendor availability annotations
to match system library.
This helps ld.bfd find the correct `glibc` dependency. Needed when using
host toolchain which will only search for /etc/ld.so.conf.
Also can help unsupported systems that force poured non-relocatable
`binutils` bottle.
In #20424, we moved `HOMEBREW_RUSTFLAGS` to the end of the compiler
invocation, but didn't update the comment. Let's fix that.
While we're here, let's fix these `shellcheck disable`s.
If we pass it first, it can be overridden by other arguments passed on
the command line. We don't want that.
See discussion at Homebrew/homebrew-core#232566.
Having log files with extensions like `.cc` and `.cmake` is really
unfriendly to editor syntax highlighters and language servers. Let's try
to make sure these are opened as log files by adding a `.log` extension
to them.
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>
Our parsing of linker flags can be easily confused by, e.g.,
-Wl,-undefined -Wl,dynamic_lookup,-dead_strip_dylibs
The current code that tries to detect these flags will erroneously
conclude that they were not passed.
This change fixes that.
A local `ruby` build failed while building extensions, with:
*** Following extensions are not compiled:
-test-/file:
Could not be configured. It will not be installed.
/tmp/ruby-20240824-893184-ehcnsa/ruby-3.3.4/lib/mkmf.rb:480: The compiler failed to generate an executable file.
You have to install development tools first.
Check ext/-test-/file/mkmf.log for more details.
-test-/symbol:
Could not be configured. It will not be installed.
/tmp/ruby-20240824-893184-ehcnsa/ruby-3.3.4/lib/mkmf.rb:480: The compiler failed to generate an executable file.
You have to install development tools first.
Check ext/-test-/symbol/mkmf.log for more details.
[...]
`mkmf.log` indicated that the compiler shim failed to load `pathname`:
LD_LIBRARY_PATH=.:../../.. "gcc-13 -o conftest -I../../../.ext/include/aarch64-linux -I../../.././include -I../../.././ext/-test-/file -I/home/linuxbrew/.linuxbrew/opt/libyaml/include -I/home/linuxbrew/.linuxbrew/opt/openssl@3/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wmisleading-indentation -Wundef -fPIC conftest.c -L. -L../../.. -L/home/linuxbrew/.linuxbrew/opt/libyaml/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/libyaml/lib -L/home/linuxbrew/.linuxbrew/opt/openssl@3/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/openssl@3/lib -L. -fstack-protector-strong -L/home/linuxbrew/.linuxbrew/opt/libyaml/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/libyaml/lib -L/home/linuxbrew/.linuxbrew/opt/openssl@3/lib -Wl,-rpath,/home/linuxbrew/.linuxbrew/opt/openssl@3/lib -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -Wl,-rpath,/home/linuxbrew/.linuxbrew/Cellar/ruby/3.3.4/lib -L/home/linuxbrew/.linuxbrew/Cellar/ruby/3.3.4/lib -lruby-static -lz -lrt -lrt -ldl -lcrypt -lm -lpthread -lm -lpthread -lc"
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super/gcc-13:12:in `require': cannot load such file -- pathname (LoadError)
from /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super/gcc-13:12:in `<main>'
I believe this was due to `../../..` in `LD_LIBRARY_PATH` containing
`libruby.so`, causing the Ruby script to load the being-built Ruby
library instead of the system/portable one.
We have a handful of formulae that use Homebrew `make` to build. Doing
this evades our compiler shims. Let's try to avoid this by allowing our
shims to support usage of Homebrew `make` by calling it as `gmake` in
the formula.
The `opencv@3` build calls `gmake`, which ends up evading our compiler
shim and results in a build failure because of a `-Werror` flag.
ClosesHomebrew/homebrew-core#132966.
- check the version of `/usr/bin/ld` for support of `-no_fixup_chains`
- check for usage of the `-fuse-ld` flag, since this flag is only
supported by Apple ld64
Also, call `no_fixup_chains` when setting up the build environment.
Invoking `ld` with `-undefined dynamic_lookup` emits a warning starting
Xcode 14:
ld: warning: -undefined dynamic_lookup may not work with chained fixups
Chained fixups is a linker optimisation that results in faster binary
load times, and is enabled by default starting Xcode 13 when the target
is macOS 12 or newer.
However, this interacts poorly with `-undefined dynamic_lookup`, and
Xcode will disable chained fixups when it is invoked with this flag
starting Xcode 14.3. Until then, we may be shipping binaries that are
broken in subtle ways, so let's disable chained fixups when necessary
instead.
I patterned the changes here after the handling of `-no_weak_imports`.
The only difference is that we need to check the flags that were passed
to the linker first to see if we do need to disable chained fixups.
For additional context, see:
https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-noteshttps://www.wwdcnotes.com/notes/wwdc22/110362/https://www.emergetools.com/blog/posts/iOS15LaunchTimehttps://github.com/python/cpython/issues/97524https://github.com/pybind/pybind11/pull/4301