From: Kyrylo Tkachov Date: Tue, 18 Apr 2023 11:15:35 +0000 (+0100) Subject: aarch64: Give hint for -mcpu options that match -march instead X-Git-Tag: basepoints/gcc-15~10114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebaec582ca1ee33269724bff945a16655e487ad5;p=thirdparty%2Fgcc.git aarch64: Give hint for -mcpu options that match -march instead We should redirect users of the erroneous -mcpu=armv8.2-a to use -march instead. There is an equivalent hint for -march used with a CPU name. Bootstrapped and tested on aarch64-none-linux-gnu. gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_validate_mcpu): Add hint to use -march if the argument matches that. gcc/testsuite/ChangeLog: * gcc.target/aarch64/spellcheck_11.c: New test. --- diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 0f04ab9fba02..adbdaaf86030 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -18139,6 +18139,12 @@ aarch64_validate_mcpu (const char *str, const struct processor **res, case AARCH_PARSE_INVALID_ARG: error ("unknown value %qs for %<-mcpu%>", str); aarch64_print_hint_for_core (str); + /* A common user error is confusing -march and -mcpu. + If the -mcpu string matches a known architecture then suggest + -march=. */ + parse_res = aarch64_parse_arch (str, res, isa_flags, &invalid_extension); + if (parse_res == AARCH_PARSE_OK) + inform (input_location, "did you mean %<-march=%s%>?", str); break; case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs in %<-mcpu=%s%>", diff --git a/gcc/testsuite/gcc.target/aarch64/spellcheck_11.c b/gcc/testsuite/gcc.target/aarch64/spellcheck_11.c new file mode 100644 index 000000000000..a278328cabc4 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/spellcheck_11.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-march=*" } { "" } } */ +/* { dg-skip-if "" { *-*-* } { "-mcpu=*" } { "" } } */ +/* { dg-options "-mcpu=armv8.2-a+dotprod" } */ + +void +foo () +{ +} + +/* { dg-error "unknown value .armv8.2-a\\+dotprod. for .-mcpu." "" { target *-*-* } 0 } */ +/* { dg-message "valid arguments are: \[^\n\r]*" "" { target *-*-* } 0 } */ +/* { dg-message "did you mean .-march=armv8.2-a\\+dotprod.?" "" { target *-*-* } 0 } */