Add --enable-static-pie configure option to build static PIE [BZ #19574]
[glibc.git] / sysdeps / x86_64 / configure.ac
blobb7d2c0124fbf678754872e5ec04b78fc406b1be9
1 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2 # Local configure fragment for sysdeps/x86_64.
4 dnl Check if asm supports AVX512DQ.
5 AC_CACHE_CHECK(for AVX512DQ support in assembler, libc_cv_asm_avx512dq, [dnl
6 cat > conftest.s <<\EOF
7         vandpd (%rax), %zmm6, %zmm1
8 EOF
9 if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
10   libc_cv_asm_avx512dq=yes
11 else
12   libc_cv_asm_avx512dq=no
14 rm -f conftest*])
15 if test $libc_cv_asm_avx512dq = yes; then
16   AC_DEFINE(HAVE_AVX512DQ_ASM_SUPPORT)
19 dnl Check if -mavx512f works.
20 AC_CACHE_CHECK(for AVX512 support, libc_cv_cc_avx512, [dnl
21 LIBC_TRY_CC_OPTION([-mavx512f], [libc_cv_cc_avx512=$libc_cv_asm_avx512dq], [libc_cv_cc_avx512=no])
23 if test $libc_cv_cc_avx512 = yes; then
24   AC_DEFINE(HAVE_AVX512_SUPPORT)
26 LIBC_CONFIG_VAR([config-cflags-avx512], [$libc_cv_cc_avx512])
28 dnl Check whether asm supports Intel MPX
29 AC_CACHE_CHECK(for Intel MPX support, libc_cv_asm_mpx, [dnl
30 cat > conftest.s <<\EOF
31         bndmov %bnd0,(%rsp)
32 EOF
33 if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
34   libc_cv_asm_mpx=yes
35 else
36   libc_cv_asm_mpx=no
38 rm -f conftest*])
39 if test $libc_cv_asm_mpx = yes; then
40   AC_DEFINE(HAVE_MPX_SUPPORT)
43 if test x"$build_mathvec" = xnotset; then
44   build_mathvec=yes
47 dnl Check if linker supports static PIE with the fix for
48 dnl
49 dnl https://sourceware.org/bugzilla/show_bug.cgi?id=21782
50 dnl
51 if test "$static_pie" = yes; then
52   AC_CACHE_CHECK(for linker static PIE support, libc_cv_ld_static_pie, [dnl
53 cat > conftest.s <<\EOF
54         .text
55         .global _start
56         .weak foo
57 _start:
58         leaq    foo(%rip), %rax
59 EOF
60   libc_cv_pie_option="-Wl,-pie"
61   if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib $no_ssp $libc_cv_pie_option -o conftest conftest.s 1>&AS_MESSAGE_LOG_FD); then
62     libc_cv_ld_static_pie=yes
63   else
64     libc_cv_ld_static_pie=no
65   fi
66 rm -f conftest*])
67   if test "$libc_cv_ld_static_pie" != yes; then
68     AC_MSG_ERROR([linker support for static PIE needed])
69   fi
72 dnl It is always possible to access static and hidden symbols in an
73 dnl position independent way.
74 AC_DEFINE(PI_STATIC_AND_HIDDEN)
76 test -n "$critic_missing" && AC_MSG_ERROR([
77 *** $critic_missing])