1 dnl Process this file with autoconf to produce a configure script.
2 dnl Note we do not use AC_PREREQ here! See aclocal.m4 for what we use instead.
3 AC_INIT([GNU C Library], [(see version.h)], [https://sourceware.org/bugzilla/],
4 [glibc], [https://www.gnu.org/software/glibc/])
5 AC_CONFIG_SRCDIR([include/features.h])
6 AC_CONFIG_HEADERS([config.h])
7 AC_CONFIG_AUX_DIR([scripts])
9 ACX_PKGVERSION([GNU libc])
10 ACX_BUGURL([https://www.gnu.org/software/libc/bugs.html])
11 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"],
12 [Package description])
13 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"],
14 [Bug reporting address])
16 # Glibc should not depend on any header files
17 AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
18 [m4_divert_text([DEFAULTS],
19 [ac_includes_default='/* none */'])])
21 # We require GCC, and by default use its preprocessor. Override AC_PROG_CPP
22 # here to work around the Autoconf issue discussed in
23 # <https://sourceware.org/ml/libc-alpha/2013-01/msg00721.html>.
24 AC_DEFUN([AC_PROG_CPP],
25 [AC_REQUIRE([AC_PROG_CC])dnl
26 AC_ARG_VAR([CPP], [C preprocessor])dnl
27 _AC_ARG_VAR_CPPFLAGS()dnl
28 # On Suns, sometimes $CPP names a directory.
29 if test -n "$CPP" && test -d "$CPP"; then
32 if test -z "$CPP"; then
38 # We require GCC. Override _AC_PROG_CC_C89 here to work around the Autoconf
40 # <https://sourceware.org/ml/libc-alpha/2013-01/msg00757.html>.
41 AC_DEFUN([_AC_PROG_CC_C89], [[$1]])
43 dnl This is here so we can set $subdirs directly based on configure fragments.
50 [C compiler for testing])
51 if test -z "$TEST_CC"; then
54 if test $host != $build; then
55 AC_CHECK_PROGS(BUILD_CC, gcc cc)
57 AC_SUBST(cross_compiling)
60 # This will get text that should go into config.make.
63 AC_ARG_ENABLE([static-c++-tests],
64 AS_HELP_STRING([--disable-static-c++-tests],
65 [disable static C++ tests@<:@default=no@:>@]),
66 [static_cxx_tests=$enableval],
67 [static_cxx_tests=yes])
68 LIBC_CONFIG_VAR([static-cxx-tests], [$static_cxx_tests])
70 AC_ARG_ENABLE([static-c++-link-check],
71 AS_HELP_STRING([--disable-static-c++-link-check],
72 [disable static C++ link check @<:@default=no@:>@]),
73 [static_cxx_link_check=$enableval],
74 [static_cxx_link_check=yes])
76 # We need the C++ compiler for testing and libsupport.
78 AC_ARG_VAR([TEST_CXX],
79 [C++ compiler for testing])
81 if test -z "$TEST_CXX"; then
86 # It's useless to us if it can't link programs (e.g. missing -lstdc++).
87 AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl
89 # Default, dynamic case.
90 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
91 [libc_cv_cxx_link_ok=yes],
92 [libc_cv_cxx_link_ok=no])
93 if test $static_cxx_link_check$static_cxx_tests = yesyes; then
95 old_LDFLAGS="$LDFLAGS"
96 LDFLAGS="$LDFLAGS -static"
97 AC_LINK_IFELSE([AC_LANG_SOURCE([
103 std::cout << "Hello, world!";
108 [libc_cv_cxx_link_ok=no])
109 LDFLAGS="$old_LDFLAGS"
113 AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=; TEST_CXX=])
115 if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
116 AC_MSG_ERROR([you must configure in a separate build directory])
119 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
121 AS_HELP_STRING([--with-gd=DIR],
122 [find libgd include dir and library with prefix DIR]),
126 *) libgd_include="-I$withval/include"
127 libgd_ldflags="-L$withval/lib" ;;
130 AC_ARG_WITH([gd-include],
131 AS_HELP_STRING([--with-gd-include=DIR],
132 [find libgd include files in DIR]),
134 case "$with_gd_include" in
136 *) libgd_include="-I$withval" ;;
139 AC_ARG_WITH([gd-lib],
140 AS_HELP_STRING([--with-gd-lib=DIR],
141 [find libgd library files in DIR]),
143 case "$with_gd_lib" in
145 *) libgd_ldflags="-L$withval" ;;
149 if test -n "$libgd_include"; then
150 config_vars="$config_vars
151 CFLAGS-memusagestat.c = $libgd_include"
153 if test -n "$libgd_ldflags"; then
154 config_vars="$config_vars
155 libgd-LDFLAGS = $libgd_ldflags"
158 dnl Arguments to specify presence of other packages/features.
159 AC_ARG_WITH([binutils],
160 AS_HELP_STRING([--with-binutils=PATH],
161 [specify location of binutils (as and ld)]),
162 [path_binutils=$withval],
164 AC_ARG_WITH([selinux],
165 AS_HELP_STRING([--with-selinux],
166 [if building with SELinux support]),
167 [with_selinux=$withval],
170 AC_ARG_WITH([headers],
171 AS_HELP_STRING([--with-headers=PATH],
172 [location of system headers to use
173 (for example /usr/src/linux/include)
174 @<:@default=compiler default@:>@]),
175 [sysheaders=$withval],
179 dnl Additional build flags injection.
180 AC_ARG_WITH([nonshared-cflags],
181 AS_HELP_STRING([--with-nonshared-cflags=CFLAGS],
182 [build nonshared libraries with additional CFLAGS]),
183 [extra_nonshared_cflags=$withval],
184 [extra_nonshared_cflags=])
185 AC_SUBST(extra_nonshared_cflags)
186 AC_ARG_WITH([rtld-early-cflags],
187 AS_HELP_STRING([--with-rtld-early-cflags=CFLAGS],
188 [build early initialization with additional CFLAGS]),
189 [rtld_early_cflags=$withval],
190 [rtld_early_cflags=])
191 AC_SUBST(rtld_early_cflags)
193 AC_ARG_WITH([timeoutfactor],
194 AS_HELP_STRING([--with-timeoutfactor=NUM],
195 [specify an integer to scale the timeout]),
196 [timeoutfactor=$withval],
198 AC_DEFINE_UNQUOTED(TIMEOUTFACTOR, $timeoutfactor)
200 man_pages_version=6.9.1
202 AC_ARG_WITH([man-pages],
203 AS_HELP_STRING([--with-man-pages=VERSION],
204 [tie manual to a specific man-pages version]),
205 [man_pages_version=$withval],
207 AC_SUBST(man_pages_version)
209 AC_ARG_ENABLE([sanity-checks],
210 AS_HELP_STRING([--disable-sanity-checks],
211 [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
212 [enable_sanity=$enableval],
215 AC_ARG_ENABLE([shared],
216 AS_HELP_STRING([--enable-shared],
217 [build shared library @<:@default=yes if GNU ld@:>@]),
220 AC_ARG_ENABLE([profile],
221 AS_HELP_STRING([--enable-profile],
222 [build profiled library @<:@default=no@:>@]),
223 [profile=$enableval],
225 AC_ARG_ENABLE([default-pie],
226 AS_HELP_STRING([--disable-default-pie],
227 [Do not build glibc programs and the testsuite as PIE @<:@default=no@:>@]),
228 [default_pie=$enableval],
230 AC_ARG_ENABLE([timezone-tools],
231 AS_HELP_STRING([--disable-timezone-tools],
232 [do not install timezone tools @<:@default=install@:>@]),
233 [enable_timezone_tools=$enableval],
234 [enable_timezone_tools=yes])
235 AC_SUBST(enable_timezone_tools)
237 AC_ARG_ENABLE([hardcoded-path-in-tests],
238 AS_HELP_STRING([--enable-hardcoded-path-in-tests],
239 [hardcode newly built glibc path in tests @<:@default=no@:>@]),
240 [hardcoded_path_in_tests=$enableval],
241 [hardcoded_path_in_tests=no])
242 AC_SUBST(hardcoded_path_in_tests)
244 AC_ARG_ENABLE([hidden-plt],
245 AS_HELP_STRING([--disable-hidden-plt],
246 [do not hide internal function calls to avoid PLT]),
249 if test "x$hidden" = xno; then
253 AC_ARG_ENABLE([bind-now],
254 AS_HELP_STRING([--enable-bind-now],
255 [disable lazy relocations in DSOs]),
256 [bindnow=$enableval],
259 if test "x$bindnow" = xyes; then
263 dnl Build glibc with -fstack-protector, -fstack-protector-all, or
264 dnl -fstack-protector-strong.
265 AC_ARG_ENABLE([stack-protector],
266 AS_HELP_STRING([--enable-stack-protector=@<:@yes|no|all|strong@:>@],
267 [Use -fstack-protector[-all|-strong] to detect glibc buffer overflows]),
268 [enable_stack_protector=$enableval],
269 [enable_stack_protector=no])
270 case "$enable_stack_protector" in
271 all|yes|no|strong) ;;
272 *) AC_MSG_ERROR([Not a valid argument for --enable-stack-protector: "$enable_stack_protector"]);;
275 dnl On some platforms we cannot use dynamic loading. We must provide
276 dnl static NSS modules.
277 AC_ARG_ENABLE([static-nss],
278 AS_HELP_STRING([--enable-static-nss],
279 [build static NSS modules @<:@default=no@:>@]),
280 [static_nss=$enableval],
282 dnl Enable static NSS also if we build no shared objects.
283 if test x"$static_nss" = xyes || test x"$shared" = xno; then
285 AC_DEFINE(DO_STATIC_NSS)
288 AC_ARG_ENABLE([force-install],
289 AS_HELP_STRING([--disable-force-install],
290 [don't force installation of files from this package, even if they are older than the installed files]),
291 [force_install=$enableval],
293 AC_SUBST(force_install)
295 AC_ARG_ENABLE([maintainer-mode],
296 AS_HELP_STRING([--enable-maintainer-mode],
297 [enable make rules and dependencies not useful (and sometimes confusing) to the casual installer]),
298 [maintainer=$enableval],
301 dnl On some platforms we allow dropping compatibility with all kernel
303 AC_ARG_ENABLE([kernel],
304 AS_HELP_STRING([--enable-kernel=VERSION],
305 [compile for compatibility with kernel not older than VERSION]),
306 [minimum_kernel=$enableval],
308 dnl Prevent unreasonable values.
309 if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
310 # Better nothing than this.
313 if test "$minimum_kernel" = current; then
314 minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
318 AC_ARG_ENABLE([werror],
319 AS_HELP_STRING([--disable-werror],
320 [do not build with -Werror]),
321 [enable_werror=$enableval],
323 AC_SUBST(enable_werror)
325 AC_ARG_ENABLE([multi-arch],
326 AS_HELP_STRING([--enable-multi-arch],
327 [enable single DSO with optimizations for multiple architectures]),
328 [multi_arch=$enableval],
329 [multi_arch=default])
331 AC_ARG_ENABLE([memory-tagging],
332 AS_HELP_STRING([--enable-memory-tagging],
333 [enable memory tagging if supported by the architecture @<:@default=no@:>@]),
334 [memory_tagging=$enableval],
336 if test "$memory_tagging" = yes; then
337 # Only enable this on architectures that support it.
344 AC_SUBST(memory_tagging)
346 AC_ARG_ENABLE([systemtap],
347 [AS_HELP_STRING([--enable-systemtap],
348 [enable systemtap static probe points @<:@default=no@:>@])],
349 [systemtap=$enableval],
351 if test "x$systemtap" != xno; then
352 AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
354 CFLAGS="-std=gnu11 $CFLAGS"
355 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
356 void foo (int i, void *p)
358 asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
359 :: STAP_PROBE_ASM_OPERANDS (2, i, p));
360 }]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
361 CFLAGS="$old_CFLAGS"])
362 if test $libc_cv_sdt = yes; then
363 AC_DEFINE([USE_STAP_PROBE])
364 elif test "x$systemtap" != xauto; then
365 AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
369 AC_ARG_ENABLE([build-nscd],
370 [AS_HELP_STRING([--disable-build-nscd],
371 [disable building and installing the nscd daemon])],
372 [build_nscd=$enableval],
373 [build_nscd=default])
376 # Note the use of $use_nscd is near the bottom of the file.
377 AC_ARG_ENABLE([nscd],
378 [AS_HELP_STRING([--disable-nscd],
379 [library functions will not contact the nscd daemon])],
380 [use_nscd=$enableval],
383 AC_ARG_ENABLE([pt_chown],
384 [AS_HELP_STRING([--enable-pt_chown],
385 [Enable building and installing pt_chown])],
386 [build_pt_chown=$enableval],
388 AC_SUBST(build_pt_chown)
389 if test "$build_pt_chown" = yes; then
390 AC_DEFINE(HAVE_PT_CHOWN)
393 # The abi-tags file uses a fairly simplistic model for name recognition that
394 # can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
395 # $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
396 # This doesn't get used much beyond that, so it's fairly safe.
401 host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
405 AC_ARG_ENABLE([mathvec],
406 [AS_HELP_STRING([--enable-mathvec],
407 [Enable building and installing mathvec @<:@default depends on architecture@:>@])],
408 [build_mathvec=$enableval],
409 [build_mathvec=notset])
411 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
413 # error no CET compiler support
415 [libc_cv_compiler_default_cet=yes],
416 [libc_cv_compiler_default_cet=no])
419 AS_HELP_STRING([--enable-cet],
420 [enable Intel Control-flow Enforcement Technology (CET), x86 only]),
421 [enable_cet=$enableval],
422 [enable_cet=$libc_cv_compiler_default_cet])
425 AS_HELP_STRING([--disable-scv],
426 [syscalls will not use scv instruction, even if the kernel supports it, powerpc only]),
427 [use_scv=$enableval],
430 AS_IF([[test "$use_scv" != "no"]],[AC_DEFINE(USE_PPC_SCV)])
432 dnl Build glibc with _FORTIFY_SOURCE
433 AC_ARG_ENABLE(fortify-source,
434 AS_HELP_STRING([--enable-fortify-source@<:@=1|2|3@:>@],
435 [Use -D_FORTIFY_SOURCE=[1|2|3] to control code hardening, defaults to highest possible value supported by the build compiler.]),
436 [enable_fortify_source=$enableval],
437 [enable_fortify_source=no])
438 case "$enable_fortify_source" in
440 *) AC_MSG_ERROR([Not a valid argument for --enable-fortify-source: "$enable_fortify_source"]);;
443 # We keep the original values in `$config_*' and never modify them, so we
444 # can write them unchanged into config.make. Everything else uses
445 # $machine, $vendor, and $os, and changes them whenever convenient.
446 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
448 # Don't allow vendor == "unknown"
449 test "$config_vendor" = unknown && config_vendor=
450 config_os="`echo $config_os | sed 's/^unknown-//'`"
452 # Some configurations imply other options.
455 # The configure fragment of a port can modify these to supplement
456 # or override the table in the case statement below. No fragment should
457 # ever change the config_* variables, however.
458 machine=$config_machine
459 vendor=$config_vendor
465 AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
468 yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
470 *) submachine="$withval" ;;
474 # An preconfigure script can set this when it wants to disable the sanity
478 # A preconfigure script for a system that may or may not use fpu
479 # sysdeps directories sets this to a preprocessor conditional for
480 # whether to use such directories.
483 # A preconfigure script may define another name to TLS descriptor variant
486 dnl Let sysdeps/*/preconfigure act here.
487 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
491 ### By using the undocumented --enable-hacker-mode option for configure
492 ### one can skip this test to make the configuration not fail for unsupported
495 if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
496 case "$machine-$host_os" in
501 *** The GNU C library is currently unavailable for this platform.
502 *** If you are interested in seeing glibc on this platform visit
503 *** the "How to submit a new port" in the wiki:
504 *** https://sourceware.org/glibc/wiki/#Development
505 *** and join the community!])
510 # Set base_machine if not set by a preconfigure fragment.
511 test -n "$base_machine" || base_machine=$machine
512 AC_SUBST(base_machine)
517 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
518 # The makefiles need to use a different form to find it in $srcdir.
519 INSTALL='\$(..)./scripts/install-sh -c'
525 # Accept binutils 2.25 or newer.
527 case $($LD --version) in
529 # Accept gold 1.14 or higher
530 AC_CHECK_PROG_VER(LD, $LD, --version,
531 [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
532 [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
533 LD=: critic_missing="$critic_missing GNU gold")
536 # Accept LLD 13.0.0 or higher
537 AC_CHECK_PROG_VER(LD, $LD, --version,
538 [LLD.* \([0-9][0-9]*\.[0-9.]*\)],
539 [1[3-9].*|[2-9][0-9].*],
540 LD=: critic_missing="$critic_missing LLD")
544 AC_CHECK_PROG_VER(LD, $LD, --version,
545 [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
546 [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
547 LD=: critic_missing="$critic_missing GNU ld")
550 LIBC_CONFIG_VAR([with-lld], [$libc_cv_with_lld])
552 # These programs are version sensitive.
553 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
554 [GNU Make[^0-9]*\([0-9][0-9.]*\)],
555 [[4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
557 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
558 [GNU gettext.* \([0-9]*\.[0-9.]*\)],
559 [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
560 MSGFMT=: aux_missing="$aux_missing msgfmt")
561 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
562 [GNU texinfo.* \([0-9][0-9.]*\)],
563 [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
564 MAKEINFO=: aux_missing="$aux_missing makeinfo")
565 AC_CHECK_PROG_VER(SED, sed, --version,
566 [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
567 [3.0[2-9]*|3.[1-9]*|[4-9]*],
568 SED=: aux_missing="$aux_missing sed")
569 AC_CHECK_PROG_VER(AWK, gawk, --version,
570 [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
571 [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
572 AC_CHECK_PROG_VER(BISON, bison, --version,
573 [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
574 [2.7*|[3-9].*|[1-9][0-9]*], critic_missing="$critic_missing bison")
576 AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
577 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
578 #if !defined __GNUC__ || __GNUC__ < 6 || (__GNUC__ == 6 && __GNUC_MINOR__ < 2)
579 #error insufficient compiler
581 [libc_cv_compiler_ok=yes],
582 [libc_cv_compiler_ok=no])])
583 AS_IF([test $libc_cv_compiler_ok != yes],
584 [critic_missing="$critic_missing compiler"])
586 if test "x$maintainer" = "xyes"; then
587 AC_CHECK_PROGS(AUTOCONF, autoconf, no)
589 xno|x|x:) AUTOCONF=no ;;
592 whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
593 if (cd $srcdir; $AUTOCONF $ACFLAGS configure.ac > /dev/null 2>&1); then
594 libc_cv_autoconf_works=yes
596 libc_cv_autoconf_works=no
598 test $libc_cv_autoconf_works = yes || AUTOCONF=no
601 if test "x$AUTOCONF" = xno; then
602 aux_missing="$aux_missing autoconf"
608 # Check for python3 if available, or else python.
609 AC_CHECK_PROG_VER(PYTHON_PROG, python3 python, --version,
610 [Python \([0-9][0-9.]*\)],
611 [3.[4-9]*|3.[1-9][0-9]*|[4-9].*|[1-9][0-9]*],
612 critic_missing="$critic_missing python")
613 PYTHON="$PYTHON_PROG -B"
616 test -n "$critic_missing" && AC_MSG_ERROR([
617 *** These critical programs are missing or too old:$critic_missing
618 *** Check the INSTALL file for required versions.])
620 test -n "$aux_missing" && AC_MSG_WARN([
621 *** These auxiliary programs are missing or incompatible versions:$aux_missing
622 *** some features or tests will be disabled.
623 *** Check the INSTALL file for required versions.])
626 # Determine whether to use fpu or nofpu sysdeps directories.
627 AC_CACHE_CHECK([for use of fpu sysdeps directories],
628 libc_cv_with_fp, [dnl
629 cat > conftest.c <<EOF
633 # error "no hardware floating point"
637 if ${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c -o conftest.s \
638 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
642 AC_SUBST(libc_cv_with_fp)
650 dnl Check if clang is used to test glibc.
651 LIBC_TRY_TEST_CC_COMMAND([for clang],
655 [libc_cv_test_clang=yes], [libc_cv_test_clang=no],
657 LIBC_CONFIG_VAR([have-test-clang], [$libc_cv_test_clang])
659 dnl Check if clang++ is used to test glibc.
660 LIBC_TRY_TEST_CXX_COMMAND([for clang++],
663 libc_cv_test_clangxx,
664 [libc_cv_test_clangxx=yes], [libc_cv_test_clangxx=no],
666 LIBC_CONFIG_VAR([have-test-clangxx], [$libc_cv_test_clangxx])
668 if test "$libc_cv_test_clang" = "yes"; then
670 #if __clang_major__ > 19
671 #error clang version > 19
674 LIBC_TRY_TEST_CC_COMMAND([for clang],
677 libc_cv_test_clang_19_or_less,
678 [libc_cv_test_clang_19_or_less=yes], [libc_cv_test_clang_19_or_less=no],
681 LIBC_CONFIG_VAR([have-test-clang-19-or-less], [$libc_cv_test_clang_19_or_less])
683 LIBC_TRY_CC_AND_TEST_CC_OPTION([for -fstack-protector],
684 [-Werror -fstack-protector],
689 [libc_cv_test_ssp=yes],
690 [libc_cv_test_ssp=no])
692 AC_CACHE_CHECK(for -fstack-protector-strong, libc_cv_ssp_strong, [dnl
693 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-strong],
694 [libc_cv_ssp_strong=yes],
695 [libc_cv_ssp_strong=no])
698 AC_CACHE_CHECK(for -fstack-protector-all, libc_cv_ssp_all, [dnl
699 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-all],
700 [libc_cv_ssp_all=yes],
701 [libc_cv_ssp_all=no])
706 if test "$libc_cv_ssp" = yes; then
707 no_stack_protector="-fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0"
708 AC_DEFINE(HAVE_CC_NO_STACK_PROTECTOR)
710 if test "$libc_cv_test_ssp" = yes; then
711 AC_DEFINE(HAVE_TEST_CC_NO_STACK_PROTECTOR)
715 if test "$enable_stack_protector" = yes && test "$libc_cv_ssp" = yes; then
716 stack_protector="-fstack-protector"
717 AC_DEFINE(STACK_PROTECTOR_LEVEL, 1)
718 elif test "$enable_stack_protector" = all && test "$libc_cv_ssp_all" = yes; then
719 stack_protector="-fstack-protector-all"
720 AC_DEFINE(STACK_PROTECTOR_LEVEL, 2)
721 elif test "$enable_stack_protector" = strong && test "$libc_cv_ssp_strong" = yes; then
722 stack_protector="-fstack-protector-strong"
723 AC_DEFINE(STACK_PROTECTOR_LEVEL, 3)
725 stack_protector="-fno-stack-protector"
726 AC_DEFINE(STACK_PROTECTOR_LEVEL, 0)
728 AC_SUBST(libc_cv_ssp)
729 AC_SUBST(stack_protector)
730 AC_SUBST(no_stack_protector)
732 if test -n "$stack_protector"; then
733 dnl Don't run configure tests with stack-protection on, to avoid problems with
735 no_ssp=-fno-stack-protector
739 if test "$enable_stack_protector" != no; then
740 AC_MSG_ERROR([--enable-stack-protector=$enable_stack_protector specified, but specified level of stack protection is not supported by the compiler.])
744 # For the multi-arch option we need support in the assembler & linker.
745 AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
746 libc_cv_ld_gnu_indirect_function, [dnl
747 cat > conftest.S <<EOF
748 .type foo,%gnu_indirect_function
761 libc_cv_ld_gnu_indirect_function=no
762 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
763 -nostartfiles -nostdlib $no_ssp \
764 -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
765 # Do a link to see if the backend supports IFUNC relocs.
766 $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
767 LC_ALL=C $READELF -Wr conftest | grep -q 'IRELATIVE\|R_SPARC_JMP_IREL' && {
768 libc_cv_ld_gnu_indirect_function=yes
773 # Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
774 AC_CACHE_CHECK([for gcc attribute ifunc support],
775 libc_cv_gcc_indirect_function, [dnl
776 cat > conftest.c <<EOF
777 extern int func (int);
778 int used_func (int a)
782 static void *resolver ()
786 extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
788 libc_cv_gcc_indirect_function=no
789 if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
790 2>&AS_MESSAGE_LOG_FD ; then
791 if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&AS_MESSAGE_LOG_FD; then
792 libc_cv_gcc_indirect_function=yes
797 # Check if linker supports textrel relocation with ifunc (used on elf/tests).
798 # Note that it relies on libc_cv_ld_gnu_indirect_function test above.
799 AC_CACHE_CHECK([whether the linker supports textrels along with ifunc],
800 libc_cv_textrel_ifunc, [dnl
801 cat > conftest.S <<EOF
802 .type foo,%gnu_indirect_function
823 libc_cv_textrel_ifunc=no
824 if test $libc_cv_ld_gnu_indirect_function = yes; then
825 if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib $no_ssp -pie -o conftest conftest.S); then
826 libc_cv_textrel_ifunc=yes
830 AC_SUBST(libc_cv_textrel_ifunc)
832 # Check if CC supports attribute retain as it is used in attribute_used_retain macro.
833 AC_CACHE_CHECK([for GNU attribute retain support],
834 libc_cv_gnu_retain, [dnl
835 cat > conftest.c <<EOF
836 static int var __attribute__ ((used, retain, section ("__libc_atexit")));
838 libc_cv_gnu_retain=no
839 if ${CC-cc} -Werror -c conftest.c -o /dev/null 1>&AS_MESSAGE_LOG_FD \
840 2>&AS_MESSAGE_LOG_FD ; then
841 libc_cv_gnu_retain=yes
844 if test $libc_cv_gnu_retain = yes; then
845 AC_DEFINE(HAVE_GNU_RETAIN)
847 LIBC_CONFIG_VAR([have-gnu-retain], [$libc_cv_gnu_retain])
849 # Check if gcc warns about alias for function with incompatible types.
850 AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
851 libc_cv_gcc_incompatible_alias, [dnl
852 cat > conftest.c <<EOF
853 int __redirect_foo (const void *s, int c);
855 __typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
856 __typeof (__redirect_foo) *foo_impl (void)
861 extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
863 libc_cv_gcc_incompatible_alias=yes
864 if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
865 libc_cv_gcc_incompatible_alias=no
869 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
870 if test x"$multi_arch" = xyes; then
871 AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
876 if test x"$libc_cv_gcc_indirect_function" != xyes; then
877 # GCC 8+ emits a warning for alias with incompatible types and it might
878 # fail to build ifunc resolvers aliases to either weak or internal
879 # symbols. Disables multiarch build in this case.
880 if test x"$libc_cv_gcc_incompatible_alias" = xyes; then
881 AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types])
882 if test x"$multi_arch" = xyes; then
883 AC_MSG_ERROR([--enable-multi-arch support requires a gcc with gnu-indirect-function support])
885 AC_MSG_WARN([Multi-arch is disabled.])
887 elif test x"$multi_arch" = xyes; then
888 AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
889 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
893 if test x"$multi_arch" != xno; then
894 multi_arch_d=/multiarch
897 # Compute the list of sysdep directories for this configuration.
898 # This can take a while to compute.
899 sysdep_dir=$srcdir/sysdeps
900 AC_MSG_CHECKING(sysdep dirs)
901 dnl We need to use [ and ] for other purposes for a while now.
903 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
904 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
906 test "x$base_os" != x || case "$os" in
913 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
916 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
920 o=`echo $tail | sed 's/[0-9]*$//'`
921 if test $o != $tail; then
924 # For linux-gnu, try linux-gnu, then linux.
925 o=`echo $tail | sed 's/-.*$//'`
926 if test $o != $tail; then
930 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
933 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
939 # For sparc/sparc32, try sparc/sparc32 and then sparc.
941 tail=$machine${submachine:+/$submachine}
942 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
944 # Prepend the machine's FPU directory unless the architecture specific
945 # preconfigure disables it.
946 if test "$libc_cv_with_fp" = yes; then
951 # For each machine term, try it with and then without /multiarch.
952 for try_fpu in $maybe_fpu ''; do
953 for try_multi in $multi_arch_d ''; do
954 mach="$mach /$1$try_fpu$try_multi"
960 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
963 # Find what sysdep directories exist.
965 for b in $base ''; do
966 for m0 in $mach ''; do
967 for v in /$vendor ''; do
968 test "$v" = / && continue
969 for o in /$ostry ''; do
970 test "$o" = / && continue
971 for m in $mach ''; do
972 try_suffix="$m0$b$v$o$m"
973 if test -n "$try_suffix"; then
974 try_srcdir="${srcdir}/"
975 try="sysdeps$try_suffix"
976 test -n "$enable_debug_configure" &&
977 echo "$0 [DEBUG]: try $try" >&2
978 if test -d "$try_srcdir$try"; then
979 sysnames="$sysnames $try"
980 { test -n "$o" || test -n "$b"; } && os_used=t
981 { test -n "$m" || test -n "$m0"; } && machine_used=t
983 x*/$submachine) submachine_used=t ;;
993 # If the assembler supports gnu_indirect_function symbol type and the
994 # architecture supports multi-arch, we enable multi-arch by default.
999 test x"$multi_arch" = xdefault && multi_arch=no
1002 if test x"$multi_arch" != xno; then
1003 AC_DEFINE(USE_MULTIARCH)
1005 AC_SUBST(multi_arch)
1007 if test -z "$os_used" && test "$os" != none; then
1008 AC_MSG_ERROR(Operating system $os is not supported.)
1010 if test -z "$machine_used" && test "$machine" != none; then
1011 AC_MSG_ERROR(The $machine is not supported.)
1013 if test -z "$submachine_used" && test -n "$submachine"; then
1014 AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
1016 AC_SUBST(submachine)
1018 # We have now validated the configuration.
1020 # Expand the list of system names into a full list of directories
1021 # from each element's parent name and Implies file (if present).
1024 while test $# -gt 0; do
1028 case " $names " in *" $name "*)
1029 # Already in the list.
1033 # Report each name as we discover it, so there is no long pause in output.
1034 echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
1036 name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
1040 *) xsrcdir=$srcdir/ ;;
1042 test -n "$enable_debug_configure" &&
1043 echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
1045 for implies_file in Implies Implies-before Implies-after; do
1046 implies_type=`echo $implies_file | sed s/-/_/`
1047 eval ${implies_type}=
1048 if test -f $xsrcdir$name/$implies_file; then
1049 # Collect more names from the `Implies' file (removing comments).
1050 implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/$implies_file`"
1051 for x in $implied_candidate; do
1053 if test -d $xsrcdir$name_base/$x; then
1054 eval "${implies_type}=\"\$${implies_type} \$name_base/\$x\""
1059 test -n "$enable_debug_configure" &&
1060 echo "[DEBUG]: $name $implies_file $x try() {$try_srcdir}$try" >&2
1061 if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
1063 eval "${implies_type}=\"\$${implies_type} \$try\""
1066 if test $found = no; then
1067 AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
1073 # Add NAME to the list of names.
1074 names="$names $name"
1076 # Find the parent of NAME, using the empty string if it has none.
1078 parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
1081 test -n "$enable_debug_configure" &&
1082 echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
1083 Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
1085 # Add the names implied by NAME, and NAME's parent (if it has one), to
1086 # the list of names to be processed (the argument list). We prepend the
1087 # implied names to the list and append the parent. We want implied
1088 # directories to come before further directories inferred from the
1089 # configuration components; this ensures that for sysv4, unix/common
1090 # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
1092 sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
1093 test -n "$sysnames" && set $sysnames
1096 # Add the default directories.
1097 default_sysnames="sysdeps/generic"
1098 sysnames="$names $default_sysnames"
1100 # The other names were emitted during the scan.
1101 AC_MSG_RESULT($default_sysnames)
1103 # if using special system headers, find out the compiler's sekrit
1104 # header directory and add that to the list. NOTE: Only does the right
1105 # thing on a system that doesn't need fixincludes. (Not presently a problem.)
1106 if test -n "$sysheaders"; then
1107 SYSINCLUDES=-nostdinc
1108 for d in include include-fixed; do
1109 i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
1110 SYSINCLUDES="$SYSINCLUDES -isystem $i"
1112 SYSINCLUDES="$SYSINCLUDES \
1113 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
1114 if test -n "$CXX"; then
1116 for cxxheaders in `$CXX -v -S -x c++ /dev/null -o /dev/null 2>&1 \
1117 | sed -n -e '1,/#include/d' -e 's/^ \(\/.*\/[cg]++\)/\1/p'`; do
1118 test "x$cxxheaders" != x &&
1119 CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders"
1123 AC_SUBST(SYSINCLUDES)
1124 AC_SUBST(CXX_SYSINCLUDES)
1126 # Obtain some C++ header file paths. This is used to make a local
1127 # copy of those headers in Makerules.
1128 if test -n "$TEST_CXX"; then
1131 find_cxx_header () {
1132 echo "#include <$1>" | $CXX -H -fsyntax-only -x c++ - 2>&1 \
1133 | $AWK '$1 == "."{print $2}'
1135 CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
1136 CXX_CMATH_HEADER="$(find_cxx_header cmath)"
1137 CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
1140 AC_SUBST(CXX_CSTDLIB_HEADER)
1141 AC_SUBST(CXX_CMATH_HEADER)
1142 AC_SUBST(CXX_BITS_STD_ABS_H)
1144 # Test if LD_LIBRARY_PATH contains the notation for the current directory
1145 # since this would lead to problems installing/building glibc.
1146 # LD_LIBRARY_PATH contains the current directory if one of the following
1148 # - one of the terminals (":" and ";") is the first or last sign
1149 # - two terminals occur directly after each other
1150 # - the path contains an element with a dot in it
1151 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
1153 case ${LD_LIBRARY_PATH} in
1154 [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
1155 ld_library_path_setting="contains current directory"
1158 ld_library_path_setting="ok"
1162 AC_MSG_RESULT($ld_library_path_setting)
1163 if test "$ld_library_path_setting" != "ok"; then
1165 *** LD_LIBRARY_PATH shouldn't contain the current directory when
1166 *** building glibc. Please change the environment variable
1167 *** and run configure again.])
1170 AC_PATH_PROG(BASH_SHELL, bash, no)
1172 AC_PATH_PROG(PERL, perl, no)
1173 if test "$PERL" != no &&
1174 (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1177 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1178 $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1180 AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
1181 cat > conftest.s <<EOF
1184 .set glibc_conftest_frobozz,foo
1185 .globl glibc_conftest_frobozz
1187 # The alpha-dec-osf1 assembler gives only a warning for `.set'
1188 # (but it doesn't work), so we must do a linking check to be sure.
1189 cat > conftest1.c <<\EOF
1190 extern int glibc_conftest_frobozz;
1191 void _start() { glibc_conftest_frobozz = 1; }
1193 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1194 -nostartfiles -nostdlib $no_ssp \
1195 -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1196 libc_cv_asm_set_directive=yes
1198 libc_cv_asm_set_directive=no
1201 if test $libc_cv_asm_set_directive = yes; then
1202 AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1205 AC_CACHE_CHECK(linker support for protected data symbol,
1206 libc_cv_protected_data,
1207 [cat > conftest.c <<EOF
1208 int bar __attribute__ ((visibility ("protected"))) = 1;
1210 libc_cv_protected_data=no
1211 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -o conftest.so); then
1212 cat > conftest.c <<EOF
1214 int main (void) { return bar; }
1216 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp conftest.c -o conftest conftest.so); then
1217 libc_cv_protected_data=yes
1222 AC_SUBST(libc_cv_protected_data)
1224 AC_CACHE_CHECK(linker support for INSERT in linker script,
1226 [cat > conftest.c <<EOF
1227 int __attribute__ ((section(".bar"))) bar = 0x12345678;
1228 int test (void) { return bar; }
1230 cat > conftest.t <<EOF
1235 INSERT AFTER .rela.dyn;
1238 if AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -Wl,-T,conftest.t -o conftest.so]); then
1243 AC_SUBST(libc_cv_insert)
1245 AC_CACHE_CHECK(for broken __attribute__((alias())),
1246 libc_cv_broken_alias_attribute,
1247 [cat > conftest.c <<EOF
1248 extern int foo (int x) __asm ("xyzzy");
1249 int bar (int x) { return x; }
1250 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1252 extern __typeof (dfoo) dfoo __asm ("abccb");
1255 libc_cv_broken_alias_attribute=yes
1256 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1257 if grep 'xyzzy' conftest.s >/dev/null &&
1258 grep 'abccb' conftest.s >/dev/null; then
1259 libc_cv_broken_alias_attribute=no
1262 rm -f conftest.c conftest.s
1264 if test $libc_cv_broken_alias_attribute = yes; then
1265 AC_MSG_ERROR(working alias attribute support required)
1268 AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
1269 libc_cv_have_sdata_section,
1270 [echo "int i;" > conftest.c
1271 libc_cv_have_sdata_section=no
1272 if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
1273 | grep '\.sdata' >/dev/null; then
1274 libc_cv_have_sdata_section=yes
1276 rm -f conftest.c conftest.so
1278 if test $libc_cv_have_sdata_section = yes; then
1279 AC_DEFINE(HAVE_SDATA_SECTION)
1282 AC_CACHE_CHECK(for libunwind-support in compiler,
1283 libc_cv_cc_with_libunwind, [
1284 cat > conftest.c <<EOF
1285 int main (void) { return 0; }
1287 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
1288 conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
1289 libc_cv_cc_with_libunwind=yes
1291 libc_cv_cc_with_libunwind=no
1294 AC_SUBST(libc_cv_cc_with_libunwind)
1295 if test $libc_cv_cc_with_libunwind = yes; then
1296 AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
1300 AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1301 libc_cv_as_noexecstack, [dnl
1302 cat > conftest.c <<EOF
1305 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1306 -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1307 && grep .note.GNU-stack conftest.s >/dev/null \
1308 && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1309 -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1311 libc_cv_as_noexecstack=yes
1313 libc_cv_as_noexecstack=no
1316 if test $libc_cv_as_noexecstack = yes; then
1317 ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1319 AC_SUBST(ASFLAGS_config)
1321 LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
1322 [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
1323 AC_SUBST(libc_cv_z_execstack)
1325 LIBC_LINKER_FEATURE([-z start-stop-gc], [-Wl,-z,start-stop-gc],
1326 [libc_cv_z_start_stop_gc=yes], [libc_cv_z_start_stop_gc=no])
1327 LIBC_CONFIG_VAR([have-z-start-stop-gc], [$libc_cv_z_start_stop_gc])
1329 LIBC_LINKER_FEATURE([--depaudit], [-Wl,--depaudit,x],
1330 [libc_cv_depaudit=yes], [libc_cv_depaudit=no])
1331 LIBC_CONFIG_VAR([have-depaudit], [$libc_cv_depaudit])
1333 LIBC_LINKER_FEATURE([-z pack-relative-relocs],
1334 [-Wl,-z,pack-relative-relocs],
1335 [libc_cv_dt_relr=yes], [libc_cv_dt_relr=no])
1336 LIBC_CONFIG_VAR([have-dt-relr], [$libc_cv_dt_relr])
1338 LIBC_LINKER_FEATURE([--no-dynamic-linker],
1339 [-Wl,--no-dynamic-linker],
1340 [libc_cv_no_dynamic_linker=yes],
1341 [libc_cv_no_dynamic_linker=no])
1342 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
1344 LIBC_TRY_CC_AND_TEST_CC_OPTION(for -static-pie, [-static-pie],
1346 [libc_cv_static_pie=yes], [libc_cv_static_pie=no],
1347 libc_cv_test_static_pie,
1348 [libc_cv_test_static_pie=yes], [libc_cv_test_static_pie=no]
1350 LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie])
1351 AC_SUBST(libc_cv_test_static_pie)
1353 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1354 LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
1357 AC_SUBST(libc_cv_fpie)
1359 AC_CACHE_CHECK(for GLOB_DAT reloc,
1360 libc_cv_has_glob_dat, [dnl
1361 cat > conftest.c <<EOF
1363 int foo (void) { return mumble; }
1365 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1366 -fPIC -shared -o conftest.so conftest.c
1367 -nostdlib -nostartfiles $no_ssp
1368 1>&AS_MESSAGE_LOG_FD])
1370 dnl look for GLOB_DAT relocation.
1371 if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
1372 libc_cv_has_glob_dat=yes
1374 libc_cv_has_glob_dat=no
1377 libc_cv_has_glob_dat=no
1380 AC_SUBST(libc_cv_has_glob_dat)
1389 dnl Check if TEST_CC support tls descriptor.
1390 LIBC_TRY_TEST_CC_COMMAND([for tls descriptor support],
1392 [-fPIC -mtls-dialect=$mtls_descriptor -nostdlib -nostartfiles -shared],
1393 libc_cv_test_mtls_descriptor,
1394 [libc_cv_test_mtls_descriptor=$mtls_descriptor],
1395 [libc_cv_test_mtls_descriptor=no])
1396 LIBC_CONFIG_VAR([have-test-mtls-descriptor],
1397 [$libc_cv_test_mtls_descriptor])
1399 dnl clang emits an warning for a double alias redirection, to warn the
1400 dnl original symbol is sed even when weak definition overrides it.
1401 dnl It is a usual pattern for weak_alias, where multiple alias point to
1407 extern __typeof (__foo) foo __attribute__ ((weak, alias ("__foo")));
1408 extern __typeof (__foo) bar __attribute__ ((weak, alias ("foo")));
1410 LIBC_TRY_CC_AND_TEST_CC_COMMAND([if -Wno-ignored-attributes is required for aliases],
1412 [-c -Werror -Wno-ignored-attributes],
1413 libc_cv_wno_ignored_attributes,
1414 [libc_cv_wno_ignored_attributes="-Wno-ignored-attributes"],
1415 [libc_cv_wno_ignored_attributes=],
1416 libc_cv_test_wno_ignored_attributes,
1417 [libc_cv_test_wno_ignored_attributes="-Wno-ignored-attributes"],
1418 [libc_cv_test_wno_ignored_attributes=])
1419 LIBC_CONFIG_VAR([config-cflags-wno-ignored-attributes],
1420 [$libc_cv_wno_ignored_attributes])
1421 AC_SUBST(libc_cv_test_wno_ignored_attributes)
1423 AC_CACHE_CHECK(whether cc puts quotes around section names,
1424 libc_cv_have_section_quotes,
1425 [cat > conftest.c <<EOF
1426 static const int foo
1427 __attribute__ ((section ("bar"))) = 1;
1429 if ${CC-cc} -S conftest.c -o conftest.s; then
1430 if grep '\.section.*"bar"' conftest.s >/dev/null; then
1431 libc_cv_have_section_quotes=yes
1433 libc_cv_have_section_quotes=no
1436 libc_cv_have_section_quotes=unknown
1438 rm -f conftest.{c,s}
1440 if test $libc_cv_have_section_quotes = yes; then
1441 AC_DEFINE(HAVE_SECTION_QUOTES)
1444 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1445 cat > conftest.c <<\EOF
1448 __builtin_memset (x, 0, 1000);
1452 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "memset" > /dev/null]);
1454 libc_cv_gcc_builtin_memset=no
1456 libc_cv_gcc_builtin_memset=yes
1459 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1460 AC_DEFINE(HAVE_BUILTIN_MEMSET)
1463 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1464 cat > conftest.c <<\EOF
1465 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1466 char *foo (const char *a, const char *b)
1468 return __builtin_strstr (a, b);
1472 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null]);
1474 libc_cv_gcc_builtin_redirection=yes
1476 libc_cv_gcc_builtin_redirection=no
1479 if test "$libc_cv_gcc_builtin_redirection" = no; then
1480 AC_MSG_ERROR([support for the symbol redirection needed])
1483 dnl Determine how to disable generation of FMA instructions.
1484 AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1485 libc_cv_cc_nofma, [dnl
1487 for opt in -ffp-contract=off -mno-fused-madd; do
1488 LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1490 AC_SUBST(libc_cv_cc_nofma)
1492 if test -n "$submachine"; then
1493 AC_CACHE_CHECK([for compiler option for CPU variant],
1494 libc_cv_cc_submachine, [dnl
1495 libc_cv_cc_submachine=no
1496 for opt in "-march=$submachine" "-mcpu=$submachine"; do
1497 LIBC_TRY_CC_OPTION([$opt], [
1498 libc_cv_cc_submachine="$opt"
1501 if test "x$libc_cv_cc_submachine" = xno; then
1502 AC_MSG_ERROR([${CC-cc} does not support $submachine])
1505 AC_SUBST(libc_cv_cc_submachine)
1507 dnl Determine if compiler supports -fsignaling-nans
1508 LIBC_TRY_CC_AND_TEST_CC_OPTION([for compiler option that -fsignaling-nans],
1509 [-Werror -fsignaling-nans],
1510 libc_cv_cc_signaling_nans,
1511 [libc_cv_cc_signaling_nans=-fsignaling-nans],
1512 [libc_cv_cc_signaling_nans=],
1513 libc_cv_test_cc_signaling_nans,
1514 [libc_cv_test_cc_signaling_nans=-fsignaling-nans],
1515 [libc_cv_test_cc_signaling_nans=])
1516 LIBC_CONFIG_VAR([config-cflags-signaling-nans],
1517 [$libc_cv_cc_signaling_nans])
1518 AC_SUBST(libc_cv_test_cc_signaling_nans)
1520 dnl Check if TEST_CC supports -fsemantic-interposition.
1521 LIBC_TRY_TEST_CC_OPTION([-fsemantic-interposition],
1522 [-c -Werror -fsemantic-interposition],
1523 libc_cv_test_cc_cflags_fsemantic_interposition,
1524 [libc_cv_test_cc_cflags_fsemantic_interposition=yes],
1525 [libc_cv_test_cc_cflags_fsemantic_interposition=no]
1527 LIBC_CONFIG_VAR(have-test-cc-cflags-fsemantic-interposition,
1528 $libc_cv_test_cc_cflags_fsemantic_interposition)
1530 dnl Determine if TEST_CC supports -ffloat-store.
1531 LIBC_TRY_TEST_CC_OPTION([for -ffloat-store],
1532 [-Werror -ffloat-store],
1533 libc_cv_test_cc_float_store,
1534 [libc_cv_test_cc_float_store="-ffloat-store"],
1535 [libc_cv_test_cc_float_store=])
1536 LIBC_CONFIG_VAR([test-config-cflags-float-store],
1537 [$libc_cv_test_cc_float_store])
1541 __attribute__ ((__optimize__ (\"-fno-tree-loop-distribute-patterns\")))
1544 LIBC_TRY_CC_AND_TEST_CC_COMMAND([if __attribute__ ((__optimize__("-fno-tree-loop-distribute-patterns"))) works],
1547 libc_cv_cc_loop_to_function,
1548 [libc_cv_cc_loop_to_function=yes],
1549 [libc_cv_cc_loop_to_function=no],
1550 libc_cv_test_cc_loop_to_function,
1551 [libc_cv_test_cc_loop_to_function=yes],
1552 [libc_cv_test_cc_loop_to_function=no])
1553 if test $libc_cv_cc_loop_to_function = yes; then
1554 AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
1556 if test $libc_cv_test_cc_loop_to_function = yes; then
1557 AC_DEFINE(HAVE_TEST_CC_INHIBIT_LOOP_TO_LIBCALL)
1559 AC_SUBST(libc_cv_cc_loop_to_function)
1561 LIBC_TRY_CC_AND_TEST_CC_OPTION([for -Wimplicit-fallthrough],
1562 [-Werror -Wimplicit-fallthrough],
1563 libc_cv_cc_wimplicit_fallthrough,
1564 [libc_cv_cc_wimplicit_fallthrough=-Wimplicit-fallthrough],
1565 [libc_cv_cc_wimplicit_fallthrough=],
1566 libc_cv_test_cc_wimplicit_fallthrough,
1567 [libc_cv_test_cc_wimplicit_fallthrough=-Wimplicit-fallthrough],
1568 [libc_cv_test_cc_wimplicit_fallthrough=])
1569 LIBC_CONFIG_VAR([cc-option-wimplicit-fallthrough],
1570 [$libc_cv_cc_wimplicit_fallthrough])
1571 AC_SUBST(libc_cv_test_cc_wimplicit_fallthrough)
1574 void bar (void (*callback) (void));
1578 void callback (void) { var = 1; }
1584 dnl Check if TEST_CC support trampolines.
1585 LIBC_TRY_TEST_CC_COMMAND([support for trampolines],
1588 libc_cv_test_cc_trampolines,
1589 [libc_cv_test_cc_trampolines=yes],
1590 [libc_cv_test_cc_trampolines=no]
1592 LIBC_CONFIG_VAR([have-test-cc-trampoline],
1593 [$libc_cv_test_cc_trampolines])
1595 dnl Check if TEST_CC supports -Wno-restrict.
1596 LIBC_TRY_TEST_CC_OPTION([-Wno-restrict],
1597 [-c -Werror -Wno-restrict],
1598 libc_cv_test_cflags_wno_restrict,
1599 [libc_cv_test_cflags_wno_restrict=-Wno-restrict],
1600 [libc_cv_test_cflags_wno_restrict=]
1602 LIBC_CONFIG_VAR([test-config-cflags-wno-restrict],
1603 [$libc_cv_test_cflags_wno_restrict])
1605 dnl Check if TEST_CC supports -Wno-fortify-source.
1606 LIBC_TRY_TEST_CC_OPTION([-Wno-fortify-source],
1607 [-c -Werror -Wno-fortify-source],
1608 libc_cv_test_cflags_wno_fortify_source,
1609 [libc_cv_test_cflags_wno_fortify_source=-Wno-fortify-source],
1610 [libc_cv_test_cflags_wno_fortify_source=]
1612 LIBC_CONFIG_VAR([test-config-cflags-wno-fortify-source],
1613 [$libc_cv_test_cflags_wno_fortify_source])
1615 dnl Check if TEST_CC supports -finput-charset=ascii.
1616 LIBC_TRY_TEST_CC_OPTION([-finput-charset=ascii],
1617 [-c -Werror -finput-charset=ascii],
1618 libc_cv_test_cflags_finput_charset_ascii,
1619 [libc_cv_test_cflags_finput_charset_ascii="-finput-charset=ascii"],
1620 [libc_cv_test_cflags_finput_charset_ascii=]
1622 LIBC_CONFIG_VAR(test-config-cflags-finput-charset-ascii,
1623 $libc_cv_test_cflags_finput_charset_ascii)
1625 dnl Check if TEST_CXX supports -finput-charset=ascii.
1626 LIBC_TRY_TEST_CXX_OPTION([$CXX -finput-charset=ascii],
1627 [-c -Werror -finput-charset=ascii],
1628 libc_cv_test_cxxflags_finput_charset_ascii,
1629 [libc_cv_test_cxxflags_finput_charset_ascii="-finput-charset=ascii"],
1630 [libc_cv_test_cxxflags_finput_charset_ascii=]
1632 LIBC_CONFIG_VAR(test-config-cxxflags-finput-charset-ascii,
1633 $libc_cv_test_cxxflags_finput_charset_ascii)
1636 extern int not_exist (void);
1638 inline int make_unique (void)
1640 /* Static variables in inline functions and classes
1641 generate STB_GNU_UNIQUE symbols. */
1648 return make_unique () + not_exist ();
1652 dnl Check if TEST_CXX supports STB_GNU_UNIQUE.
1653 LIBC_TRY_TEST_CXX_COMMAND([for STB_GNU_UNIQUE],
1656 libc_cv_test_stb_gnu_unique,
1658 if LC_ALL=C $READELF -sW conftest \
1659 | grep -q "UNIQUE.* _ZZ11make_uniquevE6unique"; then
1660 libc_cv_test_stb_gnu_unique=yes
1662 libc_cv_test_stb_gnu_unique=no
1665 [libc_cv_test_stb_gnu_unique=no],
1667 LIBC_CONFIG_VAR([have-test-stb-gnu-unique], [$libc_cv_test_stb_gnu_unique])
1669 dnl Check whether we have the gd library available.
1670 AC_MSG_CHECKING(for libgd)
1671 if test "$with_gd" != "no"; then
1672 old_CFLAGS="$CFLAGS"
1673 CFLAGS="$CFLAGS $libgd_include"
1674 old_LDFLAGS="$LDFLAGS"
1675 LDFLAGS="$LDFLAGS $libgd_ldflags"
1677 LIBS="$LIBS -lgd -lpng -lz -lm"
1678 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gd.h>]], [[gdImagePng (0, 0)]])],
1679 [LIBGD=yes], [LIBGD=no])
1680 CFLAGS="$old_CFLAGS"
1681 LDFLAGS="$old_LDFLAGS"
1686 AC_MSG_RESULT($LIBGD)
1690 if test x$with_selinux = xno ; then
1693 # See if we have the SELinux library
1694 AC_CHECK_LIB(selinux, is_selinux_enabled,
1695 have_selinux=yes, have_selinux=no)
1696 if test x$with_selinux = xyes ; then
1697 if test x$have_selinux = xno ; then
1698 AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
1702 # Check if we're building with SELinux support.
1703 if test "x$have_selinux" = xyes; then
1704 AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
1706 # See if we have the libaudit library
1707 AC_CHECK_LIB(audit, audit_log_user_avc_message,
1708 have_libaudit=yes, have_libaudit=no)
1709 if test "x$have_libaudit" = xyes; then
1710 AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
1712 AC_SUBST(have_libaudit)
1714 # See if we have the libcap library
1715 AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
1716 if test "x$have_libcap" = xyes; then
1717 AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
1719 AC_SUBST(have_libcap)
1721 AC_SUBST(have_selinux)
1723 dnl Check if we support the requested _FORTIFY_SOURCE level
1724 dnl If not, then don't use it.
1725 dnl Note that _FORTIFY_SOURCE may have been set through FLAGS too.
1726 dnl _FORTIFY_SOURCE value will be selectively disabled for function that can't
1728 no_fortify_source="-U_FORTIFY_SOURCE"
1729 fortify_source="${no_fortify_source}"
1731 LIBC_TRY_CC_AND_TEST_LINK([for maximum supported _FORTIFY_SOURCE level],
1732 [__builtin_dynamic_object_size("", 0)],
1733 libc_cv_supported_fortify_source,
1734 [libc_cv_supported_fortify_source=3],
1735 [libc_cv_supported_fortify_source=2],
1736 libc_cv_test_supported_fortify_source,
1737 [libc_cv_test_supported_fortify_source=3],
1738 [libc_cv_test_supported_fortify_source=2])
1739 AC_SUBST(libc_cv_test_supported_fortify_source)
1741 AS_CASE([$enable_fortify_source],
1742 [yes], [libc_cv_fortify_source=yes enable_fortify_source=$libc_cv_supported_fortify_source],
1743 [1|2], [libc_cv_fortify_source=yes],
1744 [3], [AS_IF([test $libc_cv_supported_fortify_source = 3],
1745 [libc_cv_fortify_source=yes],
1746 [AC_MSG_ERROR([Compiler doesn't provide necessary support for _FORTIFY_SOURCE=3])])],
1747 [libc_cv_fortify_source=no])
1749 AS_IF([test "$libc_cv_fortify_source" = yes],
1750 [fortify_source="${fortify_source} -D_FORTIFY_SOURCE=${enable_fortify_source}"]
1753 AC_SUBST(enable_fortify_source)
1754 AC_SUBST(libc_cv_fortify_source)
1755 AC_SUBST(no_fortify_source)
1756 AC_SUBST(fortify_source)
1757 LIBC_CONFIG_VAR([supported-fortify], [$libc_cv_supported_fortify_source])
1759 dnl Check if compiler define _FILE_OFFSET_BITS by default
1760 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
1761 #ifndef _FILE_OFFSET_BITS
1762 # error _FILE_OFFSET_BITS not defined
1764 [libc_cv_compiler_default_file_offset_bits=yes],
1765 [libc_cv_compiler_default_file_offset_bits=no])
1766 AS_IF([test "$libc_cv_compiler_default_file_offset_bits" = yes],
1767 [no_file_offset_bits_source="-U_FILE_OFFSET_BITS"])
1768 AC_SUBST(no_file_offset_bits_source)
1769 LIBC_CONFIG_VAR([no-file-offset-bits-source], [$no_file_offset_bits_source])
1771 dnl Check if compiler define _TIME_BITS by default
1772 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
1774 # error _TIME_BITS not defined
1776 [libc_cv_compiler_default_time_bits=yes],
1777 [libc_cv_compiler_default_time_bits=no])
1778 AS_IF([test "$libc_cv_compiler_default_time_bits" = yes],
1779 [no_time_bits_source="-U_TIME_BITS"])
1780 AC_SUBST(no_time_bits_source)
1781 LIBC_CONFIG_VAR([no-time-bits-source], [$no_time_bits_source])
1783 dnl Starting with binutils 2.35, GAS can attach multiple symbol versions
1784 dnl to one symbol (PR 23840).
1785 AC_CACHE_CHECK(whether the assembler requires one version per symbol,
1786 libc_cv_symver_needs_alias, [dnl
1787 cat > conftest.s <<EOF
1791 .symver testfunc, testfunc1@VERSION1
1792 .symver testfunc, testfunc1@VERSION2
1794 libc_cv_symver_needs_alias=no
1795 if ${CC-cc} $ASFLAGS -c conftest.s 2>&AS_MESSAGE_LOG_FD; then
1796 libc_cv_symver_needs_alias=no
1798 libc_cv_symver_needs_alias=yes
1802 if test "$libc_cv_symver_needs_alias" = yes; then
1803 AC_DEFINE(SYMVER_NEEDS_ALIAS)
1806 AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
1807 libc_cv_builtin_trap, [dnl
1808 libc_cv_builtin_trap=no
1809 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[__builtin_trap ()]])],[
1810 libc_undefs=`$NM -u conftest.o |
1811 LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1812 2>&AS_MESSAGE_LOG_FD` || {
1813 AC_MSG_ERROR([confusing output from $NM -u])
1815 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1816 if test -z "$libc_undefs"; then
1817 libc_cv_builtin_trap=yes
1819 if test $libc_cv_builtin_trap = yes; then
1820 AC_DEFINE([HAVE_BUILTIN_TRAP])
1823 dnl C++ feature tests.
1826 AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
1827 libc_cv_cxx_thread_local, [
1828 old_CXXFLAGS="$CXXFLAGS"
1829 CXXFLAGS="$CXXFLAGS -std=gnu++11"
1830 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1833 // Compiler support.
1840 S * get () { return &s; }
1842 // libstdc++ support.
1843 #ifndef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
1844 #error __cxa_thread_atexit_impl not supported
1847 [libc_cv_cxx_thread_local=yes],
1848 [libc_cv_cxx_thread_local=no])
1849 CXXFLAGS="$old_CXXFLAGS"
1851 AC_SUBST(libc_cv_cxx_thread_local)
1854 dnl End of C++ feature tests.
1856 ### End of automated tests.
1857 ### Now run sysdeps configure fragments.
1859 # They also can set these variables.
1861 ldd_rewrite_script=no
1862 libc_cv_sysconfdir=$sysconfdir
1863 libc_cv_localstatedir=$localstatedir
1864 libc_cv_gcc_unwind_find_fde=no
1868 # Iterate over all the sysdep directories we will use, running their
1869 # configure fragments.
1870 for dir in $sysnames; do
1873 *) dest=$srcdir/$dir ;;
1875 if test -r $dest/configure; then
1876 AC_MSG_RESULT(running configure fragment for $dir)
1881 if test x"$build_mathvec" = xnotset; then
1884 LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
1886 AC_SUBST(libc_extra_cflags)
1887 AC_SUBST(libc_extra_cppflags)
1889 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
1890 AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
1892 AC_SUBST(libc_cv_gcc_unwind_find_fde)
1894 # A sysdeps configure fragment can reset this if IFUNC is not actually
1895 # usable even though the assembler knows how to generate the symbol type.
1896 if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
1897 AC_DEFINE(HAVE_IFUNC)
1899 LIBC_CONFIG_VAR([have-ifunc], [$libc_cv_ld_gnu_indirect_function])
1901 if test x"$libc_cv_gcc_indirect_function" = xyes; then
1902 AC_DEFINE(HAVE_GCC_IFUNC)
1904 LIBC_CONFIG_VAR([have-gcc-ifunc], [$libc_cv_gcc_indirect_function])
1906 # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
1907 # configure fragment can override the value to prevent this AC_DEFINE.
1909 if test "x$use_nscd" != xno; then
1910 AC_DEFINE([USE_NSCD])
1912 if test "x$build_nscd" = xdefault; then
1913 build_nscd=$use_nscd
1916 AC_SUBST(libc_cv_slibdir)
1917 AC_SUBST(libc_cv_rtlddir)
1918 AC_SUBST(libc_cv_complocaledir)
1919 AC_SUBST(libc_cv_sysconfdir)
1920 AC_SUBST(libc_cv_localstatedir)
1921 AC_SUBST(libc_cv_rootsbindir)
1923 if test x$use_ldconfig = xyes; then
1924 AC_DEFINE(USE_LDCONFIG)
1926 AC_SUBST(use_ldconfig)
1927 AC_SUBST(ldd_rewrite_script)
1932 AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
1933 [libc_cv_pic_default=yes
1934 cat > conftest.c <<EOF
1935 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
1936 # error PIC is default.
1939 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1940 libc_cv_pic_default=no
1943 LIBC_CONFIG_VAR([build-pic-default], [$libc_cv_pic_default])
1945 AC_CACHE_CHECK([whether -fPIE is default], libc_cv_cc_pie_default,
1946 [libc_cv_cc_pie_default=yes
1947 cat > conftest.c <<EOF
1948 #if defined __PIE__ || defined __pie__ || defined PIE || defined pie
1949 # error PIE is default.
1952 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1953 libc_cv_cc_pie_default=no
1956 LIBC_CONFIG_VAR([cc-pie-default], [$libc_cv_cc_pie_default])
1958 # Get Position Dependent Executable (PDE) load address to be used to
1959 # load static Position Independent Executable (PIE) at a known working
1960 # non-zero load address. This is only used by glibc tests to verify
1961 # that PIE and static PIE with non-zero load address work correctly.
1962 AC_CACHE_CHECK([PDE load address],
1963 libc_cv_pde_load_address, [dnl
1964 cat > conftest.S <<EOF
1971 if test $libc_cv_cc_pie_default = yes; then
1972 pde_ld_flags="-no-pie"
1974 if ${CC-cc} $pde_ld_flags $CFLAGS $CPPFLAGS $LDFLAGS \
1975 -nostartfiles -nostdlib $no_ssp \
1976 -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1977 # Get the load address of the first PT_LOAD segment.
1978 libc_cv_pde_load_address=$(LC_ALL=C $READELF -Wl conftest \
1979 | $AWK '/LOAD/ { print $3; exit 0; }')
1981 AC_MSG_ERROR([${CC-cc} can not create PDE])
1984 LIBC_CONFIG_VAR([pde-load-address], [$libc_cv_pde_load_address])
1986 # Get the linker command-line option to load executable at a non-zero
1987 # load address. This is only used by glibc tests to verify that PIE and
1988 # static PIE with non-zero load address work correctly.
1989 LIBC_LINKER_FEATURE([-Ttext-segment=$libc_cv_pde_load_address],
1990 [-Wl,-Ttext-segment=$libc_cv_pde_load_address],
1991 [libc_cv_load_address_ldflag=-Wl,-Ttext-segment],
1992 [libc_cv_load_address_ldflag=])
1993 LIBC_CONFIG_VAR([load-address-ldflag], [$libc_cv_load_address_ldflag])
1995 AC_MSG_CHECKING(if we can build programs as PIE)
1996 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifdef PIE_UNSUPPORTED
1997 # error PIE is not supported
1998 #endif]])], [libc_cv_pie_supported=yes], [libc_cv_pie_supported=no])
1999 AC_MSG_RESULT($libc_cv_pie_supported)
2000 # Disable build-pie-default if target does not support it or glibc is
2001 # configured with --disable-default-pie.
2002 if test "x$default_pie" = xno; then
2003 build_pie_default=no
2005 build_pie_default=$libc_cv_pie_supported
2007 LIBC_CONFIG_VAR([build-pie-default], [$build_pie_default])
2009 AC_MSG_CHECKING(if we can build static PIE programs)
2010 libc_cv_static_pie_supported=$libc_cv_pie_supported
2011 if test "x$libc_cv_pie_supported" != xno \
2012 -a "$libc_cv_no_dynamic_linker" = yes; then
2013 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef SUPPORT_STATIC_PIE
2014 # error static PIE is not supported
2015 #endif]])], [libc_cv_static_pie_supported=yes],
2016 [libc_cv_static_pie_supported=no])
2018 AC_MSG_RESULT($libc_cv_static_pie_supported)
2020 # Enable static-pie only if it is available and glibc isn't configured
2021 # with --disable-default-pie.
2022 if test "x$default_pie" = xno; then
2023 libc_cv_static_pie=no
2025 libc_cv_static_pie=$libc_cv_static_pie_supported
2027 if test "$libc_cv_static_pie" = "yes"; then
2028 AC_DEFINE(ENABLE_STATIC_PIE)
2030 LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
2032 # Support configure.ac under sysdeps.
2033 AC_SUBST(libc_cv_test_cc_mprefer_vector_width)
2034 AC_SUBST(test_enable_cet)
2035 AC_SUBST(libc_cv_test_x86_have_amx_tile)
2037 # Set the `multidir' variable by grabbing the variable from the compiler.
2038 # We do it once and save the result in a generated makefile.
2039 libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
2040 AC_SUBST(libc_cv_multidir)
2043 AC_SUBST(static_nss)
2047 dnl See sysdeps/mach/configure.ac for this variable.
2048 AC_SUBST(mach_interface_list)
2050 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
2051 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
2055 if test "$pthread_in_libc" = yes; then
2056 AC_DEFINE(PTHREAD_IN_LIBC)
2058 AC_SUBST(pthread_in_libc)
2060 AC_CONFIG_FILES([config.make Makefile])
2061 AC_CONFIG_COMMANDS([default],[[
2062 case $CONFIG_FILES in *config.make*)
2063 echo "$config_vars" >> config.make;;
2065 test -d bits || mkdir bits]],[[config_vars='$config_vars']])