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.
49 if test $host != $build; then
50 AC_CHECK_PROGS(BUILD_CC, gcc cc)
52 AC_SUBST(cross_compiling)
55 # We need the C++ compiler only for testing.
57 # It's useless to us if it can't link programs (e.g. missing -lstdc++).
58 AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl
60 # Default, dynamic case.
61 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
62 [libc_cv_cxx_link_ok=yes],
63 [libc_cv_cxx_link_ok=no])
65 old_LDFLAGS="$LDFLAGS"
66 LDFLAGS="$LDFLAGS -static"
67 AC_LINK_IFELSE([AC_LANG_SOURCE([
73 std::cout << "Hello, world!";
78 [libc_cv_cxx_link_ok=no])
79 LDFLAGS="$old_LDFLAGS"
81 AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
83 if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
84 AC_MSG_ERROR([you must configure in a separate build directory])
87 # This will get text that should go into config.make.
90 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
92 AS_HELP_STRING([--with-gd=DIR],
93 [find libgd include dir and library with prefix DIR]),
97 *) libgd_include="-I$withval/include"
98 libgd_ldflags="-L$withval/lib" ;;
101 AC_ARG_WITH([gd-include],
102 AS_HELP_STRING([--with-gd-include=DIR],
103 [find libgd include files in DIR]),
105 case "$with_gd_include" in
107 *) libgd_include="-I$withval" ;;
110 AC_ARG_WITH([gd-lib],
111 AS_HELP_STRING([--with-gd-lib=DIR],
112 [find libgd library files in DIR]),
114 case "$with_gd_lib" in
116 *) libgd_ldflags="-L$withval" ;;
120 if test -n "$libgd_include"; then
121 config_vars="$config_vars
122 CFLAGS-memusagestat.c = $libgd_include"
124 if test -n "$libgd_ldflags"; then
125 config_vars="$config_vars
126 libgd-LDFLAGS = $libgd_ldflags"
129 dnl Arguments to specify presence of other packages/features.
130 AC_ARG_WITH([binutils],
131 AS_HELP_STRING([--with-binutils=PATH],
132 [specify location of binutils (as and ld)]),
133 [path_binutils=$withval],
135 AC_ARG_WITH([selinux],
136 AS_HELP_STRING([--with-selinux],
137 [if building with SELinux support]),
138 [with_selinux=$withval],
141 AC_ARG_WITH([headers],
142 AS_HELP_STRING([--with-headers=PATH],
143 [location of system headers to use
144 (for example /usr/src/linux/include)
145 @<:@default=compiler default@:>@]),
146 [sysheaders=$withval],
150 dnl Additional build flags injection.
151 AC_ARG_WITH([nonshared-cflags],
152 AS_HELP_STRING([--with-nonshared-cflags=CFLAGS],
153 [build nonshared libraries with additional CFLAGS]),
154 [extra_nonshared_cflags=$withval],
155 [extra_nonshared_cflags=])
156 AC_SUBST(extra_nonshared_cflags)
157 AC_ARG_WITH([rtld-early-cflags],
158 AS_HELP_STRING([--with-rtld-early-cflags=CFLAGS],
159 [build early initialization with additional CFLAGS]),
160 [rtld_early_cflags=$withval],
161 [rtld_early_cflags=])
162 AC_SUBST(rtld_early_cflags)
164 AC_ARG_WITH([timeoutfactor],
165 AS_HELP_STRING([--with-timeoutfactor=NUM],
166 [specify an integer to scale the timeout]),
167 [timeoutfactor=$withval],
169 AC_DEFINE_UNQUOTED(TIMEOUTFACTOR, $timeoutfactor)
171 AC_ARG_ENABLE([sanity-checks],
172 AS_HELP_STRING([--disable-sanity-checks],
173 [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
174 [enable_sanity=$enableval],
177 AC_ARG_ENABLE([shared],
178 AS_HELP_STRING([--enable-shared],
179 [build shared library @<:@default=yes if GNU ld@:>@]),
182 AC_ARG_ENABLE([profile],
183 AS_HELP_STRING([--enable-profile],
184 [build profiled library @<:@default=no@:>@]),
185 [profile=$enableval],
187 AC_ARG_ENABLE([default-pie],
188 AS_HELP_STRING([--disable-default-pie],
189 [Do not build glibc programs and the testsuite as PIE @<:@default=no@:>@]),
190 [default_pie=$enableval],
192 AC_ARG_ENABLE([timezone-tools],
193 AS_HELP_STRING([--disable-timezone-tools],
194 [do not install timezone tools @<:@default=install@:>@]),
195 [enable_timezone_tools=$enableval],
196 [enable_timezone_tools=yes])
197 AC_SUBST(enable_timezone_tools)
199 AC_ARG_ENABLE([hardcoded-path-in-tests],
200 AS_HELP_STRING([--enable-hardcoded-path-in-tests],
201 [hardcode newly built glibc path in tests @<:@default=no@:>@]),
202 [hardcoded_path_in_tests=$enableval],
203 [hardcoded_path_in_tests=no])
204 AC_SUBST(hardcoded_path_in_tests)
206 AC_ARG_ENABLE([hidden-plt],
207 AS_HELP_STRING([--disable-hidden-plt],
208 [do not hide internal function calls to avoid PLT]),
211 if test "x$hidden" = xno; then
215 AC_ARG_ENABLE([bind-now],
216 AS_HELP_STRING([--enable-bind-now],
217 [disable lazy relocations in DSOs]),
218 [bindnow=$enableval],
221 if test "x$bindnow" = xyes; then
225 dnl Build glibc with -fstack-protector, -fstack-protector-all, or
226 dnl -fstack-protector-strong.
227 AC_ARG_ENABLE([stack-protector],
228 AS_HELP_STRING([--enable-stack-protector=@<:@yes|no|all|strong@:>@],
229 [Use -fstack-protector[-all|-strong] to detect glibc buffer overflows]),
230 [enable_stack_protector=$enableval],
231 [enable_stack_protector=no])
232 case "$enable_stack_protector" in
233 all|yes|no|strong) ;;
234 *) AC_MSG_ERROR([Not a valid argument for --enable-stack-protector: "$enable_stack_protector"]);;
237 dnl On some platforms we cannot use dynamic loading. We must provide
238 dnl static NSS modules.
239 AC_ARG_ENABLE([static-nss],
240 AS_HELP_STRING([--enable-static-nss],
241 [build static NSS modules @<:@default=no@:>@]),
242 [static_nss=$enableval],
244 dnl Enable static NSS also if we build no shared objects.
245 if test x"$static_nss" = xyes || test x"$shared" = xno; then
247 AC_DEFINE(DO_STATIC_NSS)
250 AC_ARG_ENABLE([force-install],
251 AS_HELP_STRING([--disable-force-install],
252 [don't force installation of files from this package, even if they are older than the installed files]),
253 [force_install=$enableval],
255 AC_SUBST(force_install)
257 AC_ARG_ENABLE([maintainer-mode],
258 AS_HELP_STRING([--enable-maintainer-mode],
259 [enable make rules and dependencies not useful (and sometimes confusing) to the casual installer]),
260 [maintainer=$enableval],
263 dnl On some platforms we allow dropping compatibility with all kernel
265 AC_ARG_ENABLE([kernel],
266 AS_HELP_STRING([--enable-kernel=VERSION],
267 [compile for compatibility with kernel not older than VERSION]),
268 [minimum_kernel=$enableval],
270 dnl Prevent unreasonable values.
271 if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
272 # Better nothing than this.
275 if test "$minimum_kernel" = current; then
276 minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
280 AC_ARG_ENABLE([werror],
281 AS_HELP_STRING([--disable-werror],
282 [do not build with -Werror]),
283 [enable_werror=$enableval],
285 AC_SUBST(enable_werror)
287 AC_ARG_ENABLE([multi-arch],
288 AS_HELP_STRING([--enable-multi-arch],
289 [enable single DSO with optimizations for multiple architectures]),
290 [multi_arch=$enableval],
291 [multi_arch=default])
293 AC_ARG_ENABLE([memory-tagging],
294 AS_HELP_STRING([--enable-memory-tagging],
295 [enable memory tagging if supported by the architecture @<:@default=no@:>@]),
296 [memory_tagging=$enableval],
298 if test "$memory_tagging" = yes; then
299 # Only enable this on architectures that support it.
306 AC_SUBST(memory_tagging)
308 AC_ARG_ENABLE([crypt],
309 AS_HELP_STRING([--enable-crypt],
310 [build and install the legacy passphrase hashing library, libcrypt]),
311 [build_crypt=$enableval],
313 AC_SUBST(build_crypt)
315 AC_ARG_ENABLE([nss-crypt],
316 AS_HELP_STRING([--enable-nss-crypt],
317 [enable libcrypt to use nss]),
318 [nss_crypt=$enableval],
320 if test x$build_libcrypt = xno && test x$nss_crypt = xyes; then
321 AC_MSG_WARN([--enable-nss-crypt has no effect when libcrypt is disabled])
324 if test x$nss_crypt = xyes; then
325 nss_includes=-I$(nss-config --includedir 2>/dev/null)
326 if test $? -ne 0; then
327 AC_MSG_ERROR([cannot find include directory with nss-config])
329 nspr_includes=-I$(nspr-config --includedir 2>/dev/null)
330 if test $? -ne 0; then
331 AC_MSG_ERROR([cannot find include directory with nspr-config])
334 CFLAGS="$CFLAGS $nss_includes $nspr_includes"
335 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
337 #include <nsslowhash.h>
338 void f (void) { NSSLOW_Init (); }])],
339 libc_cv_nss_crypt=yes,
341 cannot find NSS headers with lowlevel hash function interfaces]))
343 old_LDFLAGS="$LDFLAGS"
344 LIBS="$LIBS -lfreebl3"
345 AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
347 #include <nsslowhash.h>],
349 libc_cv_nss_crypt=yes,
351 cannot link program using lowlevel NSS hash functions]))
352 # Check to see if there is a static NSS cryptographic library.
353 # If there isn't then we can't link anything with libcrypt.a,
354 # and that might mean disabling some static tests.
355 LDFLAGS="$LDFLAGS -static"
356 AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
358 #include <nsslowhash.h>],
360 libc_cv_static_nss_crypt=yes,
361 libc_cv_static_nss_crypt=no)
362 LDFLAGS="$old_LDFLAGS"
367 libc_cv_static_nss_crypt=no
369 AC_SUBST(libc_cv_nss_crypt)
370 AC_SUBST(libc_cv_static_nss_crypt)
373 AC_ARG_ENABLE([systemtap],
374 [AS_HELP_STRING([--enable-systemtap],
375 [enable systemtap static probe points @<:@default=no@:>@])],
376 [systemtap=$enableval],
378 if test "x$systemtap" != xno; then
379 AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
381 CFLAGS="-std=gnu11 $CFLAGS"
382 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
383 void foo (int i, void *p)
385 asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
386 :: STAP_PROBE_ASM_OPERANDS (2, i, p));
387 }]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
388 CFLAGS="$old_CFLAGS"])
389 if test $libc_cv_sdt = yes; then
390 AC_DEFINE([USE_STAP_PROBE])
391 elif test "x$systemtap" != xauto; then
392 AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
396 AC_ARG_ENABLE([build-nscd],
397 [AS_HELP_STRING([--disable-build-nscd],
398 [disable building and installing the nscd daemon])],
399 [build_nscd=$enableval],
400 [build_nscd=default])
403 # Note the use of $use_nscd is near the bottom of the file.
404 AC_ARG_ENABLE([nscd],
405 [AS_HELP_STRING([--disable-nscd],
406 [library functions will not contact the nscd daemon])],
407 [use_nscd=$enableval],
410 AC_ARG_ENABLE([pt_chown],
411 [AS_HELP_STRING([--enable-pt_chown],
412 [Enable building and installing pt_chown])],
413 [build_pt_chown=$enableval],
415 AC_SUBST(build_pt_chown)
416 if test "$build_pt_chown" = yes; then
417 AC_DEFINE(HAVE_PT_CHOWN)
420 # The abi-tags file uses a fairly simplistic model for name recognition that
421 # can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
422 # $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
423 # This doesn't get used much beyond that, so it's fairly safe.
428 host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
432 AC_ARG_ENABLE([mathvec],
433 [AS_HELP_STRING([--enable-mathvec],
434 [Enable building and installing mathvec @<:@default depends on architecture@:>@])],
435 [build_mathvec=$enableval],
436 [build_mathvec=notset])
438 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
440 # error no CET compiler support
442 [libc_cv_compiler_default_cet=yes],
443 [libc_cv_compiler_default_cet=no])
446 AS_HELP_STRING([--enable-cet],
447 [enable Intel Control-flow Enforcement Technology (CET), x86 only]),
448 [enable_cet=$enableval],
449 [enable_cet=$libc_cv_compiler_default_cet])
452 AS_HELP_STRING([--disable-scv],
453 [syscalls will not use scv instruction, even if the kernel supports it, powerpc only]),
454 [use_scv=$enableval],
457 AS_IF([[test "$use_scv" != "no"]],[AC_DEFINE(USE_PPC_SCV)])
459 dnl Build glibc with _FORTIFY_SOURCE
460 AC_ARG_ENABLE(fortify-source,
461 AS_HELP_STRING([--enable-fortify-source@<:@=1|2|3@:>@],
462 [Use -D_FORTIFY_SOURCE=[1|2|3] to control code hardening, defaults to highest possible value supported by the build compiler.]),
463 [enable_fortify_source=$enableval],
464 [enable_fortify_source=no])
465 case "$enable_fortify_source" in
467 *) AC_MSG_ERROR([Not a valid argument for --enable-fortify-source: "$enable_fortify_source"]);;
470 # We keep the original values in `$config_*' and never modify them, so we
471 # can write them unchanged into config.make. Everything else uses
472 # $machine, $vendor, and $os, and changes them whenever convenient.
473 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
475 # Don't allow vendor == "unknown"
476 test "$config_vendor" = unknown && config_vendor=
477 config_os="`echo $config_os | sed 's/^unknown-//'`"
479 # Some configurations imply other options.
482 # The configure fragment of a port can modify these to supplement
483 # or override the table in the case statement below. No fragment should
484 # ever change the config_* variables, however.
485 machine=$config_machine
486 vendor=$config_vendor
492 AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
495 yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
497 *) submachine="$withval" ;;
501 # An preconfigure script can set this when it wants to disable the sanity
505 # A preconfigure script for a system that may or may not use fpu
506 # sysdeps directories sets this to a preprocessor conditional for
507 # whether to use such directories.
510 dnl Let sysdeps/*/preconfigure act here.
511 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
515 ### By using the undocumented --enable-hacker-mode option for configure
516 ### one can skip this test to make the configuration not fail for unsupported
519 if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
520 case "$machine-$host_os" in
525 *** The GNU C library is currently unavailable for this platform.
526 *** If you are interested in seeing glibc on this platform visit
527 *** the "How to submit a new port" in the wiki:
528 *** https://sourceware.org/glibc/wiki/#Development
529 *** and join the community!])
534 # Set base_machine if not set by a preconfigure fragment.
535 test -n "$base_machine" || base_machine=$machine
536 AC_SUBST(base_machine)
541 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
542 # The makefiles need to use a different form to find it in $srcdir.
543 INSTALL='\$(..)./scripts/install-sh -c'
549 # Accept binutils 2.25 or newer.
551 case $($LD --version) in
553 # Accept gold 1.14 or higher
554 AC_CHECK_PROG_VER(LD, $LD, --version,
555 [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
556 [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
557 LD=: critic_missing="$critic_missing GNU gold")
560 # Accept LLD 13.0.0 or higher
561 AC_CHECK_PROG_VER(LD, $LD, --version,
562 [LLD.* \([0-9][0-9]*\.[0-9.]*\)],
563 [1[3-9].*|[2-9][0-9].*],
564 LD=: critic_missing="$critic_missing LLD")
568 AC_CHECK_PROG_VER(LD, $LD, --version,
569 [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
570 [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
571 LD=: critic_missing="$critic_missing GNU ld")
574 LIBC_CONFIG_VAR([with-lld], [$libc_cv_with_lld])
576 # These programs are version sensitive.
577 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
578 [GNU Make[^0-9]*\([0-9][0-9.]*\)],
579 [[4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
581 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
582 [GNU gettext.* \([0-9]*\.[0-9.]*\)],
583 [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
584 MSGFMT=: aux_missing="$aux_missing msgfmt")
585 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
586 [GNU texinfo.* \([0-9][0-9.]*\)],
587 [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
588 MAKEINFO=: aux_missing="$aux_missing makeinfo")
589 AC_CHECK_PROG_VER(SED, sed, --version,
590 [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
591 [3.0[2-9]*|3.[1-9]*|[4-9]*],
592 SED=: aux_missing="$aux_missing sed")
593 AC_CHECK_PROG_VER(AWK, gawk, --version,
594 [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
595 [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
596 AC_CHECK_PROG_VER(BISON, bison, --version,
597 [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
598 [2.7*|[3-9].*|[1-9][0-9]*], critic_missing="$critic_missing bison")
600 AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
601 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
602 #if !defined __GNUC__ || __GNUC__ < 6 || (__GNUC__ == 6 && __GNUC_MINOR__ < 2)
603 #error insufficient compiler
605 [libc_cv_compiler_ok=yes],
606 [libc_cv_compiler_ok=no])])
607 AS_IF([test $libc_cv_compiler_ok != yes],
608 [critic_missing="$critic_missing compiler"])
610 if test "x$maintainer" = "xyes"; then
611 AC_CHECK_PROGS(AUTOCONF, autoconf, no)
613 xno|x|x:) AUTOCONF=no ;;
616 whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
617 if (cd $srcdir; $AUTOCONF $ACFLAGS configure.ac > /dev/null 2>&1); then
618 libc_cv_autoconf_works=yes
620 libc_cv_autoconf_works=no
622 test $libc_cv_autoconf_works = yes || AUTOCONF=no
625 if test "x$AUTOCONF" = xno; then
626 aux_missing="$aux_missing autoconf"
632 # Check for python3 if available, or else python.
633 AC_CHECK_PROG_VER(PYTHON_PROG, python3 python, --version,
634 [Python \([0-9][0-9.]*\)],
635 [3.[4-9]*|3.[1-9][0-9]*|[4-9].*|[1-9][0-9]*],
636 critic_missing="$critic_missing python")
637 PYTHON="$PYTHON_PROG -B"
640 test -n "$critic_missing" && AC_MSG_ERROR([
641 *** These critical programs are missing or too old:$critic_missing
642 *** Check the INSTALL file for required versions.])
644 test -n "$aux_missing" && AC_MSG_WARN([
645 *** These auxiliary programs are missing or incompatible versions:$aux_missing
646 *** some features or tests will be disabled.
647 *** Check the INSTALL file for required versions.])
650 # Determine whether to use fpu or nofpu sysdeps directories.
651 AC_CACHE_CHECK([for use of fpu sysdeps directories],
652 libc_cv_with_fp, [dnl
653 cat > conftest.c <<EOF
657 # error "no hardware floating point"
661 if ${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c -o conftest.s \
662 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
666 AC_SUBST(libc_cv_with_fp)
668 AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
669 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
674 AC_CACHE_CHECK(for -fstack-protector-strong, libc_cv_ssp_strong, [dnl
675 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-strong],
676 [libc_cv_ssp_strong=yes],
677 [libc_cv_ssp_strong=no])
680 AC_CACHE_CHECK(for -fstack-protector-all, libc_cv_ssp_all, [dnl
681 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-all],
682 [libc_cv_ssp_all=yes],
683 [libc_cv_ssp_all=no])
688 if test "$libc_cv_ssp" = yes; then
689 no_stack_protector="-fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0"
690 AC_DEFINE(HAVE_CC_NO_STACK_PROTECTOR)
693 if test "$enable_stack_protector" = yes && test "$libc_cv_ssp" = yes; then
694 stack_protector="-fstack-protector"
695 AC_DEFINE(STACK_PROTECTOR_LEVEL, 1)
696 elif test "$enable_stack_protector" = all && test "$libc_cv_ssp_all" = yes; then
697 stack_protector="-fstack-protector-all"
698 AC_DEFINE(STACK_PROTECTOR_LEVEL, 2)
699 elif test "$enable_stack_protector" = strong && test "$libc_cv_ssp_strong" = yes; then
700 stack_protector="-fstack-protector-strong"
701 AC_DEFINE(STACK_PROTECTOR_LEVEL, 3)
703 stack_protector="-fno-stack-protector"
704 AC_DEFINE(STACK_PROTECTOR_LEVEL, 0)
706 AC_SUBST(libc_cv_ssp)
707 AC_SUBST(stack_protector)
708 AC_SUBST(no_stack_protector)
710 if test -n "$stack_protector"; then
711 dnl Don't run configure tests with stack-protection on, to avoid problems with
713 no_ssp=-fno-stack-protector
717 if test "$enable_stack_protector" != no; then
718 AC_MSG_ERROR([--enable-stack-protector=$enable_stack_protector specified, but specified level of stack protection is not supported by the compiler.])
722 # For the multi-arch option we need support in the assembler & linker.
723 AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
724 libc_cv_ld_gnu_indirect_function, [dnl
725 cat > conftest.S <<EOF
726 .type foo,%gnu_indirect_function
739 libc_cv_ld_gnu_indirect_function=no
740 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
741 -nostartfiles -nostdlib $no_ssp \
742 -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
743 # Do a link to see if the backend supports IFUNC relocs.
744 $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
745 LC_ALL=C $READELF -Wr conftest | grep -q 'IRELATIVE\|R_SPARC_JMP_IREL' && {
746 libc_cv_ld_gnu_indirect_function=yes
751 # Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
752 AC_CACHE_CHECK([for gcc attribute ifunc support],
753 libc_cv_gcc_indirect_function, [dnl
754 cat > conftest.c <<EOF
755 extern int func (int);
756 int used_func (int a)
760 static void *resolver ()
764 extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
766 libc_cv_gcc_indirect_function=no
767 if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
768 2>&AS_MESSAGE_LOG_FD ; then
769 if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&AS_MESSAGE_LOG_FD; then
770 libc_cv_gcc_indirect_function=yes
775 # Check if linker supports textrel relocation with ifunc (used on elf/tests).
776 # Note that it relies on libc_cv_ld_gnu_indirect_function test above.
777 AC_CACHE_CHECK([whether the linker supports textrels along with ifunc],
778 libc_cv_textrel_ifunc, [dnl
779 cat > conftest.S <<EOF
780 .type foo,%gnu_indirect_function
801 libc_cv_textrel_ifunc=no
802 if test $libc_cv_ld_gnu_indirect_function = yes; then
803 if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib $no_ssp -pie -o conftest conftest.S); then
804 libc_cv_textrel_ifunc=yes
808 AC_SUBST(libc_cv_textrel_ifunc)
810 # Check if CC supports attribute retain as it is used in attribute_used_retain macro.
811 AC_CACHE_CHECK([for GNU attribute retain support],
812 libc_cv_gnu_retain, [dnl
813 cat > conftest.c <<EOF
814 static int var __attribute__ ((used, retain, section ("__libc_atexit")));
816 libc_cv_gnu_retain=no
817 if ${CC-cc} -Werror -c conftest.c -o /dev/null 1>&AS_MESSAGE_LOG_FD \
818 2>&AS_MESSAGE_LOG_FD ; then
819 libc_cv_gnu_retain=yes
822 if test $libc_cv_gnu_retain = yes; then
823 AC_DEFINE(HAVE_GNU_RETAIN)
825 LIBC_CONFIG_VAR([have-gnu-retain], [$libc_cv_gnu_retain])
827 # Check if gcc warns about alias for function with incompatible types.
828 AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
829 libc_cv_gcc_incompatible_alias, [dnl
830 cat > conftest.c <<EOF
831 int __redirect_foo (const void *s, int c);
833 __typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
834 __typeof (__redirect_foo) *foo_impl (void)
839 extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
841 libc_cv_gcc_incompatible_alias=yes
842 if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
843 libc_cv_gcc_incompatible_alias=no
847 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
848 if test x"$multi_arch" = xyes; then
849 AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
854 if test x"$libc_cv_gcc_indirect_function" != xyes; then
855 # GCC 8+ emits a warning for alias with incompatible types and it might
856 # fail to build ifunc resolvers aliases to either weak or internal
857 # symbols. Disables multiarch build in this case.
858 if test x"$libc_cv_gcc_incompatible_alias" = xyes; then
859 AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types])
860 if test x"$multi_arch" = xyes; then
861 AC_MSG_ERROR([--enable-multi-arch support requires a gcc with gnu-indirect-function support])
863 AC_MSG_WARN([Multi-arch is disabled.])
865 elif test x"$multi_arch" = xyes; then
866 AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
867 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
871 if test x"$multi_arch" != xno; then
872 multi_arch_d=/multiarch
875 # Compute the list of sysdep directories for this configuration.
876 # This can take a while to compute.
877 sysdep_dir=$srcdir/sysdeps
878 AC_MSG_CHECKING(sysdep dirs)
879 dnl We need to use [ and ] for other purposes for a while now.
881 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
882 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
884 test "x$base_os" != x || case "$os" in
891 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
894 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
898 o=`echo $tail | sed 's/[0-9]*$//'`
899 if test $o != $tail; then
902 # For linux-gnu, try linux-gnu, then linux.
903 o=`echo $tail | sed 's/-.*$//'`
904 if test $o != $tail; then
908 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
911 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
917 # For sparc/sparc32, try sparc/sparc32 and then sparc.
919 tail=$machine${submachine:+/$submachine}
920 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
922 # Prepend the machine's FPU directory unless the architecture specific
923 # preconfigure disables it.
924 if test "$libc_cv_with_fp" = yes; then
929 # For each machine term, try it with and then without /multiarch.
930 for try_fpu in $maybe_fpu ''; do
931 for try_multi in $multi_arch_d ''; do
932 mach="$mach /$1$try_fpu$try_multi"
938 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
941 # Find what sysdep directories exist.
943 for b in $base ''; do
944 for m0 in $mach ''; do
945 for v in /$vendor ''; do
946 test "$v" = / && continue
947 for o in /$ostry ''; do
948 test "$o" = / && continue
949 for m in $mach ''; do
950 try_suffix="$m0$b$v$o$m"
951 if test -n "$try_suffix"; then
952 try_srcdir="${srcdir}/"
953 try="sysdeps$try_suffix"
954 test -n "$enable_debug_configure" &&
955 echo "$0 [DEBUG]: try $try" >&2
956 if test -d "$try_srcdir$try"; then
957 sysnames="$sysnames $try"
958 { test -n "$o" || test -n "$b"; } && os_used=t
959 { test -n "$m" || test -n "$m0"; } && machine_used=t
961 x*/$submachine) submachine_used=t ;;
971 # If the assembler supports gnu_indirect_function symbol type and the
972 # architecture supports multi-arch, we enable multi-arch by default.
977 test x"$multi_arch" = xdefault && multi_arch=no
980 if test x"$multi_arch" != xno; then
981 AC_DEFINE(USE_MULTIARCH)
985 if test -z "$os_used" && test "$os" != none; then
986 AC_MSG_ERROR(Operating system $os is not supported.)
988 if test -z "$machine_used" && test "$machine" != none; then
989 AC_MSG_ERROR(The $machine is not supported.)
991 if test -z "$submachine_used" && test -n "$submachine"; then
992 AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
996 # We have now validated the configuration.
998 # Expand the list of system names into a full list of directories
999 # from each element's parent name and Implies file (if present).
1002 while test $# -gt 0; do
1006 case " $names " in *" $name "*)
1007 # Already in the list.
1011 # Report each name as we discover it, so there is no long pause in output.
1012 echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
1014 name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
1018 *) xsrcdir=$srcdir/ ;;
1020 test -n "$enable_debug_configure" &&
1021 echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
1023 for implies_file in Implies Implies-before Implies-after; do
1024 implies_type=`echo $implies_file | sed s/-/_/`
1025 eval ${implies_type}=
1026 if test -f $xsrcdir$name/$implies_file; then
1027 # Collect more names from the `Implies' file (removing comments).
1028 implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/$implies_file`"
1029 for x in $implied_candidate; do
1031 if test -d $xsrcdir$name_base/$x; then
1032 eval "${implies_type}=\"\$${implies_type} \$name_base/\$x\""
1037 test -n "$enable_debug_configure" &&
1038 echo "[DEBUG]: $name $implies_file $x try() {$try_srcdir}$try" >&2
1039 if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
1041 eval "${implies_type}=\"\$${implies_type} \$try\""
1044 if test $found = no; then
1045 AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
1051 # Add NAME to the list of names.
1052 names="$names $name"
1054 # Find the parent of NAME, using the empty string if it has none.
1056 parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
1059 test -n "$enable_debug_configure" &&
1060 echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
1061 Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
1063 # Add the names implied by NAME, and NAME's parent (if it has one), to
1064 # the list of names to be processed (the argument list). We prepend the
1065 # implied names to the list and append the parent. We want implied
1066 # directories to come before further directories inferred from the
1067 # configuration components; this ensures that for sysv4, unix/common
1068 # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
1070 sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
1071 test -n "$sysnames" && set $sysnames
1074 # Add the default directories.
1075 default_sysnames="sysdeps/generic"
1076 sysnames="$names $default_sysnames"
1078 # The other names were emitted during the scan.
1079 AC_MSG_RESULT($default_sysnames)
1081 # if using special system headers, find out the compiler's sekrit
1082 # header directory and add that to the list. NOTE: Only does the right
1083 # thing on a system that doesn't need fixincludes. (Not presently a problem.)
1084 if test -n "$sysheaders"; then
1085 SYSINCLUDES=-nostdinc
1086 for d in include include-fixed; do
1087 i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
1088 SYSINCLUDES="$SYSINCLUDES -isystem $i"
1090 SYSINCLUDES="$SYSINCLUDES \
1091 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
1092 if test -n "$CXX"; then
1094 for cxxheaders in `$CXX -v -S -x c++ /dev/null -o /dev/null 2>&1 \
1095 | sed -n -e '1,/#include/d' -e 's/^ \(\/.*\/[cg]++\)/\1/p'`; do
1096 test "x$cxxheaders" != x &&
1097 CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders"
1101 AC_SUBST(SYSINCLUDES)
1102 AC_SUBST(CXX_SYSINCLUDES)
1104 # Obtain some C++ header file paths. This is used to make a local
1105 # copy of those headers in Makerules.
1106 if test -n "$CXX"; then
1107 find_cxx_header () {
1108 echo "#include <$1>" | $CXX -H -fsyntax-only -x c++ - 2>&1 \
1109 | $AWK '$1 == "."{print $2}'
1111 CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
1112 CXX_CMATH_HEADER="$(find_cxx_header cmath)"
1113 CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
1115 AC_SUBST(CXX_CSTDLIB_HEADER)
1116 AC_SUBST(CXX_CMATH_HEADER)
1117 AC_SUBST(CXX_BITS_STD_ABS_H)
1119 # Test if LD_LIBRARY_PATH contains the notation for the current directory
1120 # since this would lead to problems installing/building glibc.
1121 # LD_LIBRARY_PATH contains the current directory if one of the following
1123 # - one of the terminals (":" and ";") is the first or last sign
1124 # - two terminals occur directly after each other
1125 # - the path contains an element with a dot in it
1126 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
1128 case ${LD_LIBRARY_PATH} in
1129 [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
1130 ld_library_path_setting="contains current directory"
1133 ld_library_path_setting="ok"
1137 AC_MSG_RESULT($ld_library_path_setting)
1138 if test "$ld_library_path_setting" != "ok"; then
1140 *** LD_LIBRARY_PATH shouldn't contain the current directory when
1141 *** building glibc. Please change the environment variable
1142 *** and run configure again.])
1145 AC_PATH_PROG(BASH_SHELL, bash, no)
1147 AC_PATH_PROG(PERL, perl, no)
1148 if test "$PERL" != no &&
1149 (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1152 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1153 $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1155 AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
1156 cat > conftest.s <<EOF
1159 .set glibc_conftest_frobozz,foo
1160 .globl glibc_conftest_frobozz
1162 # The alpha-dec-osf1 assembler gives only a warning for `.set'
1163 # (but it doesn't work), so we must do a linking check to be sure.
1164 cat > conftest1.c <<\EOF
1165 extern int glibc_conftest_frobozz;
1166 void _start() { glibc_conftest_frobozz = 1; }
1168 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1169 -nostartfiles -nostdlib $no_ssp \
1170 -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1171 libc_cv_asm_set_directive=yes
1173 libc_cv_asm_set_directive=no
1176 if test $libc_cv_asm_set_directive = yes; then
1177 AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1180 AC_CACHE_CHECK(linker support for protected data symbol,
1181 libc_cv_protected_data,
1182 [cat > conftest.c <<EOF
1183 int bar __attribute__ ((visibility ("protected"))) = 1;
1185 libc_cv_protected_data=no
1186 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -o conftest.so); then
1187 cat > conftest.c <<EOF
1189 int main (void) { return bar; }
1191 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp conftest.c -o conftest conftest.so); then
1192 libc_cv_protected_data=yes
1197 AC_SUBST(libc_cv_protected_data)
1199 AC_CACHE_CHECK(linker support for INSERT in linker script,
1201 [cat > conftest.c <<EOF
1202 int __attribute__ ((section(".bar"))) bar = 0x12345678;
1203 int test (void) { return bar; }
1205 cat > conftest.t <<EOF
1210 INSERT AFTER .rela.dyn;
1213 if AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -Wl,-T,conftest.t -o conftest.so]); then
1218 AC_SUBST(libc_cv_insert)
1220 AC_CACHE_CHECK(for broken __attribute__((alias())),
1221 libc_cv_broken_alias_attribute,
1222 [cat > conftest.c <<EOF
1223 extern int foo (int x) __asm ("xyzzy");
1224 int bar (int x) { return x; }
1225 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1227 extern __typeof (dfoo) dfoo __asm ("abccb");
1230 libc_cv_broken_alias_attribute=yes
1231 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1232 if grep 'xyzzy' conftest.s >/dev/null &&
1233 grep 'abccb' conftest.s >/dev/null; then
1234 libc_cv_broken_alias_attribute=no
1237 rm -f conftest.c conftest.s
1239 if test $libc_cv_broken_alias_attribute = yes; then
1240 AC_MSG_ERROR(working alias attribute support required)
1243 AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
1244 libc_cv_have_sdata_section,
1245 [echo "int i;" > conftest.c
1246 libc_cv_have_sdata_section=no
1247 if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
1248 | grep '\.sdata' >/dev/null; then
1249 libc_cv_have_sdata_section=yes
1251 rm -f conftest.c conftest.so
1253 if test $libc_cv_have_sdata_section = yes; then
1254 AC_DEFINE(HAVE_SDATA_SECTION)
1257 AC_CACHE_CHECK(for libunwind-support in compiler,
1258 libc_cv_cc_with_libunwind, [
1259 cat > conftest.c <<EOF
1260 int main (void) { return 0; }
1262 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
1263 conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
1264 libc_cv_cc_with_libunwind=yes
1266 libc_cv_cc_with_libunwind=no
1269 AC_SUBST(libc_cv_cc_with_libunwind)
1270 if test $libc_cv_cc_with_libunwind = yes; then
1271 AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
1275 AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1276 libc_cv_as_noexecstack, [dnl
1277 cat > conftest.c <<EOF
1280 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1281 -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1282 && grep .note.GNU-stack conftest.s >/dev/null \
1283 && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1284 -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1286 libc_cv_as_noexecstack=yes
1288 libc_cv_as_noexecstack=no
1291 if test $libc_cv_as_noexecstack = yes; then
1292 ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1294 AC_SUBST(ASFLAGS_config)
1296 LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
1297 [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
1298 AC_SUBST(libc_cv_z_execstack)
1300 LIBC_LINKER_FEATURE([-z start-stop-gc], [-Wl,-z,start-stop-gc],
1301 [libc_cv_z_start_stop_gc=yes], [libc_cv_z_start_stop_gc=no])
1302 LIBC_CONFIG_VAR([have-z-start-stop-gc], [$libc_cv_z_start_stop_gc])
1304 LIBC_LINKER_FEATURE([--depaudit], [-Wl,--depaudit,x],
1305 [libc_cv_depaudit=yes], [libc_cv_depaudit=no])
1306 LIBC_CONFIG_VAR([have-depaudit], [$libc_cv_depaudit])
1308 LIBC_LINKER_FEATURE([-z pack-relative-relocs],
1309 [-Wl,-z,pack-relative-relocs],
1310 [libc_cv_dt_relr=yes], [libc_cv_dt_relr=no])
1311 LIBC_CONFIG_VAR([have-dt-relr], [$libc_cv_dt_relr])
1313 LIBC_LINKER_FEATURE([--no-dynamic-linker],
1314 [-Wl,--no-dynamic-linker],
1315 [libc_cv_no_dynamic_linker=yes],
1316 [libc_cv_no_dynamic_linker=no])
1317 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
1319 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
1320 LIBC_TRY_CC_OPTION([-static-pie],
1321 [libc_cv_static_pie=yes],
1322 [libc_cv_static_pie=no])
1324 LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie])
1326 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1327 LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
1330 AC_SUBST(libc_cv_fpie)
1332 AC_CACHE_CHECK(for GLOB_DAT reloc,
1333 libc_cv_has_glob_dat, [dnl
1334 cat > conftest.c <<EOF
1336 int foo (void) { return mumble; }
1338 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1339 -fPIC -shared -o conftest.so conftest.c
1340 -nostdlib -nostartfiles $no_ssp
1341 1>&AS_MESSAGE_LOG_FD])
1343 dnl look for GLOB_DAT relocation.
1344 if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
1345 libc_cv_has_glob_dat=yes
1347 libc_cv_has_glob_dat=no
1350 libc_cv_has_glob_dat=no
1353 AC_SUBST(libc_cv_has_glob_dat)
1355 AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
1357 cat > conftest.c <<EOF
1364 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -fPIC -mtls-dialect=gnu2 -nostdlib -nostartfiles
1365 conftest.c -o conftest 1>&AS_MESSAGE_LOG_FD])
1367 libc_cv_mtls_dialect_gnu2=yes
1369 libc_cv_mtls_dialect_gnu2=no
1372 AC_SUBST(libc_cv_mtls_dialect_gnu2)
1373 LIBC_CONFIG_VAR([have-mtls-dialect-gnu2], [$libc_cv_mtls_dialect_gnu2])
1375 dnl clang emits an warning for a double alias redirection, to warn the
1376 dnl original symbol is sed even when weak definition overrides it.
1377 dnl It is a usual pattern for weak_alias, where multiple alias point to
1379 AC_CACHE_CHECK([if -Wno-ignored-attributes is required for aliases],
1380 libc_cv_wno_ignored_attributes, [dnl
1381 cat > conftest.c <<EOF
1385 extern __typeof (__foo) foo __attribute__ ((weak, alias ("__foo")));
1386 extern __typeof (__foo) bar __attribute__ ((weak, alias ("foo")));
1388 libc_cv_wno_ignored_attributes=""
1389 if ! AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
1391 libc_cv_wno_ignored_attributes="-Wno-ignored-attributes"
1394 LIBC_CONFIG_VAR([config-cflags-wno-ignored-attributes],
1395 [$libc_cv_wno_ignored_attributes])
1397 AC_CACHE_CHECK(whether cc puts quotes around section names,
1398 libc_cv_have_section_quotes,
1399 [cat > conftest.c <<EOF
1400 static const int foo
1401 __attribute__ ((section ("bar"))) = 1;
1403 if ${CC-cc} -S conftest.c -o conftest.s; then
1404 if grep '\.section.*"bar"' conftest.s >/dev/null; then
1405 libc_cv_have_section_quotes=yes
1407 libc_cv_have_section_quotes=no
1410 libc_cv_have_section_quotes=unknown
1412 rm -f conftest.{c,s}
1414 if test $libc_cv_have_section_quotes = yes; then
1415 AC_DEFINE(HAVE_SECTION_QUOTES)
1418 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1419 cat > conftest.c <<\EOF
1422 __builtin_memset (x, 0, 1000);
1426 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "memset" > /dev/null]);
1428 libc_cv_gcc_builtin_memset=no
1430 libc_cv_gcc_builtin_memset=yes
1433 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1434 AC_DEFINE(HAVE_BUILTIN_MEMSET)
1437 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1438 cat > conftest.c <<\EOF
1439 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1440 char *foo (const char *a, const char *b)
1442 return __builtin_strstr (a, b);
1446 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null]);
1448 libc_cv_gcc_builtin_redirection=yes
1450 libc_cv_gcc_builtin_redirection=no
1453 if test "$libc_cv_gcc_builtin_redirection" = no; then
1454 AC_MSG_ERROR([support for the symbol redirection needed])
1457 dnl Determine how to disable generation of FMA instructions.
1458 AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1459 libc_cv_cc_nofma, [dnl
1461 for opt in -ffp-contract=off -mno-fused-madd; do
1462 LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1464 AC_SUBST(libc_cv_cc_nofma)
1466 if test -n "$submachine"; then
1467 AC_CACHE_CHECK([for compiler option for CPU variant],
1468 libc_cv_cc_submachine, [dnl
1469 libc_cv_cc_submachine=no
1470 for opt in "-march=$submachine" "-mcpu=$submachine"; do
1471 LIBC_TRY_CC_OPTION([$opt], [
1472 libc_cv_cc_submachine="$opt"
1475 if test "x$libc_cv_cc_submachine" = xno; then
1476 AC_MSG_ERROR([${CC-cc} does not support $submachine])
1479 AC_SUBST(libc_cv_cc_submachine)
1481 dnl Determine if compiler supports -fsignaling-nans
1482 AC_CACHE_CHECK([for compiler option that -fsignaling-nans],
1483 libc_cv_cc_signaling_nans, [dnl
1484 LIBC_TRY_CC_OPTION([-Werror -fsignaling-nans],
1485 [libc_cv_cc_signaling_nans=-fsignaling-nans],
1486 [libc_cv_cc_signaling_nans=])
1488 LIBC_CONFIG_VAR([config-cflags-signaling-nans],
1489 [$libc_cv_cc_signaling_nans])
1491 AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
1492 __attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
1493 cat > conftest.c <<EOF
1495 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
1498 libc_cv_cc_loop_to_function=no
1499 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c])
1501 libc_cv_cc_loop_to_function=yes
1504 if test $libc_cv_cc_loop_to_function = yes; then
1505 AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
1507 AC_SUBST(libc_cv_cc_loop_to_function)
1509 dnl Check whether we have the gd library available.
1510 AC_MSG_CHECKING(for libgd)
1511 if test "$with_gd" != "no"; then
1512 old_CFLAGS="$CFLAGS"
1513 CFLAGS="$CFLAGS $libgd_include"
1514 old_LDFLAGS="$LDFLAGS"
1515 LDFLAGS="$LDFLAGS $libgd_ldflags"
1517 LIBS="$LIBS -lgd -lpng -lz -lm"
1518 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gd.h>]], [[gdImagePng (0, 0)]])],
1519 [LIBGD=yes], [LIBGD=no])
1520 CFLAGS="$old_CFLAGS"
1521 LDFLAGS="$old_LDFLAGS"
1526 AC_MSG_RESULT($LIBGD)
1530 if test x$with_selinux = xno ; then
1533 # See if we have the SELinux library
1534 AC_CHECK_LIB(selinux, is_selinux_enabled,
1535 have_selinux=yes, have_selinux=no)
1536 if test x$with_selinux = xyes ; then
1537 if test x$have_selinux = xno ; then
1538 AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
1542 # Check if we're building with SELinux support.
1543 if test "x$have_selinux" = xyes; then
1544 AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
1546 # See if we have the libaudit library
1547 AC_CHECK_LIB(audit, audit_log_user_avc_message,
1548 have_libaudit=yes, have_libaudit=no)
1549 if test "x$have_libaudit" = xyes; then
1550 AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
1552 AC_SUBST(have_libaudit)
1554 # See if we have the libcap library
1555 AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
1556 if test "x$have_libcap" = xyes; then
1557 AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
1559 AC_SUBST(have_libcap)
1561 AC_SUBST(have_selinux)
1563 dnl Check if we support the requested _FORTIFY_SOURCE level
1564 dnl If not, then don't use it.
1565 dnl Note that _FORTIFY_SOURCE may have been set through FLAGS too.
1566 dnl _FORTIFY_SOURCE value will be selectively disabled for function that can't
1568 no_fortify_source="-Wp,-U_FORTIFY_SOURCE"
1569 fortify_source="${no_fortify_source}"
1571 AC_CACHE_CHECK([for maximum supported _FORTIFY_SOURCE level],
1572 [libc_cv_supported_fortify_source], [
1573 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_dynamic_object_size("", 0)])],
1574 [libc_cv_supported_fortify_source=3],
1575 [libc_cv_supported_fortify_source=2])
1578 AS_CASE([$enable_fortify_source],
1579 [yes], [libc_cv_fortify_source=yes enable_fortify_source=$libc_cv_supported_fortify_source],
1580 [1|2], [libc_cv_fortify_source=yes],
1581 [3], [AS_IF([test $libc_cv_supported_fortify_source = 3],
1582 [libc_cv_fortify_source=yes],
1583 [AC_MSG_ERROR([Compiler doesn't provide necessary support for _FORTIFY_SOURCE=3])])],
1584 [libc_cv_fortify_source=no])
1586 AS_IF([test "$libc_cv_fortify_source" = yes],
1587 [fortify_source="${fortify_source},-D_FORTIFY_SOURCE=${enable_fortify_source}"]
1590 AC_SUBST(enable_fortify_source)
1591 AC_SUBST(libc_cv_fortify_source)
1592 AC_SUBST(no_fortify_source)
1593 AC_SUBST(fortify_source)
1594 LIBC_CONFIG_VAR([supported-fortify], [$libc_cv_supported_fortify_source])
1596 dnl Starting with binutils 2.35, GAS can attach multiple symbol versions
1597 dnl to one symbol (PR 23840).
1598 AC_CACHE_CHECK(whether the assembler requires one version per symbol,
1599 libc_cv_symver_needs_alias, [dnl
1600 cat > conftest.s <<EOF
1604 .symver testfunc, testfunc1@VERSION1
1605 .symver testfunc, testfunc1@VERSION2
1607 libc_cv_symver_needs_alias=no
1608 if ${CC-cc} $ASFLAGS -c conftest.s 2>&AS_MESSAGE_LOG_FD; then
1609 libc_cv_symver_needs_alias=no
1611 libc_cv_symver_needs_alias=yes
1615 if test "$libc_cv_symver_needs_alias" = yes; then
1616 AC_DEFINE(SYMVER_NEEDS_ALIAS)
1619 AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
1620 libc_cv_builtin_trap, [dnl
1621 libc_cv_builtin_trap=no
1622 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[__builtin_trap ()]])],[
1623 libc_undefs=`$NM -u conftest.o |
1624 LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1625 2>&AS_MESSAGE_LOG_FD` || {
1626 AC_MSG_ERROR([confusing output from $NM -u])
1628 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1629 if test -z "$libc_undefs"; then
1630 libc_cv_builtin_trap=yes
1632 if test $libc_cv_builtin_trap = yes; then
1633 AC_DEFINE([HAVE_BUILTIN_TRAP])
1636 dnl C++ feature tests.
1639 AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
1640 libc_cv_cxx_thread_local, [
1641 old_CXXFLAGS="$CXXFLAGS"
1642 CXXFLAGS="$CXXFLAGS -std=gnu++11"
1643 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1646 // Compiler support.
1653 S * get () { return &s; }
1655 // libstdc++ support.
1656 #ifndef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
1657 #error __cxa_thread_atexit_impl not supported
1660 [libc_cv_cxx_thread_local=yes],
1661 [libc_cv_cxx_thread_local=no])
1662 CXXFLAGS="$old_CXXFLAGS"
1664 AC_SUBST(libc_cv_cxx_thread_local)
1667 dnl End of C++ feature tests.
1669 ### End of automated tests.
1670 ### Now run sysdeps configure fragments.
1672 # They also can set these variables.
1674 ldd_rewrite_script=no
1675 libc_cv_sysconfdir=$sysconfdir
1676 libc_cv_localstatedir=$localstatedir
1677 libc_cv_gcc_unwind_find_fde=no
1681 # Iterate over all the sysdep directories we will use, running their
1682 # configure fragments.
1683 for dir in $sysnames; do
1686 *) dest=$srcdir/$dir ;;
1688 if test -r $dest/configure; then
1689 AC_MSG_RESULT(running configure fragment for $dir)
1694 if test x"$build_mathvec" = xnotset; then
1697 LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
1699 AC_SUBST(libc_extra_cflags)
1700 AC_SUBST(libc_extra_cppflags)
1702 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
1703 AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
1705 AC_SUBST(libc_cv_gcc_unwind_find_fde)
1707 # A sysdeps configure fragment can reset this if IFUNC is not actually
1708 # usable even though the assembler knows how to generate the symbol type.
1709 if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
1710 AC_DEFINE(HAVE_IFUNC)
1712 LIBC_CONFIG_VAR([have-ifunc], [$libc_cv_ld_gnu_indirect_function])
1714 if test x"$libc_cv_gcc_indirect_function" = xyes; then
1715 AC_DEFINE(HAVE_GCC_IFUNC)
1717 LIBC_CONFIG_VAR([have-gcc-ifunc], [$libc_cv_gcc_indirect_function])
1719 # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
1720 # configure fragment can override the value to prevent this AC_DEFINE.
1722 if test "x$use_nscd" != xno; then
1723 AC_DEFINE([USE_NSCD])
1725 if test "x$build_nscd" = xdefault; then
1726 build_nscd=$use_nscd
1729 AC_SUBST(libc_cv_slibdir)
1730 AC_SUBST(libc_cv_rtlddir)
1731 AC_SUBST(libc_cv_complocaledir)
1732 AC_SUBST(libc_cv_sysconfdir)
1733 AC_SUBST(libc_cv_localstatedir)
1734 AC_SUBST(libc_cv_rootsbindir)
1736 if test x$use_ldconfig = xyes; then
1737 AC_DEFINE(USE_LDCONFIG)
1739 AC_SUBST(use_ldconfig)
1740 AC_SUBST(ldd_rewrite_script)
1745 AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
1746 [libc_cv_pic_default=yes
1747 cat > conftest.c <<EOF
1748 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
1749 # error PIC is default.
1752 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1753 libc_cv_pic_default=no
1756 LIBC_CONFIG_VAR([build-pic-default], [$libc_cv_pic_default])
1758 AC_CACHE_CHECK([whether -fPIE is default], libc_cv_cc_pie_default,
1759 [libc_cv_cc_pie_default=yes
1760 cat > conftest.c <<EOF
1761 #if defined __PIE__ || defined __pie__ || defined PIE || defined pie
1762 # error PIE is default.
1765 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1766 libc_cv_cc_pie_default=no
1769 LIBC_CONFIG_VAR([cc-pie-default], [$libc_cv_cc_pie_default])
1771 AC_MSG_CHECKING(if we can build programs as PIE)
1772 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifdef PIE_UNSUPPORTED
1773 # error PIE is not supported
1774 #endif]])], [libc_cv_pie_supported=yes], [libc_cv_pie_supported=no])
1775 AC_MSG_RESULT($libc_cv_pie_supported)
1776 # Disable build-pie-default if target does not support it or glibc is
1777 # configured with --disable-default-pie.
1778 if test "x$default_pie" = xno; then
1779 build_pie_default=no
1781 build_pie_default=$libc_cv_pie_supported
1783 LIBC_CONFIG_VAR([build-pie-default], [$build_pie_default])
1785 AC_MSG_CHECKING(if we can build static PIE programs)
1786 libc_cv_static_pie_supported=$libc_cv_pie_supported
1787 if test "x$libc_cv_pie_supported" != xno \
1788 -a "$libc_cv_no_dynamic_linker" = yes; then
1789 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef SUPPORT_STATIC_PIE
1790 # error static PIE is not supported
1791 #endif]])], [libc_cv_static_pie_supported=yes],
1792 [libc_cv_static_pie_supported=no])
1794 AC_MSG_RESULT($libc_cv_static_pie_supported)
1796 # Enable static-pie only if it is available and glibc isn't configured
1797 # with --disable-default-pie.
1798 if test "x$default_pie" = xno; then
1799 libc_cv_static_pie=no
1801 libc_cv_static_pie=$libc_cv_static_pie_supported
1803 if test "$libc_cv_static_pie" = "yes"; then
1804 AC_DEFINE(ENABLE_STATIC_PIE)
1806 LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
1808 # Set the `multidir' variable by grabbing the variable from the compiler.
1809 # We do it once and save the result in a generated makefile.
1810 libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
1811 AC_SUBST(libc_cv_multidir)
1814 AC_SUBST(static_nss)
1818 dnl See sysdeps/mach/configure.ac for this variable.
1819 AC_SUBST(mach_interface_list)
1821 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
1822 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
1826 if test "$pthread_in_libc" = yes; then
1827 AC_DEFINE(PTHREAD_IN_LIBC)
1829 AC_SUBST(pthread_in_libc)
1831 AC_CONFIG_FILES([config.make Makefile])
1832 AC_CONFIG_COMMANDS([default],[[
1833 case $CONFIG_FILES in *config.make*)
1834 echo "$config_vars" >> config.make;;
1836 test -d bits || mkdir bits]],[[config_vars='$config_vars']])