https://gcc.gnu.org/g:7ef8a9d4b1cea3fea3791859074df79b71abd549

commit r15-2418-g7ef8a9d4b1cea3fea3791859074df79b71abd549
Author: Edwin Lu <e...@rivosinc.com>
Date:   Wed Jul 24 16:37:18 2024 -0700

    RISC-V: Add configure check for B extention support
    
    Binutils 2.42 and before don't recognize the b extension in the march
    strings even though it supports zba_zbb_zbs. Add a configure check to
    ignore the b in the march string if found.
    
    gcc/ChangeLog:
    
            * common/config/riscv/riscv-common.cc 
(riscv_subset_list::to_string):
            Skip b in march string
            * config.in: Regenerate.
            * configure: Regenerate.
            * configure.ac: Add B assembler check
    
    Signed-off-by: Edwin Lu <e...@rivosinc.com>

Diff:
---
 gcc/common/config/riscv/riscv-common.cc |  8 ++++++++
 gcc/config.in                           |  6 ++++++
 gcc/configure                           | 31 +++++++++++++++++++++++++++++++
 gcc/configure.ac                        |  5 +++++
 4 files changed, 50 insertions(+)

diff --git a/gcc/common/config/riscv/riscv-common.cc 
b/gcc/common/config/riscv/riscv-common.cc
index 0c12e12cde51..1944c7785c48 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -858,6 +858,7 @@ riscv_subset_list::to_string (bool version_p) const
   bool skip_zifencei = false;
   bool skip_zaamo_zalrsc = false;
   bool skip_zicsr = false;
+  bool skip_b = false;
   bool i2p0 = false;
 
   /* For RISC-V ISA version 2.2 or earlier version, zicsr and zifencei is
@@ -890,6 +891,10 @@ riscv_subset_list::to_string (bool version_p) const
      for users with an older version of binutils.  */
   skip_zaamo_zalrsc = true;
 #endif
+#ifndef HAVE_AS_MARCH_B
+  /* Skip since binutils 2.42 and earlier don't recognize b.  */
+  skip_b = true;
+#endif
 
   for (subset = m_head; subset != NULL; subset = subset->next)
     {
@@ -907,6 +912,9 @@ riscv_subset_list::to_string (bool version_p) const
       if (skip_zaamo_zalrsc && subset->name == "zalrsc")
        continue;
 
+      if (skip_b && subset->name == "b")
+       continue;
+
       /* For !version_p, we only separate extension with underline for
         multi-letter extension.  */
       if (!first &&
diff --git a/gcc/config.in b/gcc/config.in
index 3af153eaec5c..7fcabbe5061d 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -629,6 +629,12 @@
 #endif
 
 
+/* Define if the assembler understands -march=rv*_b. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_MARCH_B
+#endif
+
+
 /* Define if the assembler understands -march=rv*_zaamo_zalrsc. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_MARCH_ZAAMO_ZALRSC
diff --git a/gcc/configure b/gcc/configure
index 7541bdeb7248..557ea5fa3ac9 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -30882,6 +30882,37 @@ if test $gcc_cv_as_riscv_march_zaamo_zalrsc = yes; then
 
 $as_echo "#define HAVE_AS_MARCH_ZAAMO_ZALRSC 1" >>confdefs.h
 
+fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for 
-march=rv32i_b support" >&5
+$as_echo_n "checking assembler for -march=rv32i_b support... " >&6; }
+if ${gcc_cv_as_riscv_march_b+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  gcc_cv_as_riscv_march_b=no
+  if test x$gcc_cv_as != x; then
+    $as_echo '' > conftest.s
+    if { ac_try='$gcc_cv_as $gcc_cv_as_flags -march=rv32i_b -o conftest.o 
conftest.s >&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+    then
+       gcc_cv_as_riscv_march_b=yes
+    else
+      echo "configure: failed program was" >&5
+      cat conftest.s >&5
+    fi
+    rm -f conftest.o conftest.s
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_riscv_march_b" >&5
+$as_echo "$gcc_cv_as_riscv_march_b" >&6; }
+if test $gcc_cv_as_riscv_march_b = yes; then
+
+$as_echo "#define HAVE_AS_MARCH_B 1" >>confdefs.h
+
 fi
 
     ;;
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 52c1780379d5..eaa01d0d7e56 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5461,6 +5461,11 @@ configured with --enable-newlib-nano-formatted-io.])
       [-march=rv32i_zaamo_zalrsc],,,
       [AC_DEFINE(HAVE_AS_MARCH_ZAAMO_ZALRSC, 1,
                 [Define if the assembler understands 
-march=rv*_zaamo_zalrsc.])])
+    gcc_GAS_CHECK_FEATURE([-march=rv32i_b support],
+      gcc_cv_as_riscv_march_b,
+      [-march=rv32i_b],,,
+      [AC_DEFINE(HAVE_AS_MARCH_B, 1,
+                [Define if the assembler understands -march=rv*_b.])])
     ;;
     loongarch*-*-*)
     gcc_GAS_CHECK_FEATURE([.dtprelword support],

Reply via email to