1GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2# Local configure fragment for sysdeps/aarch64.
3
4# Static and hidden objects are accessed without dynamic relocations.
5# The exception is -mcmodel=large which is unsupported with PIC/PIE.
6AC_DEFINE(PI_STATIC_AND_HIDDEN)
7
8# Static PIE is supported.
9AC_DEFINE(SUPPORT_STATIC_PIE)
10
11# We check to see if the compiler and flags are
12# selecting the big endian ABI and if they are then
13# we set libc_cv_aarch64_be to yes which causes
14# HAVE_AARCH64_BE to be defined in config.h and
15# in include/libc-symbols.h and thus available to
16# shlib-versions to select the appropriate name for
17# the dynamic linker via %ifdef.
18AC_CACHE_CHECK([for big endian],
19  [libc_cv_aarch64_be],
20  [AC_EGREP_CPP(yes,[#ifdef __AARCH64EB__
21                      yes
22                     #endif
23  ], libc_cv_aarch64_be=yes, libc_cv_aarch64_be=no)])
24if test $libc_cv_aarch64_be = yes; then
25  AC_DEFINE(HAVE_AARCH64_BE)
26  LIBC_CONFIG_VAR([default-abi], [lp64_be])
27else
28  LIBC_CONFIG_VAR([default-abi], [lp64])
29fi
30
31# Only consider BTI supported if -mbranch-protection=bti is
32# on by default in the compiler and the linker produces
33# binaries with GNU property notes in PT_GNU_PROPERTY segment.
34AC_CACHE_CHECK([for BTI support], [libc_cv_aarch64_bti], [dnl
35  cat > conftest.c <<EOF
36void foo (void) { }
37EOF
38  libc_cv_aarch64_bti=no
39  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostdlib -nostartfiles $no_ssp -shared -fPIC -o conftest.so conftest.c]) \
40     && AC_TRY_COMMAND([$READELF -lW conftest.so | grep -q GNU_PROPERTY]) \
41     && AC_TRY_COMMAND([$READELF -nW conftest.so | grep -q "NT_GNU_PROPERTY_TYPE_0.*AArch64 feature:.* BTI"])
42  then
43    libc_cv_aarch64_bti=yes
44  fi
45  rm -rf conftest.*])
46LIBC_CONFIG_VAR([aarch64-bti], [$libc_cv_aarch64_bti])
47if test $libc_cv_aarch64_bti = yes; then
48  AC_DEFINE(HAVE_AARCH64_BTI)
49fi
50
51# Check if glibc is built with return address signing, i.e.
52# if -mbranch-protection=pac-ret is on. We need this because
53# pac-ret relies on unwinder support so it's not safe to use
54# it in assembly code unconditionally, but there is no
55# feature test macro for it in gcc.
56AC_CACHE_CHECK([if pac-ret is enabled], [libc_cv_aarch64_pac_ret], [dnl
57  cat > conftest.c <<EOF
58int bar (void);
59int foo (void) { return bar () + 1; }
60EOF
61  libc_cv_aarch64_pac_ret=no
62  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -o conftest.s conftest.c]) \
63     && AC_TRY_COMMAND([grep -q -E '\''(hint( |	)+25|paciasp)'\'' conftest.s])
64  then
65    libc_cv_aarch64_pac_ret=yes
66  fi
67  rm -rf conftest.*])
68if test $libc_cv_aarch64_pac_ret = yes; then
69  AC_DEFINE(HAVE_AARCH64_PAC_RET)
70fi
71
72# Check if binutils supports variant PCS symbols.
73AC_CACHE_CHECK([for variant PCS support], [libc_cv_aarch64_variant_pcs], [dnl
74  cat > conftest.S <<EOF
75.global foo
76.type foo, %function
77.variant_pcs foo
78foo:
79	ret
80.global bar
81.type bar, %function
82bar:
83	b foo
84EOF
85  libc_cv_aarch64_variant_pcs=no
86  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostdlib -nostartfiles $no_ssp -shared -fPIC -o conftest.so conftest.S]) \
87     && AC_TRY_COMMAND([$READELF -dW conftest.so | grep -q AARCH64_VARIANT_PCS])
88  then
89    libc_cv_aarch64_variant_pcs=yes
90  fi
91  rm -rf conftest.*])
92LIBC_CONFIG_VAR([aarch64-variant-pcs], [$libc_cv_aarch64_variant_pcs])
93
94# Check if asm support armv8.2-a+sve
95AC_CACHE_CHECK(for SVE support in assembler, libc_cv_asm_sve, [dnl
96cat > conftest.s <<\EOF
97        ptrue p0.b
98EOF
99if AC_TRY_COMMAND(${CC-cc} -c -march=armv8.2-a+sve conftest.s 1>&AS_MESSAGE_LOG_FD); then
100  libc_cv_aarch64_sve_asm=yes
101else
102  libc_cv_aarch64_sve_asm=no
103fi
104rm -f conftest*])
105if test $libc_cv_aarch64_sve_asm = yes; then
106  AC_DEFINE(HAVE_AARCH64_SVE_ASM)
107fi
108