elf/Makefile: Split and sort PIE tests
[glibc.git] / sysdeps / aarch64 / configure.ac
blob56d12d661d72689285a23dce5d84bf0182f5b13d
1 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2 # Local configure fragment for sysdeps/aarch64.
4 # Static PIE is supported.
5 AC_DEFINE(SUPPORT_STATIC_PIE)
7 # We check to see if the compiler and flags are
8 # selecting the big endian ABI and if they are then
9 # we set libc_cv_aarch64_be to yes which causes
10 # HAVE_AARCH64_BE to be defined in config.h and
11 # in include/libc-symbols.h and thus available to
12 # shlib-versions to select the appropriate name for
13 # the dynamic linker via %ifdef.
14 AC_CACHE_CHECK([for big endian],
15   [libc_cv_aarch64_be],
16   [AC_EGREP_CPP(yes,[#ifdef __AARCH64EB__
17                       yes
18                      #endif
19   ], libc_cv_aarch64_be=yes, libc_cv_aarch64_be=no)])
20 if test $libc_cv_aarch64_be = yes; then
21   AC_DEFINE(HAVE_AARCH64_BE)
22   LIBC_CONFIG_VAR([default-abi], [lp64_be])
23 else
24   LIBC_CONFIG_VAR([default-abi], [lp64])
27 # Only consider BTI supported if -mbranch-protection=bti is
28 # on by default in the compiler and the linker produces
29 # binaries with GNU property notes in PT_GNU_PROPERTY segment.
30 AC_CACHE_CHECK([for BTI support], [libc_cv_aarch64_bti], [dnl
31   cat > conftest.c <<EOF
32 void foo (void) { }
33 EOF
34   libc_cv_aarch64_bti=no
35   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostdlib -nostartfiles $no_ssp -shared -fPIC -o conftest.so conftest.c]) \
36      && AC_TRY_COMMAND([$READELF -lW conftest.so | grep -q GNU_PROPERTY]) \
37      && AC_TRY_COMMAND([$READELF -nW conftest.so | grep -q "NT_GNU_PROPERTY_TYPE_0.*AArch64 feature:.* BTI"])
38   then
39     libc_cv_aarch64_bti=yes
40   fi
41   rm -rf conftest.*])
42 LIBC_CONFIG_VAR([aarch64-bti], [$libc_cv_aarch64_bti])
43 if test $libc_cv_aarch64_bti = yes; then
44   AC_DEFINE(HAVE_AARCH64_BTI)
47 # Check if glibc is built with return address signing, i.e.
48 # if -mbranch-protection=pac-ret is on. We need this because
49 # pac-ret relies on unwinder support so it's not safe to use
50 # it in assembly code unconditionally, but there is no
51 # feature test macro for it in gcc.
52 AC_CACHE_CHECK([if pac-ret is enabled], [libc_cv_aarch64_pac_ret], [dnl
53   cat > conftest.c <<EOF
54 int bar (void);
55 int foo (void) { return bar () + 1; }
56 EOF
57   libc_cv_aarch64_pac_ret=no
58   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -o conftest.s conftest.c]) \
59      && AC_TRY_COMMAND([grep -q -E '\''(hint( | )+25|paciasp)'\'' conftest.s])
60   then
61     libc_cv_aarch64_pac_ret=yes
62   fi
63   rm -rf conftest.*])
64 if test $libc_cv_aarch64_pac_ret = yes; then
65   AC_DEFINE(HAVE_AARCH64_PAC_RET)
68 # Check if binutils supports variant PCS symbols.
69 AC_CACHE_CHECK([for variant PCS support], [libc_cv_aarch64_variant_pcs], [dnl
70   cat > conftest.S <<EOF
71 .global foo
72 .type foo, %function
73 .variant_pcs foo
74 foo:
75         ret
76 .global bar
77 .type bar, %function
78 bar:
79         b foo
80 EOF
81   libc_cv_aarch64_variant_pcs=no
82   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostdlib -nostartfiles $no_ssp -shared -fPIC -o conftest.so conftest.S]) \
83      && AC_TRY_COMMAND([$READELF -dW conftest.so | grep -q AARCH64_VARIANT_PCS])
84   then
85     libc_cv_aarch64_variant_pcs=yes
86   fi
87   rm -rf conftest.*])
88 LIBC_CONFIG_VAR([aarch64-variant-pcs], [$libc_cv_aarch64_variant_pcs])
90 # Check if asm support armv8.2-a+sve
91 AC_CACHE_CHECK([for SVE support in assembler], [libc_cv_aarch64_sve_asm], [dnl
92 cat > conftest.s <<\EOF
93         .arch armv8.2-a+sve
94         ptrue p0.b
95 EOF
96 if AC_TRY_COMMAND(${CC-cc} -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
97   libc_cv_aarch64_sve_asm=yes
98 else
99   libc_cv_aarch64_sve_asm=no
101 rm -f conftest*])
102 if test $libc_cv_aarch64_sve_asm = yes; then
103   AC_DEFINE(HAVE_AARCH64_SVE_ASM)
106 if test x"$build_mathvec" = xnotset; then
107   build_mathvec=yes
110 # Check if compiler supports SVE ACLE.
111 AC_CACHE_CHECK(for availability of SVE ACLE, libc_cv_aarch64_sve_acle, [dnl
112   cat > conftest.c <<EOF
113 #include <arm_sve.h>
115   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -fsyntax-only -ffreestanding conftest.c]); then
116     libc_cv_aarch64_sve_acle=yes
117   else
118     libc_cv_aarch64_sve_acle=no
119   fi
120   rm conftest.c])
122 # Check if compiler is sufficient to build mathvec
123 if test $build_mathvec = yes; then
124   fail=no
125   if test $libc_cv_aarch64_variant_pcs = no; then
126     fail=yes
127     AC_MSG_WARN([mathvec is enabled but linker does not support variant PCS.])
128   fi
129   if test $libc_cv_aarch64_sve_asm = no; then
130     fail=yes
131     AC_MSG_WARN([mathvec is enabled but assembler does not support SVE.])
132   fi
133   if test $libc_cv_aarch64_sve_acle = no; then
134     fail=yes
135     AC_MSG_WARN([mathvec is enabled but compiler does not have SVE ACLE.])
136   fi
137   if test $fail = yes; then
138     AC_MSG_ERROR([use a compatible toolchain or configure with --disable-mathvec (this results in incomplete ABI).])
139   fi
140 else
141   AC_MSG_WARN([mathvec is disabled, this results in incomplete ABI.])