[PATCH v2 1/1] riscv: treat clang separately in RVV compiler checks
Yao Zihong
zihong.plct@isrc.iscas.ac.cn
Fri Mar 13 04:54:23 GMT 2026
From: Zihong Yao <zihong.plct@isrc.iscas.ac.cn>
Detect clang explicitly and apply compiler-specific version checks for
RVV support.
Signed-off-by: Zihong Yao <zihong.plct@isrc.iscas.ac.cn>
---
sysdeps/riscv/preconfigure | 13 +++++++++++--
sysdeps/riscv/preconfigure.ac | 13 +++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)
mode change 100644 => 100755 sysdeps/riscv/preconfigure
diff --git a/sysdeps/riscv/preconfigure b/sysdeps/riscv/preconfigure
old mode 100644
new mode 100755
index 92ffa1ac02..57fe6822cf
--- a/sysdeps/riscv/preconfigure
+++ b/sysdeps/riscv/preconfigure
@@ -57,8 +57,17 @@ riscv*)
esac
if test -n "$vector"; then
- version=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __GNUC__ \(.*\)/\1/p'`
- test $version -lt 15 && as_fn_error 1 "glibc requires GCC 15 or later for the V extension" "$LINENO" 5
+ is_clang=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep -q '__clang__' && echo yes || echo no`
+ if test "$is_clang" = "yes"; then
+ # Check clang version
+ version=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __clang_major__ \(.*\)/\1/p'`
+ test $version -lt 21 && as_fn_error 1 "glibc requires Clang 21 or later for the V extension" "$LINENO" 5
+ else
+ # Check GCC version
+ version=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __GNUC__ \(.*\)/\1/p'`
+ test $version -lt 15 && as_fn_error 1 "glibc requires GCC 15 or later for the V extension" "$LINENO" 5
+ fi
+
test $vector -lt "1000000" && as_fn_error 1 "glibc requires at least RVV 1.0 for the V extension" "$LINENO" 5
float_machine=rvv
fi
diff --git a/sysdeps/riscv/preconfigure.ac b/sysdeps/riscv/preconfigure.ac
index 99fbb0c9c9..52414919ae 100644
--- a/sysdeps/riscv/preconfigure.ac
+++ b/sysdeps/riscv/preconfigure.ac
@@ -57,8 +57,17 @@ riscv*)
esac
if test -n "$vector"; then
- version=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __GNUC__ \(.*\)/\1/p'`
- test $version -lt 15 && AC_MSG_ERROR([glibc requires GCC 15 or later for the V extension], [1])
+ is_clang=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep -q '__clang__' && echo yes || echo no`
+ if test "$is_clang" = "yes"; then
+ # Check clang version
+ version=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __clang_major__ \(.*\)/\1/p'`
+ test $version -lt 21 && AC_MSG_ERROR([glibc requires Clang 21 or later for the V extension], [1])
+ else
+ # Check GCC version
+ version=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __GNUC__ \(.*\)/\1/p'`
+ test $version -lt 15 && AC_MSG_ERROR([glibc requires GCC 15 or later for the V extension], [1])
+ fi
+
test $vector -lt "1000000" && AC_MSG_ERROR([glibc requires at least RVV 1.0 for the V extension], [1])
float_machine=rvv
fi
--
2.47.3
More information about the Libc-alpha
mailing list