mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

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