Skip a multilib only when it is exactly equivalent to the default: it
shares the default march and mabi and carries no other distinguishing
option (such as mcmodel).  A multilib that matches the default march/mabi
but differs in another option is kept.

This fixes a broken Ada build.  When configured with
--with-multilib-list=lp64d, the lp64d multilib is the default but was
still emitted as a separate multilib, so MULTISUBDIR became /lib64/lp64d
instead of empty.

gcc/ChangeLog:

        * common/config/riscv/riscv-common.cc
        (riscv_multi_lib_info_t::parse): Skip a multilib that is exactly
        equivalent to the default march/mabi.

Signed-off-by: Jim Lin <[email protected]>
---
 gcc/common/config/riscv/riscv-common.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/common/config/riscv/riscv-common.cc 
b/gcc/common/config/riscv/riscv-common.cc
index 2d56ba59f0e..8a42dbdd3eb 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -1922,11 +1922,21 @@ riscv_multi_lib_info_t::parse (
   else
     {
       std::vector<std::string>::const_iterator itr;
+      bool only_arch_abi = true;
       for (itr = conds.begin (); itr != conds.end (); ++itr)
        if (prefixed_with (*itr, "march="))
          multi_lib_info->arch_str = itr->c_str () + strlen ("march=");
        else if (prefixed_with (*itr, "mabi="))
          multi_lib_info->abi_str = itr->c_str () + strlen ("mabi=");
+       else
+         only_arch_abi = false;
+
+      /* Skip a multi-lib that is exactly equivalent to the default: same
+        march and mabi with no other distinguishing option. */
+      if (only_arch_abi
+         && multi_lib_info->arch_str == default_arch_str
+         && multi_lib_info->abi_str == default_abi_str)
+       return false;
     }
 
   multi_lib_info->subset_list =
-- 
2.52.0

Reply via email to