From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) by sourceware.org (Postfix) with ESMTPS id 030B93858C83 for ; Wed, 22 Feb 2023 10:26:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 030B93858C83 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R611e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=jinma@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VcGT9mn_1677061594; Received: from localhost.localdomain(mailfrom:jinma@linux.alibaba.com fp:SMTPD_---0VcGT9mn_1677061594) by smtp.aliyun-inc.com; Wed, 22 Feb 2023 18:26:35 +0800 From: Jin Ma To: gcc-patches@gcc.gnu.org Cc: kito.cheng@sifive.com, kito.cheng@gmail.com, palmer@dabbelt.com, Jin Ma Subject: [PATCH] RISC-V: Don't report an error until the link phase if suitable multilib isn't found. Date: Wed, 22 Feb 2023 18:26:09 +0800 Message-Id: <20230222102609.1099-1-jinma@linux.alibaba.com> X-Mailer: git-send-email 2.38.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-20.8 required=5.0 tests=BAYES_00,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: When suitable multilib isn't found, an error is not reported until the link period, which is inconsistent with the result of compiling option `-print-multi-directory`. For example, when suitable multilib isn't found, the return result of `-print-multi-directory` is the default value '.', while the actual execution result is an error during the link phase. This is not very reasonable. I think the error should be reported in advance, so that the compilation option `-print-multi-directory` will also report an error. The two should be consistent, either reporting errors or using default values. gcc/ChangeLog: * common/config/riscv/riscv-common.cc (riscv_compute_multilib): report an error if suitable multilib isn't found. (struct riscv_multi_lib_info_t): Delet. (riscv_multi_lib_check): Likewise. * config/riscv/elf.h (LIB_SPEC): Likewise. * config/riscv/riscv.h (riscv_multi_lib_check): Likewise. (EXTRA_SPEC_FUNCTIONS): Likewise. --- gcc/common/config/riscv/riscv-common.cc | 25 +++++-------------------- gcc/config/riscv/elf.h | 3 +-- gcc/config/riscv/riscv.h | 4 +--- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index ebc1ed7d7e4..3f27ecf4b3c 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -274,9 +274,6 @@ struct riscv_multi_lib_info_t { const std::vector &); }; -/* Flag for checking if there is no suitable multi-lib found. */ -static bool riscv_no_matched_multi_lib; - /* Used for record value of -march and -mabi. */ static std::string riscv_current_arch_str; static std::string riscv_current_abi_str; @@ -1396,21 +1393,6 @@ riscv_expand_arch_from_cpu (int argc ATTRIBUTE_UNUSED, return xasprintf ("-march=%s", arch.c_str()); } -/* Report error if not found suitable multilib. */ -const char * -riscv_multi_lib_check (int argc ATTRIBUTE_UNUSED, - const char **argv ATTRIBUTE_UNUSED) -{ - if (riscv_no_matched_multi_lib) - fatal_error ( - input_location, - "Cannot find suitable multilib set for %<-march=%s%>/%<-mabi=%s%>", - riscv_current_arch_str.c_str (), - riscv_current_abi_str.c_str ()); - - return ""; -} - /* We only override this in bare-metal toolchain. */ #ifdef RISCV_USE_CUSTOMISED_MULTI_LIB @@ -1583,7 +1565,6 @@ riscv_compute_multilib ( const char *this_path; size_t this_path_len; bool result; - riscv_no_matched_multi_lib = false; riscv_subset_list *subset_list = NULL; std::vector multilib_infos; @@ -1709,7 +1690,11 @@ riscv_compute_multilib ( if (best_match_multi_lib == -1) { - riscv_no_matched_multi_lib = true; + fatal_error ( + input_location, + "Cannot find suitable multilib set for %<-march=%s%>/%<-mabi=%s%>", + riscv_current_arch_str.c_str (), + riscv_current_abi_str.c_str ()); return multilib_dir; } else diff --git a/gcc/config/riscv/elf.h b/gcc/config/riscv/elf.h index a725c00b637..7b8dc29d4cb 100644 --- a/gcc/config/riscv/elf.h +++ b/gcc/config/riscv/elf.h @@ -28,8 +28,7 @@ along with GCC; see the file COPYING3. If not see Handle the circular dependence between libc and libgloss. */ #undef LIB_SPEC #define LIB_SPEC \ - "--start-group -lc %{!specs=nosys.specs:-lgloss} --end-group " \ - "%{!nostartfiles:%{!nodefaultlibs:%{!nolibc:%{!nostdlib:%:riscv_multi_lib_check()}}}}" + "--start-group -lc %{!specs=nosys.specs:-lgloss} --end-group" #undef STARTFILE_SPEC #define STARTFILE_SPEC "crt0%O%s crtbegin%O%s" diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 5bc7f2f467d..b8fa5f022db 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -46,13 +46,11 @@ along with GCC; see the file COPYING3. If not see extern const char *riscv_expand_arch (int argc, const char **argv); extern const char *riscv_expand_arch_from_cpu (int argc, const char **argv); extern const char *riscv_default_mtune (int argc, const char **argv); -extern const char *riscv_multi_lib_check (int argc, const char **argv); # define EXTRA_SPEC_FUNCTIONS \ { "riscv_expand_arch", riscv_expand_arch }, \ { "riscv_expand_arch_from_cpu", riscv_expand_arch_from_cpu }, \ - { "riscv_default_mtune", riscv_default_mtune }, \ - { "riscv_multi_lib_check", riscv_multi_lib_check }, + { "riscv_default_mtune", riscv_default_mtune }, /* Support for a compile-time default CPU, et cetera. The rules are: --with-arch is ignored if -march or -mcpu is specified. -- 2.17.1