From a4017ff7722614f749a0d5eab315e929b2035e8a Mon Sep 17 00:00:00 2001 From: Kyrylo Tkachov Date: Fri, 9 Mar 2018 15:42:10 +0000 Subject: [PATCH] [arm] PR target/83193: Do not print arch/cpu hints twice on invalid -march/-mcpu Currently when handling an invalid -march or -mcpu option on a toolchain without an explicit --with-mode configuration and compiling without an explicit -mthumb or -marm the arm specs end up calling arm_target_thumb_only to determine the "thumbness" of the target, which involves parsing the architecture or cpu name. But the functions doing that parsing also emit error messages and hints on invalid arguments. Later when we parse the architecture or cpu string to as part of the canonicalisation process (arm_canon_arch_option) we end up emitting the errors again. The solution in this patch is to silence the errors during the arm_target_thumb_only processing so that they are not emitted twice. arm_canon_arch_option is guaranteed to run as well, so it can emit the errors and hints that it needs. Bootstrapped and tested on arm-none-linux-gnueabihf. Checked that we emit the arch/cpu hints for invalid -march/-mcpu options only once when no "thumbness" options were specified during configuration or invocation. PR target/83193 * common/config/arm/arm-common.c (arm_parse_arch_option_name): Accept complain bool parameter. Only emit errors if it is true. (arm_parse_cpu_option_name): Likewise. (arm_target_thumb_only): Adjust callers of the above. * config/arm/arm-protos.h (arm_parse_cpu_option_name): Adjust prototype to take a default true bool parameter. (arm_parse_arch_option_name): Likewise. From-SVN: r258389 --- gcc/ChangeLog | 11 +++++++++++ gcc/common/config/arm/arm-common.c | 29 +++++++++++++++++++---------- gcc/config/arm/arm-protos.h | 4 ++-- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6bc488c..e6c279d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2018-03-09 Kyrylo Tkachov + + PR target/83193 + * common/config/arm/arm-common.c (arm_parse_arch_option_name): + Accept complain bool parameter. Only emit errors if it is true. + (arm_parse_cpu_option_name): Likewise. + (arm_target_thumb_only): Adjust callers of the above. + * config/arm/arm-protos.h (arm_parse_cpu_option_name): Adjust + prototype to take a default true bool parameter. + (arm_parse_arch_option_name): Likewise. + 2018-03-09 David Malcolm Francois-Xavier Coudert diff --git a/gcc/common/config/arm/arm-common.c b/gcc/common/config/arm/arm-common.c index a404d4b..76c357b 100644 --- a/gcc/common/config/arm/arm-common.c +++ b/gcc/common/config/arm/arm-common.c @@ -279,7 +279,8 @@ arm_target_thumb_only (int argc, const char **argv) if (arch) { const arch_option *arch_opt - = arm_parse_arch_option_name (all_architectures, "-march", arch); + = arm_parse_arch_option_name (all_architectures, "-march", arch, + false); if (arch_opt && !check_isa_bits_for (arch_opt->common.isa_bits, isa_bit_notm)) @@ -288,7 +289,7 @@ arm_target_thumb_only (int argc, const char **argv) else if (cpu) { const cpu_option *cpu_opt - = arm_parse_cpu_option_name (all_cores, "-mcpu", cpu); + = arm_parse_cpu_option_name (all_cores, "-mcpu", cpu, false); if (cpu_opt && !check_isa_bits_for (cpu_opt->common.isa_bits, isa_bit_notm)) @@ -329,10 +330,11 @@ arm_print_hint_for_cpu_option (const char *target, /* Parse the base component of a CPU selection in LIST. Return a pointer to the entry in the architecture table. OPTNAME is the name of the option we are parsing and can be used if a diagnostic - is needed. */ + is needed. If COMPLAIN is true (the default) emit error + messages and hints on invalid input. */ const cpu_option * arm_parse_cpu_option_name (const cpu_option *list, const char *optname, - const char *target) + const char *target, bool complain) { const cpu_option *entry; const char *end = strchr (target, '+'); @@ -345,8 +347,11 @@ arm_parse_cpu_option_name (const cpu_option *list, const char *optname, return entry; } - error_at (input_location, "unrecognized %s target: %s", optname, target); - arm_print_hint_for_cpu_option (target, list); + if (complain) + { + error_at (input_location, "unrecognized %s target: %s", optname, target); + arm_print_hint_for_cpu_option (target, list); + } return NULL; } @@ -379,10 +384,11 @@ arm_print_hint_for_arch_option (const char *target, /* Parse the base component of a CPU or architecture selection in LIST. Return a pointer to the entry in the architecture table. OPTNAME is the name of the option we are parsing and can be used if - a diagnostic is needed. */ + a diagnostic is needed. If COMPLAIN is true (the default) emit error + messages and hints on invalid input. */ const arch_option * arm_parse_arch_option_name (const arch_option *list, const char *optname, - const char *target) + const char *target, bool complain) { const arch_option *entry; const char *end = strchr (target, '+'); @@ -395,8 +401,11 @@ arm_parse_arch_option_name (const arch_option *list, const char *optname, return entry; } - error_at (input_location, "unrecognized %s target: %s", optname, target); - arm_print_hint_for_arch_option (target, list); + if (complain) + { + error_at (input_location, "unrecognized %s target: %s", optname, target); + arm_print_hint_for_arch_option (target, list); + } return NULL; } diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 7580503..9d0acde 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -545,9 +545,9 @@ extern const arch_option all_architectures[]; extern const cpu_option all_cores[]; const cpu_option *arm_parse_cpu_option_name (const cpu_option *, const char *, - const char *); + const char *, bool = true); const arch_option *arm_parse_arch_option_name (const arch_option *, - const char *, const char *); + const char *, const char *, bool = true); void arm_parse_option_features (sbitmap, const cpu_arch_option *, const char *); -- 2.7.4