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
A fix for the script was made in 95b0bd160fdbf00adb457a54d28b9925d2663494 but the user may be updating from an older version of brew, which won't have this fix.
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 resolvesHomebrew/homebrew-core#76537.
[1] open-mpi/ompi#8306 and linked issues/PRs
[2] Homebrew/homebrew-core#76537
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.
A new version of `shellcheck` (I think?) brought us so new warnings and
errors.
To fix:
- pass `--source-path` so we don't need to stop `shellcheck` trying to
read sourced files every time
- disable some more warnings/errors we don't care about fixing
- prioritise the first `pod2man` in the `PATH` if possible. This shim
was created to handle the case where there isn't one but, if there is,
we want to allow e.g. using a `pod2man` dependency to override the use
of the system version
- make `/usr/bin/pod2man` lower priority but still prioritise it over
a Homebrew-installed `pod2man` that's not in the `PATH` unless it
doesn't exist.
This shim was originally added in
5c973bad7422cf7f335e952a91ddfa2273aa2e4f to workaround a missing
`/usr/bin/pod2man`. It's now unfortunately resulting in using an older
`pod2man` on newer macOS versions.
Instead, let's use `/usr/bin/pod2man` if it's available and, if not,
work backwards to find the newest available version that is available.