110 Commits

Author SHA1 Message Date
Michael Cho
5fb96d9d8a
shims/super/cc: rpath-link glibc if indirect dep
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.
2025-09-03 22:08:10 -04:00
Douglas Eichelberger
240fd71e6f
Avoid repeated calls to affix checks 2025-08-31 11:11:41 -07:00
Ruoyu Zhong
40da6c1e16
formula: improve variable naming
`log_filename` sounds better than `logfn`.
2025-08-13 14:27:04 +08:00
Ruoyu Zhong
6f3f2d7317
formula: improve log filename handling
Fixes 718b82560a (commitcomment-163850325).
2025-08-12 22:46:41 +08:00
Carlo Cabrera
b89d4ef633
shims/super/rustc_wrapper: fix comment
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.
2025-08-12 14:15:14 +08:00
Carlo Cabrera
63a8fd7a4a
rustc_wrapper: pass HOMEBREW_RUSTFLAGS last
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.
2025-08-12 00:46:05 +08:00
Carlo Cabrera
718b82560a
formula: append .log to formula build log filenames
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.
2025-08-11 13:10:14 +08:00
Mike McQuaid
e6ba71c5b1
Add rustc wrapper shim to fix RUSTFLAGS conflicts
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>
2025-08-06 17:06:25 +01:00
Eric Knibbe
626b6aca2d
RubyDoc output fixes 2025-08-05 17:13:42 -04:00
Francois-Xavier Coudert
10095f5cac compilers: add gcc-15 2025-04-23 10:09:45 +02:00
Carlo Cabrera
ec8f3033e0
shims/super/cc: add comment for optimisation flag handling
Follow up to #19551
2025-03-20 23:19:31 +08:00
Carlo Cabrera
351f7f82f3
shims/super/cc: tweak optimisation flag handling for runtime CPU detection builds
Let's reinstate adding our own optimisation flags if the compiler
was not invoked with a conflicting optimisation flag.
2025-03-20 15:42:50 +08:00
Bo Anderson
6fed6c10e2
Use PAC+BTI where possible on arm64 Linux 2025-03-18 06:14:16 +00:00
Ruoyu Zhong
a818b25a8b
Add support for bottling Portable Ruby for ARM64 Linux 2025-01-19 17:06:32 +08:00
Caleb Xu
1ec8a0488f
shims/super/cc: handle double dash in args 2025-01-12 14:49:10 -05:00
Mike McQuaid
c31b232be9
Homebrew/shims: remove *llvm-g* shims.
They are no longer ever used.
2024-09-30 08:43:57 +01:00
Michael Cho
6020744699
shims/super/cc: remove leftover usage of llvm-g++-4.2 2024-09-29 11:41:50 -04:00
Carlo Cabrera
25afdcc2b8
shims/super/cc: add modeline for vim-like editors
This will prevent my editor from trying to read this file as shell
script and getting the syntax highlighting all wrong.
2024-09-29 05:47:05 +08:00
Michael Cho
7dac30a105
compilers: drop support for GCC 4.9, 5 and 6 2024-09-24 18:56:12 -04:00
Bo Anderson
0820c19417
shims/super/cc: don't strip prefixes with --debug-symbols 2024-09-15 19:07:12 +01:00
Carlo Cabrera
f3d1dd165d
shims/super/cc: fix linker flag parsing
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.
2024-09-11 22:53:04 +08:00
Carlo Cabrera
66ba1f10c7
shims/super/ninja: respect Homebrew parallelism
`ninja` currently doesn't respect `HOMEBREW_MAKE_JOBS` or
`ENV.deparallelize`. This change fixes that.
2024-09-09 10:50:52 +08:00
Francois-Xavier Coudert
e0b4ec4eed shims/super/cc: do not pass -pipe 2024-09-02 23:17:21 +02:00
Ruoyu Zhong
0b3b7d9bc3
shims/super/cc: only set HOMEBREW_LD_LIBRARY_PATH when needed
Co-authored-by: Bo Anderson <mail@boanderson.me>
2024-08-26 00:39:27 +08:00
Ruoyu Zhong
fb57604fe2
shims/super/cc: preserve LD_LIBRARY_PATH
This could be used by the linker [^1] so let's preserve it before
invoking the compiler/linker.

