public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kito Cheng <kito.cheng@sifive.com>
To: Jin Ma <jinma@linux.alibaba.com>
Cc: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, palmer@dabbelt.com
Subject: Re: [PATCH] RISC-V: Don't report an error until the link phase if suitable multilib isn't found.
Date: Wed, 22 Feb 2023 20:03:59 +0800	[thread overview]
Message-ID: <CALLt3TjAMpjFjduPjLx6t0xD7KedRCwA9hE4k_vjSdH4SPtJpg@mail.gmail.com> (raw)
In-Reply-To: <20230222102609.1099-1-jinma@linux.alibaba.com>

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 <jinma@linux.alibaba.com> 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<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
>

      reply	other threads:[~2023-02-22 12:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 10:26 Jin Ma
2023-02-22 12:03 ` Kito Cheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALLt3TjAMpjFjduPjLx6t0xD7KedRCwA9hE4k_vjSdH4SPtJpg@mail.gmail.com \
    --to=kito.cheng@sifive.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jinma@linux.alibaba.com \
    --cc=kito.cheng@gmail.com \
    --cc=palmer@dabbelt.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).