[PATCH v4 1/4] add a configure test to check if the compiler supports rvv
daichengrong@iscas.ac.cn
daichengrong@iscas.ac.cn
Wed Jan 22 02:03:58 GMT 2025
From: daichengrong <daichengrong@iscas.ac.cn>
---
config.h.in | 3 +++
configure | 35 +++++++++++++++++++++++++++++++++++
configure.ac | 25 +++++++++++++++++++++++++
3 files changed, 63 insertions(+)
diff --git a/config.h.in b/config.h.in
index cdbd555366..d1e84b6c07 100644
--- a/config.h.in
+++ b/config.h.in
@@ -211,6 +211,9 @@
/* Define if gcc supports attribute ifunc. */
#undef HAVE_GCC_IFUNC
+/* Define if gcc supports riscv vector. */
+#undef HAVE_GCC_RISCV_VECTOR
+
/* Define if CC supports attribute retain. */
#undef HAVE_GNU_RETAIN
diff --git a/configure b/configure
index eb8abd0054..58af3a213f 100755
--- a/configure
+++ b/configure
@@ -6375,6 +6375,33 @@ fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_textrel_ifunc" >&5
printf "%s\n" "$libc_cv_textrel_ifunc" >&6; }
+# Check if gcc supports attribute riscv vector.
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gcc attribute riscv vector support" >&5
+printf %s "checking for gcc attribute riscv vector support... " >&6; }
+if test ${libc_cv_gcc_rvv+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) cat > conftest.c <<EOF
+int used_func (int a)
+{
+ return a;
+}
+static void *resolver ()
+{
+ return &used_func;
+}
+EOF
+libc_cv_gcc_rvv=no
+if ${CC-cc} -march=rv64gcv -c conftest.c -o conftest.o 1>&5 \
+ 2>&5 ; then
+ libc_cv_gcc_rvv=yes
+fi
+rm -f conftest* ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_gcc_rvv" >&5
+printf "%s\n" "$libc_cv_gcc_rvv" >&6; }
# Check if CC supports attribute retain as it is used in attribute_used_retain macro.
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU attribute retain support" >&5
@@ -8759,6 +8786,14 @@ fi
config_vars="$config_vars
have-gcc-ifunc = $libc_cv_gcc_indirect_function"
+if test x"$libc_cv_gcc_rvv" = xyes; then
+ printf "%s\n" "#define HAVE_GCC_RISCV_VECTOR 1" >>confdefs.h
+
+fi
+config_vars="$config_vars
+have-gcc-riscv-rvv = $libc_cv_gcc_rvv"
+
+
# This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
# configure fragment can override the value to prevent this AC_DEFINE.
diff --git a/configure.ac b/configure.ac
index 050bfa65e3..0f8c497e9a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -829,6 +829,31 @@ fi
rm -f conftest*])
AC_SUBST(libc_cv_textrel_ifunc)
+# Check if gcc supports attribute riscv vector macro.
+AC_CACHE_CHECK([for gcc attribute riscv vector support],
+ libc_cv_gcc_rvv, [dnl
+cat > conftest.c <<EOF
+int used_func (int a)
+{
+ return a;
+}
+static void *resolver ()
+{
+ return &used_func;
+}
+EOF
+libc_cv_gcc_rvv=no
+if ${CC-cc} -march=rv64gcv -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
+ 2>&AS_MESSAGE_LOG_FD ; then
+ libc_cv_gcc_rvv=yes
+fi
+rm -f conftest*])
+
+if test x"$libc_cv_gcc_rvv" = xyes; then
+ AC_DEFINE(HAVE_GCC_RISCV_VECTOR)
+fi
+LIBC_CONFIG_VAR([have-gcc-riscv-rvv], [$libc_cv_gcc_rvv])
+
# Check if CC supports attribute retain as it is used in attribute_used_retain macro.
AC_CACHE_CHECK([for GNU attribute retain support],
libc_cv_gnu_retain, [dnl
--
2.25.1
More information about the Libc-alpha
mailing list