shared: only fall back to -march=native on supported architectures #18759
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?On Linux,
-march=native
is added in the optflags when building from source (and not for a bottle). This works fine for the case where users installbrew
in a custom prefix on a supported architecture, but breaks the case where the user is building from source for running under Linux on an unsupported architecture for which the-march=native
flag is not valid (I specifically ran into this issue while tinkering withbrew
under Ubuntu on RISC-V).Introduce a new optimization flag option
none
and adjusteffective_arch
to only fall back on:native
if running on Intel or ARM (which are not the only architectures which support-march=native
, but it does cover all existing supported use cases and leaves room for current development/experimentation happening withbrew
on Linux arm64), and falls back on the more conservative:none
option if not running one of those architectures.