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