riscv: Fix feenvupdate with FE_DFL_ENV (BZ 31022)
[glibc.git] / sysdeps / s390 / s390-64 / configure.ac
blob4657de0d3795f40388805d438178c63f9558e936
1 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2 # Local configure fragment for sysdeps/s390/s390-64.
4 # Bypass result of runtime configure check for known linker versions as
5 # e.g. crt-files or libc.so might not be available in bootstrapping
6 # environments.
7 case $($LD --version) in
8   "GNU gold"*)
9     # As of 2023-08-07, gold does not support static PIE due to
10     # Bug 22221 - add --no-dynamic-linker option
11     # https://sourceware.org/bugzilla/show_bug.cgi?id=22221
12     libc_cv_s390x_staticpie_req_version=no
13     ;;
14   "LLD"*)
15     # As of 2023-08-07, there is no lld which supports s390x.
16     libc_cv_s390x_staticpie_req_version=no
17     ;;
18   *)
19     # The required binutils patches are available with bintuils 2.39
20     libc_cv_s390x_staticpie_req_version=yes
21     # Skip AC_CHECK_PROGS and just use the result from main configure.ac.
22     libc_cv_s390x_staticpie_req_LD=$LD
23     AC_CHECK_PROG_VER(libc_cv_s390x_staticpie_req_LD, $LD, --version,
24                       [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
25                       [2.1[0-9][0-9]*|2.39*|2.[4-9][0-9]*|[3-9].*|[1-9][0-9]*],
26                       libc_cv_s390x_staticpie_req_version=no)
27     ;;
28 esac
29 AC_MSG_CHECKING([for s390-specific static PIE requirements (version check)])
30 AC_MSG_RESULT($libc_cv_s390x_staticpie_req_version)
32 # Minimal checking for static PIE support in ld.
33 # Compare to ld testcase/bugzilla:
34 # <binutils-source>/ld/testsuite/ld-elf/pr22263-1.rd
35 AC_CACHE_CHECK([for s390-specific static PIE requirements (runtime check)], \
36 [libc_cv_s390x_staticpie_req_runtime], [dnl
37   cat > conftest1.c <<EOF
38 __thread int * foo;
40 void
41 bar (void)
43   *foo = 1;
45 EOF
46   cat > conftest2.c <<EOF
47 extern __thread int *foo;
48 extern void bar (void);
49 static int x;
51 int
52 main ()
54   foo = &x;
55   return 0;
57 EOF
58   libc_cv_s390x_staticpie_req_runtime=no
59   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fPIE -c conftest1.c -o conftest1.o]) \
60      && AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fPIE -c conftest2.c -o conftest2.o]) \
61      && AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -o conftest conftest1.o conftest2.o]) \
62      && AC_TRY_COMMAND([! LC_ALL=C $READELF -Wr conftest | grep R_390_TLS_TPOFF])
63   then
64     libc_cv_s390x_staticpie_req_runtime=yes
65   fi
66   rm -rf conftest.*])
68 if test $libc_cv_s390x_staticpie_req_runtime = yes \
69    || test $libc_cv_s390x_staticpie_req_version = yes; then
70    # Static PIE is supported only on 64bit.
71    # Ensure you also have those patches for:
72    # - binutils (ld)
73    #   - "[PR ld/22263] s390: Avoid dynamic TLS relocs in PIE"
74    #     https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=26b1426577b5dcb32d149c64cca3e603b81948a9
75    #     (Tested by configure check above)
76    #     Otherwise there will be a R_390_TLS_TPOFF relocation, which fails to
77    #     be processed in _dl_relocate_static_pie() as static TLS map is not setup.
78    #   - "s390: Add DT_JMPREL pointing to .rela.[i]plt with static-pie"
79    #     https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d942d8db12adf4c9e5c7d9ed6496a779ece7149e
80    #     (We can't test it in configure as we are not able to link a static PIE
81    #     executable if the system glibc lacks static PIE support)
82    #     Otherwise there won't be DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ entries
83    #     and the IFUNC symbols are not processed, which leads to crashes.
84    #
85    # - kernel (the mentioned links to the commits belong to 5.19 merge window):
86    #   - "s390/mmap: increase stack/mmap gap to 128MB"
87    #     https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=f2f47d0ef72c30622e62471903ea19446ea79ee2
88    #   - "s390/vdso: move vdso mapping to its own function"
89    #     https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=57761da4dc5cd60bed2c81ba0edb7495c3c740b8
90    #   - "s390/vdso: map vdso above stack"
91    #     https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=9e37a2e8546f9e48ea76c839116fa5174d14e033
92    #   - "s390/vdso: add vdso randomization"
93    #     https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=41cd81abafdc4e58a93fcb677712a76885e3ca25
94    #   (We can't test the kernel of the target system)
95    #   Otherwise if /proc/sys/kernel/randomize_va_space is turned off (0),
96    #   static PIE executables like ldconfig will crash.  While startup sbrk is
97    #   used to enlarge the HEAP.  Unfortunately the underlying brk syscall fails
98    #   as there is not enough space after the HEAP.  Then the address of the TLS
99    #   image is invalid and the following memcpy in __libc_setup_tls() leads
100    #   to a segfault.
101    #   If /proc/sys/kernel/randomize_va_space is activated (default: 2), there
102    #   is enough space after HEAP.
103    #
104    # - glibc
105    #   - "Linux: Define MMAP_CALL_INTERNAL"
106    #     https://sourceware.org/git/?p=glibc.git;a=commit;h=c1b68685d438373efe64e5f076f4215723004dfb
107    #   - "i386: Remove OPTIMIZE_FOR_GCC_5 from Linux libc-do-syscall.S"
108    #     https://sourceware.org/git/?p=glibc.git;a=commit;h=6e5c7a1e262961adb52443ab91bd2c9b72316402
109    #   - "i386: Honor I386_USE_SYSENTER for 6-argument Linux system calls"
110    #     https://sourceware.org/git/?p=glibc.git;a=commit;h=60f0f2130d30cfd008ca39743027f1e200592dff
111    #   - "ia64: Always define IA64_USE_NEW_STUB as a flag macro"
112    #     https://sourceware.org/git/?p=glibc.git;a=commit;h=18bd9c3d3b1b6a9182698c85354578d1d58e9d64
113    #   - "Linux: Implement a useful version of _startup_fatal"
114    #     https://sourceware.org/git/?p=glibc.git;a=commit;h=a2a6bce7d7e52c1c34369a7da62c501cc350bc31
115    #   - "Linux: Introduce __brk_call for invoking the brk system call"
116    #     https://sourceware.org/git/?p=glibc.git;a=commit;h=b57ab258c1140bc45464b4b9908713e3e0ee35aa
117    #   - "csu: Implement and use _dl_early_allocate during static startup"
118    #     https://sourceware.org/git/?p=glibc.git;a=commit;h=f787e138aa0bf677bf74fa2a08595c446292f3d7
119    #   The mentioned patch series by Florian Weimer avoids the mentioned failing
120    #   sbrk syscall by falling back to mmap.
121    AC_DEFINE(SUPPORT_STATIC_PIE)