From patchwork Fri Mar 9 15:38:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 883707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-474501-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=foss.arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kKaFjeBT"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zyWkJ68FSz9sc2 for ; Sat, 10 Mar 2018 02:38:31 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=s9CDXT8tE+xDByIXguQNCALGmFMr3MYZ6KyS3wJhlEskaD bxp+QvdK0mkoD6W1zsRSYjHBt8yZOXy9RLl9yaFYpf9sqy7P6zue9+PzBnu4ggiE CMh4b4EeQLob/ohPrOZe8r2kPTYh0Ol+7YQjliv6kbqHhKBv8WZ+Zwb0/HWmk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=gXkUr7DeDLELfcIw+J+YYFnp9tc=; b=kKaFjeBTlYQSEukqOOdE I7ZqpJp13nLFPExcGWAQNNI9xvXWXlf4Cz1C7N36AA3xhdw5aasNORjl/Wos/v/a Wg76Mm7EVOAokgxmTIJ32DzZc9IYBjEwuzbZMXcS7oonBQ9P978Mw0M8z1mVomZV l9mxWQEl3AUw9NQJcZQSEy8= Received: (qmail 87929 invoked by alias); 9 Mar 2018 15:38:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 87920 invoked by uid 89); 9 Mar 2018 15:38:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=5429 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Mar 2018 15:38:23 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 97AAE1529 for ; Fri, 9 Mar 2018 07:38:20 -0800 (PST) Received: from [10.2.207.77] (e100706-lin.cambridge.arm.com [10.2.207.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 454103F53D for ; Fri, 9 Mar 2018 07:38:20 -0800 (PST) Message-ID: <5AA2AA6A.2070101@foss.arm.com> Date: Fri, 09 Mar 2018 15:38:18 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" Subject: [PATCH][arm] PR target/83193: Do not print arch/cpu hints twice on invalid -march/-mcpu Hi all, 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. Committing to trunk. Thanks, Kyrill 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. diff --git a/gcc/common/config/arm/arm-common.c b/gcc/common/config/arm/arm-common.c index a404d4b1562da7fc66b0f439f2459a90b62a170a..76c357b4258b68d0c2cd78cb54819c280d50963a 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 2b5bb255aac2507a63cbe71277df16e21feb3e79..8537262ce644bbacd7a800c708bcd86eea93d2bd 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -542,9 +542,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 *);