Tamar Christina <tamar.christ...@arm.com> writes: > Hi All, > > When both -mcpu and -march are specified, the value of -march wins out. > > This is done correctly for the calls to cc1 and for the assembler directives > we > put out in assembly files. > > However in the call to as we don't do this and instead use the arch from the > cpu. This leads to a situation that GCC cannot reliably be used to compile > assembly files which don't have a .arch directive. > > This is quite common with .S files which use macros to selectively enable > codepath based on what the preprocessor sees. > > The fix is to change MCPU_TO_MARCH_SPEC to not override the march if an march > is already specified. > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? > > Thanks, > Tamar > > gcc/ChangeLog: > > PR target/110901 > * config/aarch64/aarch64.h (MCPU_TO_MARCH_SPEC): Don't override if > march is set. > > gcc/testsuite/ChangeLog: > > PR target/110901 > * gcc.target/aarch64/options_set_29.c: New test.
LGTM. OK if there are no other comments in 24 hours. Thanks, Richard > --- > > diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h > index > 1ab49e229b080d29187690abdb0c0767c12a157a..218868a5246a19c293c03e7be48107c1b0770e27 > 100644 > --- a/gcc/config/aarch64/aarch64.h > +++ b/gcc/config/aarch64/aarch64.h > @@ -1510,7 +1510,7 @@ extern const char *host_detect_local_cpu (int argc, > const char **argv); > CONFIG_TUNE_SPEC > > #define MCPU_TO_MARCH_SPEC \ > - " %{mcpu=*:-march=%:rewrite_mcpu(%{mcpu=*:%*})}" > + "%{!march=*:%{mcpu=*:-march=%:rewrite_mcpu(%{mcpu=*:%*})}}" > > extern const char *aarch64_rewrite_mcpu (int argc, const char **argv); > extern const char *is_host_cpu_not_armv8_base (int argc, const char **argv); > diff --git a/gcc/testsuite/gcc.target/aarch64/options_set_29.c > b/gcc/testsuite/gcc.target/aarch64/options_set_29.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..0a68550951ce61422c4cfea50762b2420a92091e > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/options_set_29.c > @@ -0,0 +1,11 @@ > +/* { dg-do assemble } */ > +/* { dg-additional-options "-march=armv8.2-a+sve -mcpu=cortex-a72 -O1 -w > -###" } */ > + > +int main () > +{ > + return 0; > +} > + > +/* { dg-message "-march=armv8-a\+crc" "no arch from cpu" { xfail *-*-* } 0 } > */ > +/* { dg-message "-march=armv8\\.2-a\\+sve" "using only sve" { target *-*-* } > 0 } */ > +/* { dg-excess-errors "" } */