[v2,09/15] RISC-V: Add compiler test for Zbb function attribute support
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Testing passed
|
redhat-pt-bot/TryBot-still_applies |
warning
|
Patch no longer applies to master
|
Commit Message
Target function attributes that allow enabling RISC-V extensions
have been added to GCC and LLVM a few months ago.
This patch adds a configure test to see if the compiler supports
enabling Zbb via this mechanism.
Note, that unknown target attributes just issue a warning, so this
test needs to build with -Werror.
Tested with GCC 13 (fails) and GCC 14 (succeeds).
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
---
config.h.in | 3 +++
sysdeps/riscv/configure | 27 +++++++++++++++++++++++++++
sysdeps/riscv/configure.ac | 18 ++++++++++++++++++
3 files changed, 48 insertions(+)
@@ -273,6 +273,9 @@
/* PowerPC32 uses fctidz for floating point to long long conversions. */
#define HAVE_PPC_FCTIDZ 0
+/* RISC-V function attributes for Zbb. */
+#define HAVE_RISCV_FATTRIBUTE_ZBB 0
+
/* Define if PIE is unsupported. */
#undef PIE_UNSUPPORTED
@@ -80,3 +80,30 @@ if test "$libc_cv_static_pie_on_riscv" = yes; then
printf "%s\n" "#define SUPPORT_STATIC_PIE 1" >>confdefs.h
fi
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for RISC-V Zbb target attribute support" >&5
+printf %s "checking for RISC-V Zbb target attribute support... " >&6; }
+if test ${libc_cv_compiler_fattribute_zbb+y}
+then :
+ printf %s "(cached) " >&6
+else $as_nop
+ cat > conftest.c <<EOF
+__attribute__((target("arch=+zbb")))
+void foo() {}
+EOF
+libc_cv_compiler_fattribute_zbb=no
+if ${CC-cc} -Werror -c conftest.c -o /dev/null 1>&5 \
+ 2>&5 ; then
+ libc_cv_compiler_fattribute_zbb=yes
+fi
+rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_compiler_fattribute_zbb" >&5
+printf "%s\n" "$libc_cv_compiler_fattribute_zbb" >&6; }
+if test "$libc_cv_compiler_fattribute_zbb" = yes; then
+ printf "%s\n" "#define HAVE_RISCV_FATTRIBUTE_ZBB 1" >>confdefs.h
+
+fi
+config_vars="$config_vars
+have-fattribute-zbb-support = $libc_cv_compiler_fattribute_zbb"
+
@@ -43,3 +43,21 @@ EOF
if test "$libc_cv_static_pie_on_riscv" = yes; then
AC_DEFINE(SUPPORT_STATIC_PIE)
fi
+
+dnl Test if we have Zbb via function attributes
+AC_CACHE_CHECK([for RISC-V Zbb target attribute support],
+ libc_cv_compiler_fattribute_zbb, [dnl
+cat > conftest.c <<EOF
+__attribute__((target("arch=+zbb")))
+void foo() {}
+EOF
+libc_cv_compiler_fattribute_zbb=no
+if ${CC-cc} -Werror -c conftest.c -o /dev/null 1>&AS_MESSAGE_LOG_FD \
+ 2>&AS_MESSAGE_LOG_FD ; then
+ libc_cv_compiler_fattribute_zbb=yes
+fi
+rm -f conftest*])
+if test "$libc_cv_compiler_fattribute_zbb" = yes; then
+ AC_DEFINE(HAVE_RISCV_FATTRIBUTE_ZBB)
+fi
+LIBC_CONFIG_VAR([have-fattribute-zbb-support], [$libc_cv_compiler_fattribute_zbb])