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<std::string> &); }; -/* 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<riscv_multi_lib_info_t> 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