public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Kyrylo Tkachov <ktkachov@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2439] aarch64: Suggest an -mcpu option when user passes CPU name to -march Date: Mon, 5 Sep 2022 13:37:35 +0000 (GMT) [thread overview] Message-ID: <20220905133735.5878D385AC34@sourceware.org> (raw) https://gcc.gnu.org/g:48b9c7d5d329a75d0ceb4e3b26a11bc3b6370f4c commit r13-2439-g48b9c7d5d329a75d0ceb4e3b26a11bc3b6370f4c Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com> Date: Mon Sep 5 14:31:32 2022 +0100 aarch64: Suggest an -mcpu option when user passes CPU name to -march This small patch helps users who confuse -march and -mcpu on AArch64. Sometimes users pass -march with a CPU name, where they most likely wanted to use -mcpu, which would select the right architecture features *and* tune for their desired CPU. Currently we'll just error out with an unkown architecture message and list the valid architecture options. With this patch we check if their string matches a known CPU and suggest they use an -mcpu option instead. So compiling with -march=neoverse-n1 will now give the error: cc1: error: unknown value 'neoverse-n1' for '-march' cc1: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a armv8.5-a armv8.6-a armv8.7-a armv8.8-a armv8-r armv9-a cc1: note: did you mean '-mcpu=neoverse-n1'? Bootstrapped and tested on aarch64-none-linux-gnu. gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_validate_march): Check if invalid arch string is a valid -mcpu string and emit hint. gcc/testsuite/ChangeLog: * gcc.target/aarch64/spellcheck_10.c: New test. Diff: --- gcc/config/aarch64/aarch64.cc | 5 +++++ gcc/testsuite/gcc.target/aarch64/spellcheck_10.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 2311ad0e2b8..566763ce50c 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -18019,6 +18019,11 @@ aarch64_validate_march (const char *str, const struct processor **res, case AARCH64_PARSE_INVALID_ARG: error ("unknown value %qs for %<-march%>", str); aarch64_print_hint_for_arch (str); + /* A common user error is confusing -march and -mcpu. + If the -march string matches a known CPU suggest -mcpu. */ + parse_res = aarch64_parse_cpu (str, res, isa_flags, &invalid_extension); + if (parse_res == AARCH64_PARSE_OK) + inform (input_location, "did you mean %<-mcpu=%s%>?", str); break; case AARCH64_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs in %<-march=%s%>", diff --git a/gcc/testsuite/gcc.target/aarch64/spellcheck_10.c b/gcc/testsuite/gcc.target/aarch64/spellcheck_10.c new file mode 100644 index 00000000000..08540c9c25b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/spellcheck_10.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-march=*" } { "" } } */ +/* { dg-skip-if "" { *-*-* } { "-mcpu=*" } { "" } } */ +/* { dg-options "-march=neoverse-n1" } */ + +void +foo () +{ +} + +/* { dg-error "unknown value .neoverse-n1. for .-march." "" { target *-*-* } 0 } */ +/* { dg-message "valid arguments are: \[^\n\r]*" "" { target *-*-* } 0 } */ +/* { dg-message "did you mean .-mcpu=neoverse-n1.?" "" { target *-*-* } 0 } */
reply other threads:[~2022-09-05 13:37 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220905133735.5878D385AC34@sourceware.org \ --to=ktkachov@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).