6c0556
commit 77d175e14e5f4cf24e9579c03eef5d006a286316
6c0556
Author: Naohiro Tamura <naohirot@jp.fujitsu.com>
6c0556
Date:   Wed May 12 09:26:40 2021 +0000
6c0556
6c0556
    config: Added HAVE_AARCH64_SVE_ASM for aarch64
6c0556
    
6c0556
    This patch checks if assembler supports '-march=armv8.2-a+sve' to
6c0556
    generate SVE code or not, and then define HAVE_AARCH64_SVE_ASM macro.
6c0556
6c0556
Conflicts:
6c0556
	config.h.in
6c0556
	  (missing PAC+BTI support downstream, missing other ports)
6c0556
6c0556
diff --git a/config.h.in b/config.h.in
6c0556
index 8520b0fa8d4668fb..94d5ea367e10f849 100644
6c0556
--- a/config.h.in
6c0556
+++ b/config.h.in
6c0556
@@ -112,6 +112,11 @@
6c0556
 /* AArch64 big endian ABI */
6c0556
 #undef HAVE_AARCH64_BE
6c0556
 
6c0556
+/* Assembler support ARMv8.2-A SVE.
6c0556
+   This macro becomes obsolete when glibc increased the minimum
6c0556
+   required version of GNU 'binutils' to 2.28 or later. */
6c0556
+#define HAVE_AARCH64_SVE_ASM 0
6c0556
+
6c0556
 /* RISC-V integer ABI for ld.so.  */
6c0556
 #undef RISCV_ABI_XLEN
6c0556
 
6c0556
diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure
6c0556
index f78a79338aba1e34..9fb713155d4ee6d8 100644
6c0556
--- a/sysdeps/aarch64/configure
6c0556
+++ b/sysdeps/aarch64/configure
6c0556
@@ -212,3 +212,31 @@ fi
6c0556
 $as_echo "$libc_cv_aarch64_variant_pcs" >&6; }
6c0556
 config_vars="$config_vars
6c0556
 aarch64-variant-pcs = $libc_cv_aarch64_variant_pcs"
6c0556
+
6c0556
+# Check if asm support armv8.2-a+sve
6c0556
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SVE support in assembler" >&5
6c0556
+$as_echo_n "checking for SVE support in assembler... " >&6; }
6c0556
+if ${libc_cv_asm_sve+:} false; then :
6c0556
+  $as_echo_n "(cached) " >&6
6c0556
+else
6c0556
+  cat > conftest.s <<\EOF
6c0556
+        ptrue p0.b
6c0556
+EOF
6c0556
+if { ac_try='${CC-cc} -c -march=armv8.2-a+sve conftest.s 1>&5'
6c0556
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
6c0556
+  (eval $ac_try) 2>&5
6c0556
+  ac_status=$?
6c0556
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
6c0556
+  test $ac_status = 0; }; }; then
6c0556
+  libc_cv_aarch64_sve_asm=yes
6c0556
+else
6c0556
+  libc_cv_aarch64_sve_asm=no
6c0556
+fi
6c0556
+rm -f conftest*
6c0556
+fi
6c0556
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_sve" >&5
6c0556
+$as_echo "$libc_cv_asm_sve" >&6; }
6c0556
+if test $libc_cv_aarch64_sve_asm = yes; then
6c0556
+  $as_echo "#define HAVE_AARCH64_SVE_ASM 1" >>confdefs.h
6c0556
+
6c0556
+fi
6c0556
diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac
6c0556
index 7f13bfb93b60bfd7..0236cfcdf3c8d10d 100644
6c0556
--- a/sysdeps/aarch64/configure.ac
6c0556
+++ b/sysdeps/aarch64/configure.ac
6c0556
@@ -42,3 +42,18 @@ EOF
6c0556
   fi
6c0556
   rm -rf conftest.*])
6c0556
 LIBC_CONFIG_VAR([aarch64-variant-pcs], [$libc_cv_aarch64_variant_pcs])
6c0556
+
6c0556
+# Check if asm support armv8.2-a+sve
6c0556
+AC_CACHE_CHECK(for SVE support in assembler, libc_cv_asm_sve, [dnl
6c0556
+cat > conftest.s <<\EOF
6c0556
+        ptrue p0.b
6c0556
+EOF
6c0556
+if AC_TRY_COMMAND(${CC-cc} -c -march=armv8.2-a+sve conftest.s 1>&AS_MESSAGE_LOG_FD); then
6c0556
+  libc_cv_aarch64_sve_asm=yes
6c0556
+else
6c0556
+  libc_cv_aarch64_sve_asm=no
6c0556
+fi
6c0556
+rm -f conftest*])
6c0556
+if test $libc_cv_aarch64_sve_asm = yes; then
6c0556
+  AC_DEFINE(HAVE_AARCH64_SVE_ASM)
6c0556
+fi