From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 75EE13858D33 for ; Wed, 22 Feb 2023 12:04:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75EE13858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-lf1-x133.google.com with SMTP id k14so8716802lfj.7 for ; Wed, 22 Feb 2023 04:04:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=oxEFGycBZawyCqJCcFWGol3hdeFmaaApRMLVbz3L+xU=; b=Ci8OKi1pW4i9bpZc2m9/9+Qm9bmAYMUZgySEQtJeWebojF1PhtfKbWoEKr/J0MNq8k HB1tGFF7Yf8KPmXnUcfL/JykBqum1zKPr2IayBfNahicIVF3ZLYXDY1KzgxKvpkJpEUo dvTyGjE7E2qXYTtubSUWdt7/uwj+fp49+MsXYv2FG9K7tnSl1hInQDdoMFIuJJfmY+FQ KAhLxQPl5nysJxMNSdpifJ0iO+hKc8dLdk+2YH9yxz+fXdQKdho2fzjAJGJmRy0+AuFl M7Fh1r2Xc/aP6jJvaFaFdGOhLM29NEWKPrhs5kvpdRbdbpI+ouyTdnyuq0FVEH2NY3Ea LAWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oxEFGycBZawyCqJCcFWGol3hdeFmaaApRMLVbz3L+xU=; b=kFPnjU7uemeN5a7Eu425LTZZpdb36ts2vXyFBJ4UvFMZZptUWD+lltjonzWKMuZywM EfS3GnVdAAEpyTKarOHklJk3gPxf3y7VAJ/SGMEKMx9//2rTGAqsJdG4YEJeHIHajYdM SUnhgiaZGSjG6ZGq4eKb0CSJlb9s1GY+EDnu7WCalQYYubrpBmjzDcUjy2IaGW2OGUsY yO6y4ZikD6PDQn5OvSEo22ZI4/f2Eg0J6ovgQw5GTMEogFln5EkoP/IJGy3EnAUm7AUO CRRmr760S1HrSdiTCQvBF9S7605l7j939cZCW5PHT5a6Gbk1OU/kCeb5wJOep7Yzhk1+ jEkQ== X-Gm-Message-State: AO0yUKVPdyTBIFrcjvdAITrEytBqxrtDG/gYQq/50vxpg8zAzjvnofpV UQq66uaDSBUMTAMcSFMKmvtjjWTB8IuusgpQEEk4kQ== X-Google-Smtp-Source: AK7set8aE4t2YuU4MYEThBNzFrAiYu7RAxeLW7gND+1cmgimnUG1NMySkyqLGxVXihXUsirDkvmKiUqin2w5ppMZ0dM= X-Received: by 2002:a05:6512:110a:b0:4dd:9931:c555 with SMTP id l10-20020a056512110a00b004dd9931c555mr1254172lfg.0.1677067450700; Wed, 22 Feb 2023 04:04:10 -0800 (PST) MIME-Version: 1.0 References: <20230222102609.1099-1-jinma@linux.alibaba.com> In-Reply-To: <20230222102609.1099-1-jinma@linux.alibaba.com> From: Kito Cheng Date: Wed, 22 Feb 2023 20:03:59 +0800 Message-ID: Subject: Re: [PATCH] RISC-V: Don't report an error until the link phase if suitable multilib isn't found. To: Jin Ma Cc: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, palmer@dabbelt.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP 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: This will break some scenario which is to build anything by themself, which does not use any header or library from the builtin one. So that's why the spec needs to guard so many conditions, no -nostartfiles, -nodefaultlibs, -nolibc and -nostdlib appears. "%{!nostartfiles:%{!nodefaultlibs:%{!nolibc:%{!nostdlib:%:riscv_multi_lib_check()}}}} On Wed, Feb 22, 2023 at 6:26 PM Jin Ma wrote: > > 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 >