85c6f765082811f5e8312eebda8d615eabcf39a1
[platform/upstream/glibc.git] / sysdeps / aarch64 / configure.ac
1 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2 # Local configure fragment for sysdeps/aarch64.
3
4 # Static PIE is supported.
5 AC_DEFINE(SUPPORT_STATIC_PIE)
6
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])
25 fi
26
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)
45 fi
46
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)
66 fi
67
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])
89
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         ptrue p0.b
94 EOF
95 if AC_TRY_COMMAND(${CC-cc} -c -march=armv8.2-a+sve conftest.s 1>&AS_MESSAGE_LOG_FD); then
96   libc_cv_aarch64_sve_asm=yes
97 else
98   libc_cv_aarch64_sve_asm=no
99 fi
100 rm -f conftest*])
101 if test $libc_cv_aarch64_sve_asm = yes; then
102   AC_DEFINE(HAVE_AARCH64_SVE_ASM)
103 fi