aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>2022-09-05 14:31:32 +0100
committerKyrylo Tkachov <kyrylo.tkachov@arm.com>2022-09-05 14:37:13 +0100
commit48b9c7d5d329a75d0ceb4e3b26a11bc3b6370f4c (patch)
tree367d6682b6909787adca1294a3da6dd990f652b9 /gcc/config
parent77e8e405a770bc40b304cfa55081575cf88f2b31 (diff)
downloadgcc-48b9c7d5d329a75d0ceb4e3b26a11bc3b6370f4c.zip
gcc-48b9c7d5d329a75d0ceb4e3b26a11bc3b6370f4c.tar.gz
gcc-48b9c7d5d329a75d0ceb4e3b26a11bc3b6370f4c.tar.bz2
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.
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/aarch64/aarch64.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 2311ad0..566763c 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%>",