[^1]: https://sourceware.org/binutils/docs/ld/Options.html
2024-08-26 00:18:15 +08:00
Ruoyu Zhong
86de678086
shims/super/cc: unset LD_LIBRARY_PATH
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.
2024-08-25 23:50:13 +08:00
Michael Cho
0477944e71
shims/super/cc: pass -ld_classic if needed for -dead_strip_dylibs 2024-08-03 14:46:18 -04:00
Francois-Xavier Coudert
fbf7e5f069 compilers: add gcc-14 2024-05-02 09:40:09 +02:00
Carlo Cabrera
c3c61767c7
shims/super/cc: avoid passing -oso_prefix during configure
Fixes `configure` failures in Homebrew/homebrew-core#169893.
2024-04-28 12:42:04 +08:00
Bo Anderson
5582849ae7
Reproducible builds for native compiled binaries 2024-03-11 16:06:55 +00:00
Francois-Xavier Coudert
6067acfd7c compilers: add gcc-13 2023-04-19 11:18:18 +02:00
Carlo Cabrera
999582f412
Fix typo 2023-03-07 23:34:57 +08:00
Carlo Cabrera
c4fe6e7617
Incoroporate feedback from code review
- 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.
2023-03-05 16:55:00 +08:00
Carlo Cabrera
1b12d74945
Pass -no_fixup_chains to linker when required
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-notes
https://www.wwdcnotes.com/notes/wwdc22/110362/
https://www.emergetools.com/blog/posts/iOS15LaunchTime
https://github.com/python/cpython/issues/97524
https://github.com/pybind/pybind11/pull/4301
2023-03-04 00:19:13 +08:00
Bo Anderson
5445bf8f39
shims/super/cc: unset RUBYLIB 2022-11-30 03:50:38 +00:00
Lukas Oberhuber
3d60d610dd Merge branch 'master' into debug-symbols 2022-08-10 18:44:09 -10:00
Lukas Oberhuber
74dd365a56 Hardcoded symbol production
Needs to be toggled by the `--debug-symbols` flag instead of hard coded
2022-07-26 12:13:38 +01:00
Lukas Oberhuber
e1ea9da507 Conceptual draft of dsym support for macos 2022-07-26 00:00:45 +01:00
danielnachun
7a247fd52d
shims/super/cc: add -nostdinc in cppflags 2022-07-20 11:08:43 -07:00
danielnachun
6ab6382518
shims/super/cc: add nostdinc and rpath-link when using glibc@2.13 2022-07-17 17:15:06 -07:00
EricFromCanada
7c7d7a54c6
superenv: avoid adding blank --isysroot flag 2022-06-01 13:58:14 -04:00
Francois-Xavier Coudert
a30e27b403 compilers: add gcc-12 2022-04-30 22:05:35 +02:00
Bo Anderson
d23de6c54c
shims: enable cc arg refurbishment for ninja 2022-03-14 17:05:22 +00:00
Bo Anderson
30b24cf4ad
Use HOMEBREW_CURL universally, including formulae 2021-10-04 02:03:04 +01:00
Dawid Dziurla
701904ad5c
shims/super/cc: run in bash shell 2021-09-17 22:13:43 +02:00
XuehaiPan
c2d5d84b21 Merge remote-tracking branch 'upstream/master' into fix-inconsistent-shell-style 2021-09-16 01:01:49 +08:00
XuehaiPan
3f96d963f7 style: fix inconsistent code style for shell scripts 2021-09-15 14:59:01 +08:00
Bo Anderson
0eba5b29e9
shims/super: shim swiftc 2021-09-15 03:28:31 +01:00
Bo Anderson
414935fb39
shims: enforce usage of Swift-bundled Clang on Linux
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-09-15 03:25:12 +01:00
Carlo Cabrera
0404da7ba7
superenv: handle formulae with runtime CPU detection
Some formulae are able to detect the features of the runtime CPU, and
execute code accordingly. This typically entails 1) the detection of
features of the build-time CPU in order to determine the targets that
the compiler can generate code for, and 2) generating code for the
targets that the compiler can support.

Our filtering of optimization flags can cause misdetection of compiler
features, leading to failed builds [1], and miscompilation even when the
build does not fail [2].

Let's try to fix this by allowing formulae to declare
`ENV.runtime_cpu_detection` which skips the filtering of `-march` and
related flags.

I've also skipped the filtering of the optimisation
level, since it seems to me that if upstream maintainers have gone to
the lengths of writing code that detects runtime hardware, they probably
also know better about appropriate `-O` flags to use.

This is a partial list of formulae that should make use of this feature:
1. apache-arrow
2. fftw
3. gromacs
4. open-mpi
5. openblas

Partially resolves Homebrew/homebrew-core#76537.

[1] open-mpi/ompi#8306 and linked issues/PRs
[2] Homebrew/homebrew-core#76537
2021-07-01 16:24:38 +01:00