about summary refs log tree commit diff
path: root/sysdeps/aarch64/configure.ac
blob: 27874eceb44911e4f5751ca870d37198f37a9869 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
# Local configure fragment for sysdeps/aarch64.

# Static PIE is supported.
AC_DEFINE(SUPPORT_STATIC_PIE)

# We check to see if the compiler and flags are
# selecting the big endian ABI and if they are then
# we set libc_cv_aarch64_be to yes which causes
# HAVE_AARCH64_BE to be defined in config.h and
# in include/libc-symbols.h and thus available to
# shlib-versions to select the appropriate name for
# the dynamic linker via %ifdef.
AC_CACHE_CHECK([for big endian],
  [libc_cv_aarch64_be],
  [AC_EGREP_CPP(yes,[#ifdef __AARCH64EB__
                      yes
                     #endif
  ], libc_cv_aarch64_be=yes, libc_cv_aarch64_be=no)])
if test $libc_cv_aarch64_be = yes; then
  AC_DEFINE(HAVE_AARCH64_BE)
  LIBC_CONFIG_VAR([default-abi], [lp64_be])
else
  LIBC_CONFIG_VAR([default-abi], [lp64])
fi

# Only consider BTI supported if -mbranch-protection=bti is
# on by default in the compiler and the linker produces
# binaries with GNU property notes in PT_GNU_PROPERTY segment.
AC_CACHE_CHECK([for BTI support], [libc_cv_aarch64_bti], [dnl
  cat > conftest.c <<EOF
void foo (void) { }
EOF
  libc_cv_aarch64_bti=no
  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostdlib -nostartfiles $no_ssp -shared -fPIC -o conftest.so conftest.c]) \
     && AC_TRY_COMMAND([$READELF -lW conftest.so | grep -q GNU_PROPERTY]) \
     && AC_TRY_COMMAND([$READELF -nW conftest.so | grep -q "NT_GNU_PROPERTY_TYPE_0.*AArch64 feature:.* BTI"])
  then
    libc_cv_aarch64_bti=yes
  fi
  rm -rf conftest.*])
LIBC_CONFIG_VAR([aarch64-bti], [$libc_cv_aarch64_bti])
if test $libc_cv_aarch64_bti = yes; then
  AC_DEFINE(HAVE_AARCH64_BTI)
fi

# Check if glibc is built with return address signing, i.e.
# if -mbranch-protection=pac-ret is on. We need this because
# pac-ret relies on unwinder support so it's not safe to use
# it in assembly code unconditionally, but there is no
# feature test macro for it in gcc.
AC_CACHE_CHECK([if pac-ret is enabled], [libc_cv_aarch64_pac_ret], [dnl
  cat > conftest.c <<EOF
int bar (void);
int foo (void) { return bar () + 1; }
EOF
  libc_cv_aarch64_pac_ret=no
  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -o conftest.s conftest.c]) \
     && AC_TRY_COMMAND([grep -q -E '\''(hint( |	)+25|paciasp)'\'' conftest.s])
  then
    libc_cv_aarch64_pac_ret=yes
  fi
  rm -rf conftest.*])
if test $libc_cv_aarch64_pac_ret = yes; then
  AC_DEFINE(HAVE_AARCH64_PAC_RET)
fi

# Check if binutils supports variant PCS symbols.
AC_CACHE_CHECK([for variant PCS support], [libc_cv_aarch64_variant_pcs], [dnl
  cat > conftest.S <<EOF
.global foo
.type foo, %function
.variant_pcs foo
foo:
	ret
.global bar
.type bar, %function
bar:
	b foo
EOF
  libc_cv_aarch64_variant_pcs=no
  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostdlib -nostartfiles $no_ssp -shared -fPIC -o conftest.so conftest.S]) \
     && AC_TRY_COMMAND([$READELF -dW conftest.so | grep -q AARCH64_VARIANT_PCS])
  then
    libc_cv_aarch64_variant_pcs=yes
  fi
  rm -rf conftest.*])
LIBC_CONFIG_VAR([aarch64-variant-pcs], [$libc_cv_aarch64_variant_pcs])

# Check if asm support armv8.2-a+sve
AC_CACHE_CHECK([for SVE support in assembler], [libc_cv_aarch64_sve_asm], [dnl
cat > conftest.s <<\EOF
        ptrue p0.b
EOF
if AC_TRY_COMMAND(${CC-cc} -c -march=armv8.2-a+sve conftest.s 1>&AS_MESSAGE_LOG_FD); then
  libc_cv_aarch64_sve_asm=yes
else
  libc_cv_aarch64_sve_asm=no
fi
rm -f conftest*])
if test $libc_cv_aarch64_sve_asm = yes; then
  AC_DEFINE(HAVE_AARCH64_SVE_ASM)
fi

if test x"$build_mathvec" = xnotset; then
  build_mathvec=yes
fi

# Check if compiler supports SVE ACLE.
AC_CACHE_CHECK(for availability of SVE ACLE, libc_cv_aarch64_sve_acle, [dnl
  cat > conftest.c <<EOF
#include <arm_sve.h>
EOF
  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -fsyntax-only -ffreestanding conftest.c]); then
    libc_cv_aarch64_sve_acle=yes
  else
    libc_cv_aarch64_sve_acle=no
  fi
  rm conftest.c])

# Check if compiler is sufficient to build mathvec
if test $build_mathvec = yes; then
  fail=no
  if test $libc_cv_aarch64_variant_pcs = no; then
    fail=yes
    AC_MSG_WARN([mathvec is enabled but linker does not support variant PCS.])
  fi
  if test $libc_cv_aarch64_sve_asm = no; then
    fail=yes
    AC_MSG_WARN([mathvec is enabled but assembler does not support SVE.])
  fi
  if test $libc_cv_aarch64_sve_acle = no; then
    fail=yes
    AC_MSG_WARN([mathvec is enabled but compiler does not have SVE ACLE.])
  fi
  if test $fail = yes; then
    AC_MSG_ERROR([use a compatible toolchain or configure with --disable-mathvec (this results in incomplete ABI).])
  fi
else
  AC_MSG_WARN([mathvec is disabled, this results in incomplete ABI.])
fi