56 Commits

Author SHA1 Message Date
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
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
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
Carlo Cabrera
863b412820
shims/super/cc: fix sysroot flag handling
The shim currently does not handle `--sysroot=` and `-isysroot=` flags
correctly. For example, the LLVM build passes `--sysroot=.`, and this is
incorrectly parsed by the shim.
2021-06-08 14:39:37 +01:00
Bo Anderson
71703add17
shims/super/cc: don't refurbish ld.gold args
This makes the behaviour consistent to regular BFD `ld`.
2021-03-29 01:42:41 +01:00
danielnachun
b2094065fb cc: prepend gcc libs to args when gcc is a dependency 2021-02-18 16:15:28 -08:00
danielnachun
c7f337177e cc: prepend gcc libs to args when gcc is a dependency 2021-02-15 12:12:18 -08:00
Seeker
b58571a90b shims/super/cc: add CXX_REGEX constant 2021-01-12 13:49:36 -08:00
Seeker
0f2ed88f9f shims/super/cc: require English 2021-01-12 13:49:33 -08:00
Seeker
1d576d2754 shims/super/cc: fix most style errors 2021-01-08 12:15:55 -08:00
Misty De Meo
2a33de7a10
superenv: filter out /usr/local on ARM if necessary 2021-01-04 20:57:16 -08:00
EricFromCanada
3768b7a6e9 apidoc: update comment wording, punctuation, formatting 2020-11-06 00:21:02 -05:00
Mike McQuaid
6f1970fd24
Fix more 10.x hardcodings. 2020-06-23 17:10:07 +01:00
Trung Le
378906862f Update cc shim 2020-05-01 01:31:57 +10:00
Bo Anderson
fb65d5a1f8 shims/super/cc: relax restrictions with -Xclang 2020-04-24 00:29:02 +01:00
Bo Anderson
61bac2595f shims/super/cc: allow -Werror=implicit-function-declaration 2020-04-15 11:10:25 +01:00
Bo Anderson
b4ff330ac1 shims/super/cc: remove isysroot space to fix cpp
Fixes #5153
2019-11-16 15:07:11 +00:00
Jonathan Chang
7ddc185b35 Fix various typos 2019-08-19 16:12:34 +10:00
Mike McQuaid
86f43f79ee
Enable/fix optional Ruby frozen string literal usage
Combined with https://github.com/Homebrew/homebrew-test-bot/pull/247
this will test Homebrew's use of frozen strings in CI. After this we
will then enable it for Homebrew developers and eventually all Homebrew
users.
2019-04-19 10:30:41 +09:00
Mike McQuaid
ef2e297d3b
Disable RubyGems by default.
This speeds up all Ruby invocations where we don't need RubyGems by
around 10%. Where we do need RubyGems: include it manually.
2019-04-18 17:45:03 +09:00
Win Treese
04cb8f2a78 Fix regexp to allow multiple digits in Mac OS minor version.
The regular expression check for the -mmacosx-version-min value only
looked at a single digit in the minor version number, so it did not
compare correctly if the option was setting the minimum version
to (say) 10.11.
2019-01-24 16:30:00 -05:00
FX Coudert
2c09c0e0f4 shims/super/cc: Do not remove -Xpreprocessor argument 2019-01-02 14:29:36 +01:00
Shaun Jackman
b40849421c shims/super/cc: Add HOMEBREW_CACHE to white list
Compiling rust projects requires -I$HOMEBREW_CACHE/cargo_cache/...
2018-12-10 12:33:54 -08:00
Mike McQuaid
25249f0114
shims/super/cc: detect High Sierra differently.
Don't rely on `RUBY_PLATFORM`'s kernel version as it's the machine that
Ruby was built on (10.5) for portable ruby.
2018-09-20 13:49:10 +01:00
FX Coudert
481ffcf4e1 super/cc: bump -mmacosx-version-min on High Sierra and later 2018-09-20 10:37:35 +02:00
Mike McQuaid
2086e3c9c4
super/cc: fix -mmacosx-version-min on Mojave.
It fails to accept any version < 10.6.
2018-09-03 20:49:01 +01:00
Maxim Belkin
20001bbbda
Handle the case when HOMEBREW_CC = cc 2018-07-16 13:40:39 -05:00
Shaun Jackman
9e57be73ec shims/super/cc: Add support for Linux 2018-05-30 12:14:31 -07:00
Shaun Jackman
88bf6abd10 shims/super/cc: Fix c++ -xc++-header
Compiling a precompiled header should be mode :cxx rather than :cxxld.
2017-08-09 12:44:41 -07:00
Shaun Jackman
5b1213b053 super/cc: Fix --cc=llvm_clang invoked as clang
Fix the error:
brew sh --cc=llvm_clang <<<'clang --version'
Failed to execute llvm_clang --version
2017-03-08 17:11:23 -08:00
Mike McQuaid
86a9434dfc Revert "Revert "cc: always filter flags on deps."" 2017-02-27 13:41:30 +00:00
Mike McQuaid
f814ee87fb Revert "cc: always filter flags on deps." 2017-01-07 09:52:01 +00:00
Mike McQuaid
e4497a2b42 cc: always filter flags on deps.
This has been tested by `brew test-bot` since March and there’s been no
issues so let’s turn it on by default.
2016-12-30 14:31:05 +00:00
Mike McQuaid
ab060c9d52 super/cc: loosen cellar formula regex.
Match HOMEBREW_TAP_FORMULA_REGEX to avoid skipping valid cellar regexes.
2016-12-15 15:15:13 -08:00
Mike McQuaid
b9d0d7719a cc: don't filter -fopenmp for non-llvm_clang.
We can filter it just for Clang and let it be used by anything else.
2016-11-21 08:50:01 +00:00
Alex Wang
3e4544025d Prefer brewed Clang over gcc-6 for needs :openmp
Clang has fully implemented OpenMP support as of LLVM 3.7, so if OpenMP
is required by a formula gcc is no longer the only choice of compiler.

Clang should be preferred over gcc because using gcc meant linking
against libstdc++, which is ABI incompatible with libc++. This may be
unnoticeable for some users, but it causes other builds to fail, e.g.
pstoedit when imagemagick was built with OpenMP. pstoedit is required
for the octave formula, so for some users this could be a significant
problem.
2016-11-18 08:54:09 -05:00
Alex Wang
d2e2110e80 cc: Add -frounding-math to list of ignored flags 2016-11-13 16:18:19 -05:00
ilovezfs
2c43649ffc superenv: prune -Wl,-z,defs when refurbishing
`-Wl,-z,defs` should be pruned out entirely since `-z defs` is not
understood by macOS's `ld`, and the analogue `-undefined error` is
already the default.
2016-11-02 01:21:15 -07:00