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.