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 # This will get text that should go into config.make.
58 AC_ARG_ENABLE([static-c++-tests],
59 AS_HELP_STRING([--disable-static-c++-tests],
60 [disable static C++ tests@<:@default=no@:>@]),
61 [static_cxx_tests=$enableval],
62 [static_cxx_tests=yes])
63 LIBC_CONFIG_VAR([static-cxx-tests], [$static_cxx_tests])
65 AC_ARG_ENABLE([static-c++-link-check],
66 AS_HELP_STRING([--disable-static-c++-link-check],
67 [disable static C++ link check @<:@default=no@:>@]),
68 [static_cxx_link_check=$enableval],
69 [static_cxx_link_check=yes])
71 # We need the C++ compiler only for testing.
73 # It's useless to us if it can't link programs (e.g. missing -lstdc++).
74 AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl
76 # Default, dynamic case.
77 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
78 [libc_cv_cxx_link_ok=yes],
79 [libc_cv_cxx_link_ok=no])
80 if test $static_cxx_link_check$static_cxx_tests = yesyes; then
82 old_LDFLAGS="$LDFLAGS"
83 LDFLAGS="$LDFLAGS -static"
84 AC_LINK_IFELSE([AC_LANG_SOURCE([
90 std::cout << "Hello, world!";
95 [libc_cv_cxx_link_ok=no])
96 LDFLAGS="$old_LDFLAGS"
99 AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
101 if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
102 AC_MSG_ERROR([you must configure in a separate build directory])
105 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
107 AS_HELP_STRING([--with-gd=DIR],
108 [find libgd include dir and library with prefix DIR]),
112 *) libgd_include="-I$withval/include"
113 libgd_ldflags="-L$withval/lib" ;;
116 AC_ARG_WITH([gd-include],
117 AS_HELP_STRING([--with-gd-include=DIR],
118 [find libgd include files in DIR]),
120 case "$with_gd_include" in
122 *) libgd_include="-I$withval" ;;
125 AC_ARG_WITH([gd-lib],
126 AS_HELP_STRING([--with-gd-lib=DIR],
127 [find libgd library files in DIR]),
129 case "$with_gd_lib" in
131 *) libgd_ldflags="-L$withval" ;;
135 if test -n "$libgd_include"; then
136 config_vars="$config_vars
137 CFLAGS-memusagestat.c = $libgd_include"
139 if test -n "$libgd_ldflags"; then
140 config_vars="$config_vars
141 libgd-LDFLAGS = $libgd_ldflags"
144 dnl Arguments to specify presence of other packages/features.
145 AC_ARG_WITH([binutils],
146 AS_HELP_STRING([--with-binutils=PATH],
147 [specify location of binutils (as and ld)]),
148 [path_binutils=$withval],
150 AC_ARG_WITH([selinux],
151 AS_HELP_STRING([--with-selinux],
152 [if building with SELinux support]),
153 [with_selinux=$withval],
156 AC_ARG_WITH([headers],
157 AS_HELP_STRING([--with-headers=PATH],
158 [location of system headers to use
159 (for example /usr/src/linux/include)
160 @<:@default=compiler default@:>@]),
161 [sysheaders=$withval],
165 dnl Additional build flags injection.
166 AC_ARG_WITH([nonshared-cflags],
167 AS_HELP_STRING([--with-nonshared-cflags=CFLAGS],
168 [build nonshared libraries with additional CFLAGS]),
169 [extra_nonshared_cflags=$withval],
170 [extra_nonshared_cflags=])
171 AC_SUBST(extra_nonshared_cflags)
172 AC_ARG_WITH([rtld-early-cflags],
173 AS_HELP_STRING([--with-rtld-early-cflags=CFLAGS],
174 [build early initialization with additional CFLAGS]),
175 [rtld_early_cflags=$withval],
176 [rtld_early_cflags=])
177 AC_SUBST(rtld_early_cflags)
179 AC_ARG_WITH([timeoutfactor],
180 AS_HELP_STRING([--with-timeoutfactor=NUM],
181 [specify an integer to scale the timeout]),
182 [timeoutfactor=$withval],
184 AC_DEFINE_UNQUOTED(TIMEOUTFACTOR, $timeoutfactor)
186 AC_ARG_ENABLE([sanity-checks],
187 AS_HELP_STRING([--disable-sanity-checks],
188 [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
189 [enable_sanity=$enableval],
192 AC_ARG_ENABLE([shared],
193 AS_HELP_STRING([--enable-shared],
194 [build shared library @<:@default=yes if GNU ld@:>@]),
197 AC_ARG_ENABLE([profile],
198 AS_HELP_STRING([--enable-profile],
199 [build profiled library @<:@default=no@:>@]),
200 [profile=$enableval],
202 AC_ARG_ENABLE([default-pie],
203 AS_HELP_STRING([--disable-default-pie],
204 [Do not build glibc programs and the testsuite as PIE @<:@default=no@:>@]),
205 [default_pie=$enableval],
207 AC_ARG_ENABLE([timezone-tools],
208 AS_HELP_STRING([--disable-timezone-tools],
209 [do not install timezone tools @<:@default=install@:>@]),
210 [enable_timezone_tools=$enableval],
211 [enable_timezone_tools=yes])
212 AC_SUBST(enable_timezone_tools)
214 AC_ARG_ENABLE([hardcoded-path-in-tests],
215 AS_HELP_STRING([--enable-hardcoded-path-in-tests],
216 [hardcode newly built glibc path in tests @<:@default=no@:>@]),
217 [hardcoded_path_in_tests=$enableval],
218 [hardcoded_path_in_tests=no])
219 AC_SUBST(hardcoded_path_in_tests)
221 AC_ARG_ENABLE([hidden-plt],
222 AS_HELP_STRING([--disable-hidden-plt],
223 [do not hide internal function calls to avoid PLT]),
226 if test "x$hidden" = xno; then
230 AC_ARG_ENABLE([bind-now],
231 AS_HELP_STRING([--enable-bind-now],
232 [disable lazy relocations in DSOs]),
233 [bindnow=$enableval],
236 if test "x$bindnow" = xyes; then
240 dnl Build glibc with -fstack-protector, -fstack-protector-all, or
241 dnl -fstack-protector-strong.
242 AC_ARG_ENABLE([stack-protector],
243 AS_HELP_STRING([--enable-stack-protector=@<:@yes|no|all|strong@:>@],
244 [Use -fstack-protector[-all|-strong] to detect glibc buffer overflows]),
245 [enable_stack_protector=$enableval],
246 [enable_stack_protector=no])
247 case "$enable_stack_protector" in
248 all|yes|no|strong) ;;
249 *) AC_MSG_ERROR([Not a valid argument for --enable-stack-protector: "$enable_stack_protector"]);;
252 dnl On some platforms we cannot use dynamic loading. We must provide
253 dnl static NSS modules.
254 AC_ARG_ENABLE([static-nss],
255 AS_HELP_STRING([--enable-static-nss],
256 [build static NSS modules @<:@default=no@:>@]),
257 [static_nss=$enableval],
259 dnl Enable static NSS also if we build no shared objects.
260 if test x"$static_nss" = xyes || test x"$shared" = xno; then
262 AC_DEFINE(DO_STATIC_NSS)
265 AC_ARG_ENABLE([force-install],
266 AS_HELP_STRING([--disable-force-install],
267 [don't force installation of files from this package, even if they are older than the installed files]),
268 [force_install=$enableval],
270 AC_SUBST(force_install)
272 AC_ARG_ENABLE([maintainer-mode],
273 AS_HELP_STRING([--enable-maintainer-mode],
274 [enable make rules and dependencies not useful (and sometimes confusing) to the casual installer]),
275 [maintainer=$enableval],
278 dnl On some platforms we allow dropping compatibility with all kernel
280 AC_ARG_ENABLE([kernel],
281 AS_HELP_STRING([--enable-kernel=VERSION],
282 [compile for compatibility with kernel not older than VERSION]),
283 [minimum_kernel=$enableval],
285 dnl Prevent unreasonable values.
286 if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
287 # Better nothing than this.
290 if test "$minimum_kernel" = current; then
291 minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
295 AC_ARG_ENABLE([werror],
296 AS_HELP_STRING([--disable-werror],
297 [do not build with -Werror]),
298 [enable_werror=$enableval],
300 AC_SUBST(enable_werror)
302 AC_ARG_ENABLE([multi-arch],
303 AS_HELP_STRING([--enable-multi-arch],
304 [enable single DSO with optimizations for multiple architectures]),
305 [multi_arch=$enableval],
306 [multi_arch=default])
308 AC_ARG_ENABLE([memory-tagging],
309 AS_HELP_STRING([--enable-memory-tagging],
310 [enable memory tagging if supported by the architecture @<:@default=no@:>@]),
311 [memory_tagging=$enableval],
313 if test "$memory_tagging" = yes; then
314 # Only enable this on architectures that support it.
321 AC_SUBST(memory_tagging)
323 AC_ARG_ENABLE([systemtap],
324 [AS_HELP_STRING([--enable-systemtap],
325 [enable systemtap static probe points @<:@default=no@:>@])],
326 [systemtap=$enableval],
328 if test "x$systemtap" != xno; then
329 AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
331 CFLAGS="-std=gnu11 $CFLAGS"
332 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
333 void foo (int i, void *p)
335 asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
336 :: STAP_PROBE_ASM_OPERANDS (2, i, p));
337 }]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
338 CFLAGS="$old_CFLAGS"])
339 if test $libc_cv_sdt = yes; then
340 AC_DEFINE([USE_STAP_PROBE])
341 elif test "x$systemtap" != xauto; then
342 AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
346 AC_ARG_ENABLE([build-nscd],
347 [AS_HELP_STRING([--disable-build-nscd],
348 [disable building and installing the nscd daemon])],
349 [build_nscd=$enableval],
350 [build_nscd=default])
353 # Note the use of $use_nscd is near the bottom of the file.
354 AC_ARG_ENABLE([nscd],
355 [AS_HELP_STRING([--disable-nscd],
356 [library functions will not contact the nscd daemon])],
357 [use_nscd=$enableval],
360 AC_ARG_ENABLE([pt_chown],
361 [AS_HELP_STRING([--enable-pt_chown],
362 [Enable building and installing pt_chown])],
363 [build_pt_chown=$enableval],
365 AC_SUBST(build_pt_chown)
366 if test "$build_pt_chown" = yes; then
367 AC_DEFINE(HAVE_PT_CHOWN)
370 # The abi-tags file uses a fairly simplistic model for name recognition that
371 # can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
372 # $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
373 # This doesn't get used much beyond that, so it's fairly safe.
378 host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
382 AC_ARG_ENABLE([mathvec],
383 [AS_HELP_STRING([--enable-mathvec],
384 [Enable building and installing mathvec @<:@default depends on architecture@:>@])],
385 [build_mathvec=$enableval],
386 [build_mathvec=notset])
388 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
390 # error no CET compiler support
392 [libc_cv_compiler_default_cet=yes],
393 [libc_cv_compiler_default_cet=no])
396 AS_HELP_STRING([--enable-cet],
397 [enable Intel Control-flow Enforcement Technology (CET), x86 only]),
398 [enable_cet=$enableval],
399 [enable_cet=$libc_cv_compiler_default_cet])
402 AS_HELP_STRING([--disable-scv],
403 [syscalls will not use scv instruction, even if the kernel supports it, powerpc only]),
404 [use_scv=$enableval],
407 AS_IF([[test "$use_scv" != "no"]],[AC_DEFINE(USE_PPC_SCV)])
409 dnl Build glibc with _FORTIFY_SOURCE
410 AC_ARG_ENABLE(fortify-source,
411 AS_HELP_STRING([--enable-fortify-source@<:@=1|2|3@:>@],
412 [Use -D_FORTIFY_SOURCE=[1|2|3] to control code hardening, defaults to highest possible value supported by the build compiler.]),
413 [enable_fortify_source=$enableval],
414 [enable_fortify_source=no])
415 case "$enable_fortify_source" in
417 *) AC_MSG_ERROR([Not a valid argument for --enable-fortify-source: "$enable_fortify_source"]);;
420 # We keep the original values in `$config_*' and never modify them, so we
421 # can write them unchanged into config.make. Everything else uses
422 # $machine, $vendor, and $os, and changes them whenever convenient.
423 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
425 # Don't allow vendor == "unknown"
426 test "$config_vendor" = unknown && config_vendor=
427 config_os="`echo $config_os | sed 's/^unknown-//'`"
429 # Some configurations imply other options.
432 # The configure fragment of a port can modify these to supplement
433 # or override the table in the case statement below. No fragment should
434 # ever change the config_* variables, however.
435 machine=$config_machine
436 vendor=$config_vendor
442 AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
445 yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
447 *) submachine="$withval" ;;
451 # An preconfigure script can set this when it wants to disable the sanity
455 # A preconfigure script for a system that may or may not use fpu
456 # sysdeps directories sets this to a preprocessor conditional for
457 # whether to use such directories.
460 # A preconfigure script may define another name to TLS descriptor variant
463 dnl Let sysdeps/*/preconfigure act here.
464 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
468 ### By using the undocumented --enable-hacker-mode option for configure
469 ### one can skip this test to make the configuration not fail for unsupported
472 if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
473 case "$machine-$host_os" in
478 *** The GNU C library is currently unavailable for this platform.
479 *** If you are interested in seeing glibc on this platform visit
480 *** the "How to submit a new port" in the wiki:
481 *** https://sourceware.org/glibc/wiki/#Development
482 *** and join the community!])
487 # Set base_machine if not set by a preconfigure fragment.
488 test -n "$base_machine" || base_machine=$machine
489 AC_SUBST(base_machine)
494 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
495 # The makefiles need to use a different form to find it in $srcdir.
496 INSTALL='\$(..)./scripts/install-sh -c'
502 # Accept binutils 2.25 or newer.
504 case $($LD --version) in
506 # Accept gold 1.14 or higher
507 AC_CHECK_PROG_VER(LD, $LD, --version,
508 [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
509 [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
510 LD=: critic_missing="$critic_missing GNU gold")
513 # Accept LLD 13.0.0 or higher
514 AC_CHECK_PROG_VER(LD, $LD, --version,
515 [LLD.* \([0-9][0-9]*\.[0-9.]*\)],
516 [1[3-9].*|[2-9][0-9].*],
517 LD=: critic_missing="$critic_missing LLD")
521 AC_CHECK_PROG_VER(LD, $LD, --version,
522 [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
523 [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
524 LD=: critic_missing="$critic_missing GNU ld")
527 LIBC_CONFIG_VAR([with-lld], [$libc_cv_with_lld])
529 # These programs are version sensitive.
530 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
531 [GNU Make[^0-9]*\([0-9][0-9.]*\)],
532 [[4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
534 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
535 [GNU gettext.* \([0-9]*\.[0-9.]*\)],
536 [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
537 MSGFMT=: aux_missing="$aux_missing msgfmt")
538 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
539 [GNU texinfo.* \([0-9][0-9.]*\)],
540 [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
541 MAKEINFO=: aux_missing="$aux_missing makeinfo")
542 AC_CHECK_PROG_VER(SED, sed, --version,
543 [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
544 [3.0[2-9]*|3.[1-9]*|[4-9]*],
545 SED=: aux_missing="$aux_missing sed")
546 AC_CHECK_PROG_VER(AWK, gawk, --version,
547 [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
548 [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
549 AC_CHECK_PROG_VER(BISON, bison, --version,
550 [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
551 [2.7*|[3-9].*|[1-9][0-9]*], critic_missing="$critic_missing bison")
553 AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
554 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
555 #if !defined __GNUC__ || __GNUC__ < 6 || (__GNUC__ == 6 && __GNUC_MINOR__ < 2)
556 #error insufficient compiler
558 [libc_cv_compiler_ok=yes],
559 [libc_cv_compiler_ok=no])])
560 AS_IF([test $libc_cv_compiler_ok != yes],
561 [critic_missing="$critic_missing compiler"])
563 if test "x$maintainer" = "xyes"; then
564 AC_CHECK_PROGS(AUTOCONF, autoconf, no)
566 xno|x|x:) AUTOCONF=no ;;
569 whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
570 if (cd $srcdir; $AUTOCONF $ACFLAGS configure.ac > /dev/null 2>&1); then
571 libc_cv_autoconf_works=yes
573 libc_cv_autoconf_works=no
575 test $libc_cv_autoconf_works = yes || AUTOCONF=no
578 if test "x$AUTOCONF" = xno; then
579 aux_missing="$aux_missing autoconf"
585 # Check for python3 if available, or else python.
586 AC_CHECK_PROG_VER(PYTHON_PROG, python3 python, --version,
587 [Python \([0-9][0-9.]*\)],
588 [3.[4-9]*|3.[1-9][0-9]*|[4-9].*|[1-9][0-9]*],
589 critic_missing="$critic_missing python")
590 PYTHON="$PYTHON_PROG -B"
593 test -n "$critic_missing" && AC_MSG_ERROR([
594 *** These critical programs are missing or too old:$critic_missing
595 *** Check the INSTALL file for required versions.])
597 test -n "$aux_missing" && AC_MSG_WARN([
598 *** These auxiliary programs are missing or incompatible versions:$aux_missing
599 *** some features or tests will be disabled.
600 *** Check the INSTALL file for required versions.])
603 # Determine whether to use fpu or nofpu sysdeps directories.
604 AC_CACHE_CHECK([for use of fpu sysdeps directories],
605 libc_cv_with_fp, [dnl
606 cat > conftest.c <<EOF
610 # error "no hardware floating point"
614 if ${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c -o conftest.s \
615 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
619 AC_SUBST(libc_cv_with_fp)
621 AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
622 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
627 AC_CACHE_CHECK(for -fstack-protector-strong, libc_cv_ssp_strong, [dnl
628 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-strong],
629 [libc_cv_ssp_strong=yes],
630 [libc_cv_ssp_strong=no])
633 AC_CACHE_CHECK(for -fstack-protector-all, libc_cv_ssp_all, [dnl
634 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-all],
635 [libc_cv_ssp_all=yes],
636 [libc_cv_ssp_all=no])
641 if test "$libc_cv_ssp" = yes; then
642 no_stack_protector="-fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0"
643 AC_DEFINE(HAVE_CC_NO_STACK_PROTECTOR)
646 if test "$enable_stack_protector" = yes && test "$libc_cv_ssp" = yes; then
647 stack_protector="-fstack-protector"
648 AC_DEFINE(STACK_PROTECTOR_LEVEL, 1)
649 elif test "$enable_stack_protector" = all && test "$libc_cv_ssp_all" = yes; then
650 stack_protector="-fstack-protector-all"
651 AC_DEFINE(STACK_PROTECTOR_LEVEL, 2)
652 elif test "$enable_stack_protector" = strong && test "$libc_cv_ssp_strong" = yes; then
653 stack_protector="-fstack-protector-strong"
654 AC_DEFINE(STACK_PROTECTOR_LEVEL, 3)
656 stack_protector="-fno-stack-protector"
657 AC_DEFINE(STACK_PROTECTOR_LEVEL, 0)
659 AC_SUBST(libc_cv_ssp)
660 AC_SUBST(stack_protector)
661 AC_SUBST(no_stack_protector)
663 if test -n "$stack_protector"; then
664 dnl Don't run configure tests with stack-protection on, to avoid problems with
666 no_ssp=-fno-stack-protector
670 if test "$enable_stack_protector" != no; then
671 AC_MSG_ERROR([--enable-stack-protector=$enable_stack_protector specified, but specified level of stack protection is not supported by the compiler.])
675 # For the multi-arch option we need support in the assembler & linker.
676 AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
677 libc_cv_ld_gnu_indirect_function, [dnl
678 cat > conftest.S <<EOF
679 .type foo,%gnu_indirect_function
692 libc_cv_ld_gnu_indirect_function=no
693 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
694 -nostartfiles -nostdlib $no_ssp \
695 -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
696 # Do a link to see if the backend supports IFUNC relocs.
697 $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
698 LC_ALL=C $READELF -Wr conftest | grep -q 'IRELATIVE\|R_SPARC_JMP_IREL' && {
699 libc_cv_ld_gnu_indirect_function=yes
704 # Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
705 AC_CACHE_CHECK([for gcc attribute ifunc support],
706 libc_cv_gcc_indirect_function, [dnl
707 cat > conftest.c <<EOF
708 extern int func (int);
709 int used_func (int a)
713 static void *resolver ()
717 extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
719 libc_cv_gcc_indirect_function=no
720 if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
721 2>&AS_MESSAGE_LOG_FD ; then
722 if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&AS_MESSAGE_LOG_FD; then
723 libc_cv_gcc_indirect_function=yes
728 # Check if linker supports textrel relocation with ifunc (used on elf/tests).
729 # Note that it relies on libc_cv_ld_gnu_indirect_function test above.
730 AC_CACHE_CHECK([whether the linker supports textrels along with ifunc],
731 libc_cv_textrel_ifunc, [dnl
732 cat > conftest.S <<EOF
733 .type foo,%gnu_indirect_function
754 libc_cv_textrel_ifunc=no
755 if test $libc_cv_ld_gnu_indirect_function = yes; then
756 if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib $no_ssp -pie -o conftest conftest.S); then
757 libc_cv_textrel_ifunc=yes
761 AC_SUBST(libc_cv_textrel_ifunc)
763 # Check if CC supports attribute retain as it is used in attribute_used_retain macro.
764 AC_CACHE_CHECK([for GNU attribute retain support],
765 libc_cv_gnu_retain, [dnl
766 cat > conftest.c <<EOF
767 static int var __attribute__ ((used, retain, section ("__libc_atexit")));
769 libc_cv_gnu_retain=no
770 if ${CC-cc} -Werror -c conftest.c -o /dev/null 1>&AS_MESSAGE_LOG_FD \
771 2>&AS_MESSAGE_LOG_FD ; then
772 libc_cv_gnu_retain=yes
775 if test $libc_cv_gnu_retain = yes; then
776 AC_DEFINE(HAVE_GNU_RETAIN)
778 LIBC_CONFIG_VAR([have-gnu-retain], [$libc_cv_gnu_retain])
780 # Check if gcc warns about alias for function with incompatible types.
781 AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
782 libc_cv_gcc_incompatible_alias, [dnl
783 cat > conftest.c <<EOF
784 int __redirect_foo (const void *s, int c);
786 __typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
787 __typeof (__redirect_foo) *foo_impl (void)
792 extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
794 libc_cv_gcc_incompatible_alias=yes
795 if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
796 libc_cv_gcc_incompatible_alias=no
800 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
801 if test x"$multi_arch" = xyes; then
802 AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
807 if test x"$libc_cv_gcc_indirect_function" != xyes; then
808 # GCC 8+ emits a warning for alias with incompatible types and it might
809 # fail to build ifunc resolvers aliases to either weak or internal
810 # symbols. Disables multiarch build in this case.
811 if test x"$libc_cv_gcc_incompatible_alias" = xyes; then
812 AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types])
813 if test x"$multi_arch" = xyes; then
814 AC_MSG_ERROR([--enable-multi-arch support requires a gcc with gnu-indirect-function support])
816 AC_MSG_WARN([Multi-arch is disabled.])
818 elif test x"$multi_arch" = xyes; then
819 AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
820 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
824 if test x"$multi_arch" != xno; then
825 multi_arch_d=/multiarch
828 # Compute the list of sysdep directories for this configuration.
829 # This can take a while to compute.
830 sysdep_dir=$srcdir/sysdeps
831 AC_MSG_CHECKING(sysdep dirs)
832 dnl We need to use [ and ] for other purposes for a while now.
834 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
835 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
837 test "x$base_os" != x || case "$os" in
844 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
847 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
851 o=`echo $tail | sed 's/[0-9]*$//'`
852 if test $o != $tail; then
855 # For linux-gnu, try linux-gnu, then linux.
856 o=`echo $tail | sed 's/-.*$//'`
857 if test $o != $tail; then
861 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
864 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
870 # For sparc/sparc32, try sparc/sparc32 and then sparc.
872 tail=$machine${submachine:+/$submachine}
873 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
875 # Prepend the machine's FPU directory unless the architecture specific
876 # preconfigure disables it.
877 if test "$libc_cv_with_fp" = yes; then
882 # For each machine term, try it with and then without /multiarch.
883 for try_fpu in $maybe_fpu ''; do
884 for try_multi in $multi_arch_d ''; do
885 mach="$mach /$1$try_fpu$try_multi"
891 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
894 # Find what sysdep directories exist.
896 for b in $base ''; do
897 for m0 in $mach ''; do
898 for v in /$vendor ''; do
899 test "$v" = / && continue
900 for o in /$ostry ''; do
901 test "$o" = / && continue
902 for m in $mach ''; do
903 try_suffix="$m0$b$v$o$m"
904 if test -n "$try_suffix"; then
905 try_srcdir="${srcdir}/"
906 try="sysdeps$try_suffix"
907 test -n "$enable_debug_configure" &&
908 echo "$0 [DEBUG]: try $try" >&2
909 if test -d "$try_srcdir$try"; then
910 sysnames="$sysnames $try"
911 { test -n "$o" || test -n "$b"; } && os_used=t
912 { test -n "$m" || test -n "$m0"; } && machine_used=t
914 x*/$submachine) submachine_used=t ;;
924 # If the assembler supports gnu_indirect_function symbol type and the
925 # architecture supports multi-arch, we enable multi-arch by default.
930 test x"$multi_arch" = xdefault && multi_arch=no
933 if test x"$multi_arch" != xno; then
934 AC_DEFINE(USE_MULTIARCH)
938 if test -z "$os_used" && test "$os" != none; then
939 AC_MSG_ERROR(Operating system $os is not supported.)
941 if test -z "$machine_used" && test "$machine" != none; then
942 AC_MSG_ERROR(The $machine is not supported.)
944 if test -z "$submachine_used" && test -n "$submachine"; then
945 AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
949 # We have now validated the configuration.
951 # Expand the list of system names into a full list of directories
952 # from each element's parent name and Implies file (if present).
955 while test $# -gt 0; do
959 case " $names " in *" $name "*)
960 # Already in the list.
964 # Report each name as we discover it, so there is no long pause in output.
965 echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
967 name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
971 *) xsrcdir=$srcdir/ ;;
973 test -n "$enable_debug_configure" &&
974 echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
976 for implies_file in Implies Implies-before Implies-after; do
977 implies_type=`echo $implies_file | sed s/-/_/`
978 eval ${implies_type}=
979 if test -f $xsrcdir$name/$implies_file; then
980 # Collect more names from the `Implies' file (removing comments).
981 implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/$implies_file`"
982 for x in $implied_candidate; do
984 if test -d $xsrcdir$name_base/$x; then
985 eval "${implies_type}=\"\$${implies_type} \$name_base/\$x\""
990 test -n "$enable_debug_configure" &&
991 echo "[DEBUG]: $name $implies_file $x try() {$try_srcdir}$try" >&2
992 if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
994 eval "${implies_type}=\"\$${implies_type} \$try\""
997 if test $found = no; then
998 AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
1004 # Add NAME to the list of names.
1005 names="$names $name"
1007 # Find the parent of NAME, using the empty string if it has none.
1009 parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
1012 test -n "$enable_debug_configure" &&
1013 echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
1014 Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
1016 # Add the names implied by NAME, and NAME's parent (if it has one), to
1017 # the list of names to be processed (the argument list). We prepend the
1018 # implied names to the list and append the parent. We want implied
1019 # directories to come before further directories inferred from the
1020 # configuration components; this ensures that for sysv4, unix/common
1021 # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
1023 sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
1024 test -n "$sysnames" && set $sysnames
1027 # Add the default directories.
1028 default_sysnames="sysdeps/generic"
1029 sysnames="$names $default_sysnames"
1031 # The other names were emitted during the scan.
1032 AC_MSG_RESULT($default_sysnames)
1034 # if using special system headers, find out the compiler's sekrit
1035 # header directory and add that to the list. NOTE: Only does the right
1036 # thing on a system that doesn't need fixincludes. (Not presently a problem.)
1037 if test -n "$sysheaders"; then
1038 SYSINCLUDES=-nostdinc
1039 for d in include include-fixed; do
1040 i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
1041 SYSINCLUDES="$SYSINCLUDES -isystem $i"
1043 SYSINCLUDES="$SYSINCLUDES \
1044 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
1045 if test -n "$CXX"; then
1047 for cxxheaders in `$CXX -v -S -x c++ /dev/null -o /dev/null 2>&1 \
1048 | sed -n -e '1,/#include/d' -e 's/^ \(\/.*\/[cg]++\)/\1/p'`; do
1049 test "x$cxxheaders" != x &&
1050 CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders"
1054 AC_SUBST(SYSINCLUDES)
1055 AC_SUBST(CXX_SYSINCLUDES)
1057 # Obtain some C++ header file paths. This is used to make a local
1058 # copy of those headers in Makerules.
1059 if test -n "$CXX"; then
1060 find_cxx_header () {
1061 echo "#include <$1>" | $CXX -H -fsyntax-only -x c++ - 2>&1 \
1062 | $AWK '$1 == "."{print $2}'
1064 CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
1065 CXX_CMATH_HEADER="$(find_cxx_header cmath)"
1066 CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
1068 AC_SUBST(CXX_CSTDLIB_HEADER)
1069 AC_SUBST(CXX_CMATH_HEADER)
1070 AC_SUBST(CXX_BITS_STD_ABS_H)
1072 # Test if LD_LIBRARY_PATH contains the notation for the current directory
1073 # since this would lead to problems installing/building glibc.
1074 # LD_LIBRARY_PATH contains the current directory if one of the following
1076 # - one of the terminals (":" and ";") is the first or last sign
1077 # - two terminals occur directly after each other
1078 # - the path contains an element with a dot in it
1079 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
1081 case ${LD_LIBRARY_PATH} in
1082 [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
1083 ld_library_path_setting="contains current directory"
1086 ld_library_path_setting="ok"
1090 AC_MSG_RESULT($ld_library_path_setting)
1091 if test "$ld_library_path_setting" != "ok"; then
1093 *** LD_LIBRARY_PATH shouldn't contain the current directory when
1094 *** building glibc. Please change the environment variable
1095 *** and run configure again.])
1098 AC_PATH_PROG(BASH_SHELL, bash, no)
1100 AC_PATH_PROG(PERL, perl, no)
1101 if test "$PERL" != no &&
1102 (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1105 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1106 $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1108 AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
1109 cat > conftest.s <<EOF
1112 .set glibc_conftest_frobozz,foo
1113 .globl glibc_conftest_frobozz
1115 # The alpha-dec-osf1 assembler gives only a warning for `.set'
1116 # (but it doesn't work), so we must do a linking check to be sure.
1117 cat > conftest1.c <<\EOF
1118 extern int glibc_conftest_frobozz;
1119 void _start() { glibc_conftest_frobozz = 1; }
1121 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1122 -nostartfiles -nostdlib $no_ssp \
1123 -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1124 libc_cv_asm_set_directive=yes
1126 libc_cv_asm_set_directive=no
1129 if test $libc_cv_asm_set_directive = yes; then
1130 AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1133 AC_CACHE_CHECK(linker support for protected data symbol,
1134 libc_cv_protected_data,
1135 [cat > conftest.c <<EOF
1136 int bar __attribute__ ((visibility ("protected"))) = 1;
1138 libc_cv_protected_data=no
1139 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -o conftest.so); then
1140 cat > conftest.c <<EOF
1142 int main (void) { return bar; }
1144 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp conftest.c -o conftest conftest.so); then
1145 libc_cv_protected_data=yes
1150 AC_SUBST(libc_cv_protected_data)
1152 AC_CACHE_CHECK(linker support for INSERT in linker script,
1154 [cat > conftest.c <<EOF
1155 int __attribute__ ((section(".bar"))) bar = 0x12345678;
1156 int test (void) { return bar; }
1158 cat > conftest.t <<EOF
1163 INSERT AFTER .rela.dyn;
1166 if AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -Wl,-T,conftest.t -o conftest.so]); then
1171 AC_SUBST(libc_cv_insert)
1173 AC_CACHE_CHECK(for broken __attribute__((alias())),
1174 libc_cv_broken_alias_attribute,
1175 [cat > conftest.c <<EOF
1176 extern int foo (int x) __asm ("xyzzy");
1177 int bar (int x) { return x; }
1178 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1180 extern __typeof (dfoo) dfoo __asm ("abccb");
1183 libc_cv_broken_alias_attribute=yes
1184 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1185 if grep 'xyzzy' conftest.s >/dev/null &&
1186 grep 'abccb' conftest.s >/dev/null; then
1187 libc_cv_broken_alias_attribute=no
1190 rm -f conftest.c conftest.s
1192 if test $libc_cv_broken_alias_attribute = yes; then
1193 AC_MSG_ERROR(working alias attribute support required)
1196 AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
1197 libc_cv_have_sdata_section,
1198 [echo "int i;" > conftest.c
1199 libc_cv_have_sdata_section=no
1200 if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
1201 | grep '\.sdata' >/dev/null; then
1202 libc_cv_have_sdata_section=yes
1204 rm -f conftest.c conftest.so
1206 if test $libc_cv_have_sdata_section = yes; then
1207 AC_DEFINE(HAVE_SDATA_SECTION)
1210 AC_CACHE_CHECK(for libunwind-support in compiler,
1211 libc_cv_cc_with_libunwind, [
1212 cat > conftest.c <<EOF
1213 int main (void) { return 0; }
1215 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
1216 conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
1217 libc_cv_cc_with_libunwind=yes
1219 libc_cv_cc_with_libunwind=no
1222 AC_SUBST(libc_cv_cc_with_libunwind)
1223 if test $libc_cv_cc_with_libunwind = yes; then
1224 AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
1228 AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1229 libc_cv_as_noexecstack, [dnl
1230 cat > conftest.c <<EOF
1233 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1234 -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1235 && grep .note.GNU-stack conftest.s >/dev/null \
1236 && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1237 -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1239 libc_cv_as_noexecstack=yes
1241 libc_cv_as_noexecstack=no
1244 if test $libc_cv_as_noexecstack = yes; then
1245 ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1247 AC_SUBST(ASFLAGS_config)
1249 LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
1250 [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
1251 AC_SUBST(libc_cv_z_execstack)
1253 LIBC_LINKER_FEATURE([-z start-stop-gc], [-Wl,-z,start-stop-gc],
1254 [libc_cv_z_start_stop_gc=yes], [libc_cv_z_start_stop_gc=no])
1255 LIBC_CONFIG_VAR([have-z-start-stop-gc], [$libc_cv_z_start_stop_gc])
1257 LIBC_LINKER_FEATURE([--depaudit], [-Wl,--depaudit,x],
1258 [libc_cv_depaudit=yes], [libc_cv_depaudit=no])
1259 LIBC_CONFIG_VAR([have-depaudit], [$libc_cv_depaudit])
1261 LIBC_LINKER_FEATURE([-z pack-relative-relocs],
1262 [-Wl,-z,pack-relative-relocs],
1263 [libc_cv_dt_relr=yes], [libc_cv_dt_relr=no])
1264 LIBC_CONFIG_VAR([have-dt-relr], [$libc_cv_dt_relr])
1266 LIBC_LINKER_FEATURE([--no-dynamic-linker],
1267 [-Wl,--no-dynamic-linker],
1268 [libc_cv_no_dynamic_linker=yes],
1269 [libc_cv_no_dynamic_linker=no])
1270 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
1272 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
1273 LIBC_TRY_CC_OPTION([-static-pie],
1274 [libc_cv_static_pie=yes],
1275 [libc_cv_static_pie=no])
1277 LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie])
1279 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1280 LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
1283 AC_SUBST(libc_cv_fpie)
1285 AC_CACHE_CHECK(for GLOB_DAT reloc,
1286 libc_cv_has_glob_dat, [dnl
1287 cat > conftest.c <<EOF
1289 int foo (void) { return mumble; }
1291 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1292 -fPIC -shared -o conftest.so conftest.c
1293 -nostdlib -nostartfiles $no_ssp
1294 1>&AS_MESSAGE_LOG_FD])
1296 dnl look for GLOB_DAT relocation.
1297 if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
1298 libc_cv_has_glob_dat=yes
1300 libc_cv_has_glob_dat=no
1303 libc_cv_has_glob_dat=no
1306 AC_SUBST(libc_cv_has_glob_dat)
1308 AC_CACHE_CHECK([for tls descriptor support], libc_cv_mtls_descriptor,
1310 cat > conftest.c <<EOF
1317 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -fPIC -mtls-dialect=$mtls_descriptor -nostdlib -nostartfiles
1318 -shared conftest.c -o conftest 1>&AS_MESSAGE_LOG_FD])
1320 libc_cv_mtls_descriptor=$mtls_descriptor
1322 libc_cv_mtls_descriptor=no
1325 AC_SUBST(libc_cv_mtls_descriptor)
1326 LIBC_CONFIG_VAR([have-mtls-descriptor], [$libc_cv_mtls_descriptor])
1328 dnl clang emits an warning for a double alias redirection, to warn the
1329 dnl original symbol is sed even when weak definition overrides it.
1330 dnl It is a usual pattern for weak_alias, where multiple alias point to
1332 AC_CACHE_CHECK([if -Wno-ignored-attributes is required for aliases],
1333 libc_cv_wno_ignored_attributes, [dnl
1334 cat > conftest.c <<EOF
1338 extern __typeof (__foo) foo __attribute__ ((weak, alias ("__foo")));
1339 extern __typeof (__foo) bar __attribute__ ((weak, alias ("foo")));
1341 libc_cv_wno_ignored_attributes=""
1342 if ! AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
1344 libc_cv_wno_ignored_attributes="-Wno-ignored-attributes"
1347 LIBC_CONFIG_VAR([config-cflags-wno-ignored-attributes],
1348 [$libc_cv_wno_ignored_attributes])
1350 AC_CACHE_CHECK(whether cc puts quotes around section names,
1351 libc_cv_have_section_quotes,
1352 [cat > conftest.c <<EOF
1353 static const int foo
1354 __attribute__ ((section ("bar"))) = 1;
1356 if ${CC-cc} -S conftest.c -o conftest.s; then
1357 if grep '\.section.*"bar"' conftest.s >/dev/null; then
1358 libc_cv_have_section_quotes=yes
1360 libc_cv_have_section_quotes=no
1363 libc_cv_have_section_quotes=unknown
1365 rm -f conftest.{c,s}
1367 if test $libc_cv_have_section_quotes = yes; then
1368 AC_DEFINE(HAVE_SECTION_QUOTES)
1371 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1372 cat > conftest.c <<\EOF
1375 __builtin_memset (x, 0, 1000);
1379 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "memset" > /dev/null]);
1381 libc_cv_gcc_builtin_memset=no
1383 libc_cv_gcc_builtin_memset=yes
1386 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1387 AC_DEFINE(HAVE_BUILTIN_MEMSET)
1390 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1391 cat > conftest.c <<\EOF
1392 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1393 char *foo (const char *a, const char *b)
1395 return __builtin_strstr (a, b);
1399 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null]);
1401 libc_cv_gcc_builtin_redirection=yes
1403 libc_cv_gcc_builtin_redirection=no
1406 if test "$libc_cv_gcc_builtin_redirection" = no; then
1407 AC_MSG_ERROR([support for the symbol redirection needed])
1410 dnl Determine how to disable generation of FMA instructions.
1411 AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1412 libc_cv_cc_nofma, [dnl
1414 for opt in -ffp-contract=off -mno-fused-madd; do
1415 LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1417 AC_SUBST(libc_cv_cc_nofma)
1419 if test -n "$submachine"; then
1420 AC_CACHE_CHECK([for compiler option for CPU variant],
1421 libc_cv_cc_submachine, [dnl
1422 libc_cv_cc_submachine=no
1423 for opt in "-march=$submachine" "-mcpu=$submachine"; do
1424 LIBC_TRY_CC_OPTION([$opt], [
1425 libc_cv_cc_submachine="$opt"
1428 if test "x$libc_cv_cc_submachine" = xno; then
1429 AC_MSG_ERROR([${CC-cc} does not support $submachine])
1432 AC_SUBST(libc_cv_cc_submachine)
1434 dnl Determine if compiler supports -fsignaling-nans
1435 AC_CACHE_CHECK([for compiler option that -fsignaling-nans],
1436 libc_cv_cc_signaling_nans, [dnl
1437 LIBC_TRY_CC_OPTION([-Werror -fsignaling-nans],
1438 [libc_cv_cc_signaling_nans=-fsignaling-nans],
1439 [libc_cv_cc_signaling_nans=])
1441 LIBC_CONFIG_VAR([config-cflags-signaling-nans],
1442 [$libc_cv_cc_signaling_nans])
1444 AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
1445 __attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
1446 cat > conftest.c <<EOF
1448 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
1451 libc_cv_cc_loop_to_function=no
1452 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c])
1454 libc_cv_cc_loop_to_function=yes
1457 if test $libc_cv_cc_loop_to_function = yes; then
1458 AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
1460 AC_SUBST(libc_cv_cc_loop_to_function)
1462 dnl Check whether we have the gd library available.
1463 AC_MSG_CHECKING(for libgd)
1464 if test "$with_gd" != "no"; then
1465 old_CFLAGS="$CFLAGS"
1466 CFLAGS="$CFLAGS $libgd_include"
1467 old_LDFLAGS="$LDFLAGS"
1468 LDFLAGS="$LDFLAGS $libgd_ldflags"
1470 LIBS="$LIBS -lgd -lpng -lz -lm"
1471 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gd.h>]], [[gdImagePng (0, 0)]])],
1472 [LIBGD=yes], [LIBGD=no])
1473 CFLAGS="$old_CFLAGS"
1474 LDFLAGS="$old_LDFLAGS"
1479 AC_MSG_RESULT($LIBGD)
1483 if test x$with_selinux = xno ; then
1486 # See if we have the SELinux library
1487 AC_CHECK_LIB(selinux, is_selinux_enabled,
1488 have_selinux=yes, have_selinux=no)
1489 if test x$with_selinux = xyes ; then
1490 if test x$have_selinux = xno ; then
1491 AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
1495 # Check if we're building with SELinux support.
1496 if test "x$have_selinux" = xyes; then
1497 AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
1499 # See if we have the libaudit library
1500 AC_CHECK_LIB(audit, audit_log_user_avc_message,
1501 have_libaudit=yes, have_libaudit=no)
1502 if test "x$have_libaudit" = xyes; then
1503 AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
1505 AC_SUBST(have_libaudit)
1507 # See if we have the libcap library
1508 AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
1509 if test "x$have_libcap" = xyes; then
1510 AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
1512 AC_SUBST(have_libcap)
1514 AC_SUBST(have_selinux)
1516 dnl Check if we support the requested _FORTIFY_SOURCE level
1517 dnl If not, then don't use it.
1518 dnl Note that _FORTIFY_SOURCE may have been set through FLAGS too.
1519 dnl _FORTIFY_SOURCE value will be selectively disabled for function that can't
1521 no_fortify_source="-Wp,-U_FORTIFY_SOURCE"
1522 fortify_source="${no_fortify_source}"
1524 AC_CACHE_CHECK([for maximum supported _FORTIFY_SOURCE level],
1525 [libc_cv_supported_fortify_source], [
1526 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_dynamic_object_size("", 0)])],
1527 [libc_cv_supported_fortify_source=3],
1528 [libc_cv_supported_fortify_source=2])
1531 AS_CASE([$enable_fortify_source],
1532 [yes], [libc_cv_fortify_source=yes enable_fortify_source=$libc_cv_supported_fortify_source],
1533 [1|2], [libc_cv_fortify_source=yes],
1534 [3], [AS_IF([test $libc_cv_supported_fortify_source = 3],
1535 [libc_cv_fortify_source=yes],
1536 [AC_MSG_ERROR([Compiler doesn't provide necessary support for _FORTIFY_SOURCE=3])])],
1537 [libc_cv_fortify_source=no])
1539 AS_IF([test "$libc_cv_fortify_source" = yes],
1540 [fortify_source="${fortify_source},-D_FORTIFY_SOURCE=${enable_fortify_source}"]
1543 AC_SUBST(enable_fortify_source)
1544 AC_SUBST(libc_cv_fortify_source)
1545 AC_SUBST(no_fortify_source)
1546 AC_SUBST(fortify_source)
1547 LIBC_CONFIG_VAR([supported-fortify], [$libc_cv_supported_fortify_source])
1549 dnl Starting with binutils 2.35, GAS can attach multiple symbol versions
1550 dnl to one symbol (PR 23840).
1551 AC_CACHE_CHECK(whether the assembler requires one version per symbol,
1552 libc_cv_symver_needs_alias, [dnl
1553 cat > conftest.s <<EOF
1557 .symver testfunc, testfunc1@VERSION1
1558 .symver testfunc, testfunc1@VERSION2
1560 libc_cv_symver_needs_alias=no
1561 if ${CC-cc} $ASFLAGS -c conftest.s 2>&AS_MESSAGE_LOG_FD; then
1562 libc_cv_symver_needs_alias=no
1564 libc_cv_symver_needs_alias=yes
1568 if test "$libc_cv_symver_needs_alias" = yes; then
1569 AC_DEFINE(SYMVER_NEEDS_ALIAS)
1572 AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
1573 libc_cv_builtin_trap, [dnl
1574 libc_cv_builtin_trap=no
1575 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[__builtin_trap ()]])],[
1576 libc_undefs=`$NM -u conftest.o |
1577 LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1578 2>&AS_MESSAGE_LOG_FD` || {
1579 AC_MSG_ERROR([confusing output from $NM -u])
1581 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1582 if test -z "$libc_undefs"; then
1583 libc_cv_builtin_trap=yes
1585 if test $libc_cv_builtin_trap = yes; then
1586 AC_DEFINE([HAVE_BUILTIN_TRAP])
1589 dnl C++ feature tests.
1592 AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
1593 libc_cv_cxx_thread_local, [
1594 old_CXXFLAGS="$CXXFLAGS"
1595 CXXFLAGS="$CXXFLAGS -std=gnu++11"
1596 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1599 // Compiler support.
1606 S * get () { return &s; }
1608 // libstdc++ support.
1609 #ifndef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
1610 #error __cxa_thread_atexit_impl not supported
1613 [libc_cv_cxx_thread_local=yes],
1614 [libc_cv_cxx_thread_local=no])
1615 CXXFLAGS="$old_CXXFLAGS"
1617 AC_SUBST(libc_cv_cxx_thread_local)
1620 dnl End of C++ feature tests.
1622 ### End of automated tests.
1623 ### Now run sysdeps configure fragments.
1625 # They also can set these variables.
1627 ldd_rewrite_script=no
1628 libc_cv_sysconfdir=$sysconfdir
1629 libc_cv_localstatedir=$localstatedir
1630 libc_cv_gcc_unwind_find_fde=no
1634 # Iterate over all the sysdep directories we will use, running their
1635 # configure fragments.
1636 for dir in $sysnames; do
1639 *) dest=$srcdir/$dir ;;
1641 if test -r $dest/configure; then
1642 AC_MSG_RESULT(running configure fragment for $dir)
1647 if test x"$build_mathvec" = xnotset; then
1650 LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
1652 AC_SUBST(libc_extra_cflags)
1653 AC_SUBST(libc_extra_cppflags)
1655 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
1656 AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
1658 AC_SUBST(libc_cv_gcc_unwind_find_fde)
1660 # A sysdeps configure fragment can reset this if IFUNC is not actually
1661 # usable even though the assembler knows how to generate the symbol type.
1662 if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
1663 AC_DEFINE(HAVE_IFUNC)
1665 LIBC_CONFIG_VAR([have-ifunc], [$libc_cv_ld_gnu_indirect_function])
1667 if test x"$libc_cv_gcc_indirect_function" = xyes; then
1668 AC_DEFINE(HAVE_GCC_IFUNC)
1670 LIBC_CONFIG_VAR([have-gcc-ifunc], [$libc_cv_gcc_indirect_function])
1672 # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
1673 # configure fragment can override the value to prevent this AC_DEFINE.
1675 if test "x$use_nscd" != xno; then
1676 AC_DEFINE([USE_NSCD])
1678 if test "x$build_nscd" = xdefault; then
1679 build_nscd=$use_nscd
1682 AC_SUBST(libc_cv_slibdir)
1683 AC_SUBST(libc_cv_rtlddir)
1684 AC_SUBST(libc_cv_complocaledir)
1685 AC_SUBST(libc_cv_sysconfdir)
1686 AC_SUBST(libc_cv_localstatedir)
1687 AC_SUBST(libc_cv_rootsbindir)
1689 if test x$use_ldconfig = xyes; then
1690 AC_DEFINE(USE_LDCONFIG)
1692 AC_SUBST(use_ldconfig)
1693 AC_SUBST(ldd_rewrite_script)
1698 AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
1699 [libc_cv_pic_default=yes
1700 cat > conftest.c <<EOF
1701 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
1702 # error PIC is default.
1705 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1706 libc_cv_pic_default=no
1709 LIBC_CONFIG_VAR([build-pic-default], [$libc_cv_pic_default])
1711 AC_CACHE_CHECK([whether -fPIE is default], libc_cv_cc_pie_default,
1712 [libc_cv_cc_pie_default=yes
1713 cat > conftest.c <<EOF
1714 #if defined __PIE__ || defined __pie__ || defined PIE || defined pie
1715 # error PIE is default.
1718 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1719 libc_cv_cc_pie_default=no
1722 LIBC_CONFIG_VAR([cc-pie-default], [$libc_cv_cc_pie_default])
1724 AC_MSG_CHECKING(if we can build programs as PIE)
1725 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifdef PIE_UNSUPPORTED
1726 # error PIE is not supported
1727 #endif]])], [libc_cv_pie_supported=yes], [libc_cv_pie_supported=no])
1728 AC_MSG_RESULT($libc_cv_pie_supported)
1729 # Disable build-pie-default if target does not support it or glibc is
1730 # configured with --disable-default-pie.
1731 if test "x$default_pie" = xno; then
1732 build_pie_default=no
1734 build_pie_default=$libc_cv_pie_supported
1736 LIBC_CONFIG_VAR([build-pie-default], [$build_pie_default])
1738 AC_MSG_CHECKING(if we can build static PIE programs)
1739 libc_cv_static_pie_supported=$libc_cv_pie_supported
1740 if test "x$libc_cv_pie_supported" != xno \
1741 -a "$libc_cv_no_dynamic_linker" = yes; then
1742 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef SUPPORT_STATIC_PIE
1743 # error static PIE is not supported
1744 #endif]])], [libc_cv_static_pie_supported=yes],
1745 [libc_cv_static_pie_supported=no])
1747 AC_MSG_RESULT($libc_cv_static_pie_supported)
1749 # Enable static-pie only if it is available and glibc isn't configured
1750 # with --disable-default-pie.
1751 if test "x$default_pie" = xno; then
1752 libc_cv_static_pie=no
1754 libc_cv_static_pie=$libc_cv_static_pie_supported
1756 if test "$libc_cv_static_pie" = "yes"; then
1757 AC_DEFINE(ENABLE_STATIC_PIE)
1759 LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
1761 # Set the `multidir' variable by grabbing the variable from the compiler.
1762 # We do it once and save the result in a generated makefile.
1763 libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
1764 AC_SUBST(libc_cv_multidir)
1767 AC_SUBST(static_nss)
1771 dnl See sysdeps/mach/configure.ac for this variable.
1772 AC_SUBST(mach_interface_list)
1774 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
1775 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
1779 if test "$pthread_in_libc" = yes; then
1780 AC_DEFINE(PTHREAD_IN_LIBC)
1782 AC_SUBST(pthread_in_libc)
1784 AC_CONFIG_FILES([config.make Makefile])
1785 AC_CONFIG_COMMANDS([default],[[
1786 case $CONFIG_FILES in *config.make*)
1787 echo "$config_vars" >> config.make;;
1789 test -d bits || mkdir bits]],[[config_vars='$config_vars']])