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([systemtap],
309 [AS_HELP_STRING([--enable-systemtap],
310 [enable systemtap static probe points @<:@default=no@:>@])],
311 [systemtap=$enableval],
313 if test "x$systemtap" != xno; then
314 AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
316 CFLAGS="-std=gnu11 $CFLAGS"
317 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
318 void foo (int i, void *p)
320 asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
321 :: STAP_PROBE_ASM_OPERANDS (2, i, p));
322 }]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
323 CFLAGS="$old_CFLAGS"])
324 if test $libc_cv_sdt = yes; then
325 AC_DEFINE([USE_STAP_PROBE])
326 elif test "x$systemtap" != xauto; then
327 AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
331 AC_ARG_ENABLE([build-nscd],
332 [AS_HELP_STRING([--disable-build-nscd],
333 [disable building and installing the nscd daemon])],
334 [build_nscd=$enableval],
335 [build_nscd=default])
338 # Note the use of $use_nscd is near the bottom of the file.
339 AC_ARG_ENABLE([nscd],
340 [AS_HELP_STRING([--disable-nscd],
341 [library functions will not contact the nscd daemon])],
342 [use_nscd=$enableval],
345 AC_ARG_ENABLE([pt_chown],
346 [AS_HELP_STRING([--enable-pt_chown],
347 [Enable building and installing pt_chown])],
348 [build_pt_chown=$enableval],
350 AC_SUBST(build_pt_chown)
351 if test "$build_pt_chown" = yes; then
352 AC_DEFINE(HAVE_PT_CHOWN)
355 # The abi-tags file uses a fairly simplistic model for name recognition that
356 # can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
357 # $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
358 # This doesn't get used much beyond that, so it's fairly safe.
363 host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
367 AC_ARG_ENABLE([mathvec],
368 [AS_HELP_STRING([--enable-mathvec],
369 [Enable building and installing mathvec @<:@default depends on architecture@:>@])],
370 [build_mathvec=$enableval],
371 [build_mathvec=notset])
373 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
375 # error no CET compiler support
377 [libc_cv_compiler_default_cet=yes],
378 [libc_cv_compiler_default_cet=no])
381 AS_HELP_STRING([--enable-cet],
382 [enable Intel Control-flow Enforcement Technology (CET), x86 only]),
383 [enable_cet=$enableval],
384 [enable_cet=$libc_cv_compiler_default_cet])
387 AS_HELP_STRING([--disable-scv],
388 [syscalls will not use scv instruction, even if the kernel supports it, powerpc only]),
389 [use_scv=$enableval],
392 AS_IF([[test "$use_scv" != "no"]],[AC_DEFINE(USE_PPC_SCV)])
394 dnl Build glibc with _FORTIFY_SOURCE
395 AC_ARG_ENABLE(fortify-source,
396 AS_HELP_STRING([--enable-fortify-source@<:@=1|2|3@:>@],
397 [Use -D_FORTIFY_SOURCE=[1|2|3] to control code hardening, defaults to highest possible value supported by the build compiler.]),
398 [enable_fortify_source=$enableval],
399 [enable_fortify_source=no])
400 case "$enable_fortify_source" in
402 *) AC_MSG_ERROR([Not a valid argument for --enable-fortify-source: "$enable_fortify_source"]);;
405 # We keep the original values in `$config_*' and never modify them, so we
406 # can write them unchanged into config.make. Everything else uses
407 # $machine, $vendor, and $os, and changes them whenever convenient.
408 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
410 # Don't allow vendor == "unknown"
411 test "$config_vendor" = unknown && config_vendor=
412 config_os="`echo $config_os | sed 's/^unknown-//'`"
414 # Some configurations imply other options.
417 # The configure fragment of a port can modify these to supplement
418 # or override the table in the case statement below. No fragment should
419 # ever change the config_* variables, however.
420 machine=$config_machine
421 vendor=$config_vendor
427 AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
430 yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
432 *) submachine="$withval" ;;
436 # An preconfigure script can set this when it wants to disable the sanity
440 # A preconfigure script for a system that may or may not use fpu
441 # sysdeps directories sets this to a preprocessor conditional for
442 # whether to use such directories.
445 # A preconfigure script may define another name to TLS descriptor variant
448 dnl Let sysdeps/*/preconfigure act here.
449 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
453 ### By using the undocumented --enable-hacker-mode option for configure
454 ### one can skip this test to make the configuration not fail for unsupported
457 if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
458 case "$machine-$host_os" in
463 *** The GNU C library is currently unavailable for this platform.
464 *** If you are interested in seeing glibc on this platform visit
465 *** the "How to submit a new port" in the wiki:
466 *** https://sourceware.org/glibc/wiki/#Development
467 *** and join the community!])
472 # Set base_machine if not set by a preconfigure fragment.
473 test -n "$base_machine" || base_machine=$machine
474 AC_SUBST(base_machine)
479 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
480 # The makefiles need to use a different form to find it in $srcdir.
481 INSTALL='\$(..)./scripts/install-sh -c'
487 # Accept binutils 2.25 or newer.
489 case $($LD --version) in
491 # Accept gold 1.14 or higher
492 AC_CHECK_PROG_VER(LD, $LD, --version,
493 [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
494 [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
495 LD=: critic_missing="$critic_missing GNU gold")
498 # Accept LLD 13.0.0 or higher
499 AC_CHECK_PROG_VER(LD, $LD, --version,
500 [LLD.* \([0-9][0-9]*\.[0-9.]*\)],
501 [1[3-9].*|[2-9][0-9].*],
502 LD=: critic_missing="$critic_missing LLD")
506 AC_CHECK_PROG_VER(LD, $LD, --version,
507 [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
508 [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
509 LD=: critic_missing="$critic_missing GNU ld")
512 LIBC_CONFIG_VAR([with-lld], [$libc_cv_with_lld])
514 # These programs are version sensitive.
515 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
516 [GNU Make[^0-9]*\([0-9][0-9.]*\)],
517 [[4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
519 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
520 [GNU gettext.* \([0-9]*\.[0-9.]*\)],
521 [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
522 MSGFMT=: aux_missing="$aux_missing msgfmt")
523 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
524 [GNU texinfo.* \([0-9][0-9.]*\)],
525 [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
526 MAKEINFO=: aux_missing="$aux_missing makeinfo")
527 AC_CHECK_PROG_VER(SED, sed, --version,
528 [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
529 [3.0[2-9]*|3.[1-9]*|[4-9]*],
530 SED=: aux_missing="$aux_missing sed")
531 AC_CHECK_PROG_VER(AWK, gawk, --version,
532 [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
533 [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
534 AC_CHECK_PROG_VER(BISON, bison, --version,
535 [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
536 [2.7*|[3-9].*|[1-9][0-9]*], critic_missing="$critic_missing bison")
538 AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
539 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
540 #if !defined __GNUC__ || __GNUC__ < 6 || (__GNUC__ == 6 && __GNUC_MINOR__ < 2)
541 #error insufficient compiler
543 [libc_cv_compiler_ok=yes],
544 [libc_cv_compiler_ok=no])])
545 AS_IF([test $libc_cv_compiler_ok != yes],
546 [critic_missing="$critic_missing compiler"])
548 if test "x$maintainer" = "xyes"; then
549 AC_CHECK_PROGS(AUTOCONF, autoconf, no)
551 xno|x|x:) AUTOCONF=no ;;
554 whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
555 if (cd $srcdir; $AUTOCONF $ACFLAGS configure.ac > /dev/null 2>&1); then
556 libc_cv_autoconf_works=yes
558 libc_cv_autoconf_works=no
560 test $libc_cv_autoconf_works = yes || AUTOCONF=no
563 if test "x$AUTOCONF" = xno; then
564 aux_missing="$aux_missing autoconf"
570 # Check for python3 if available, or else python.
571 AC_CHECK_PROG_VER(PYTHON_PROG, python3 python, --version,
572 [Python \([0-9][0-9.]*\)],
573 [3.[4-9]*|3.[1-9][0-9]*|[4-9].*|[1-9][0-9]*],
574 critic_missing="$critic_missing python")
575 PYTHON="$PYTHON_PROG -B"
578 test -n "$critic_missing" && AC_MSG_ERROR([
579 *** These critical programs are missing or too old:$critic_missing
580 *** Check the INSTALL file for required versions.])
582 test -n "$aux_missing" && AC_MSG_WARN([
583 *** These auxiliary programs are missing or incompatible versions:$aux_missing
584 *** some features or tests will be disabled.
585 *** Check the INSTALL file for required versions.])
588 # Determine whether to use fpu or nofpu sysdeps directories.
589 AC_CACHE_CHECK([for use of fpu sysdeps directories],
590 libc_cv_with_fp, [dnl
591 cat > conftest.c <<EOF
595 # error "no hardware floating point"
599 if ${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c -o conftest.s \
600 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
604 AC_SUBST(libc_cv_with_fp)
606 AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
607 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
612 AC_CACHE_CHECK(for -fstack-protector-strong, libc_cv_ssp_strong, [dnl
613 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-strong],
614 [libc_cv_ssp_strong=yes],
615 [libc_cv_ssp_strong=no])
618 AC_CACHE_CHECK(for -fstack-protector-all, libc_cv_ssp_all, [dnl
619 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-all],
620 [libc_cv_ssp_all=yes],
621 [libc_cv_ssp_all=no])
626 if test "$libc_cv_ssp" = yes; then
627 no_stack_protector="-fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0"
628 AC_DEFINE(HAVE_CC_NO_STACK_PROTECTOR)
631 if test "$enable_stack_protector" = yes && test "$libc_cv_ssp" = yes; then
632 stack_protector="-fstack-protector"
633 AC_DEFINE(STACK_PROTECTOR_LEVEL, 1)
634 elif test "$enable_stack_protector" = all && test "$libc_cv_ssp_all" = yes; then
635 stack_protector="-fstack-protector-all"
636 AC_DEFINE(STACK_PROTECTOR_LEVEL, 2)
637 elif test "$enable_stack_protector" = strong && test "$libc_cv_ssp_strong" = yes; then
638 stack_protector="-fstack-protector-strong"
639 AC_DEFINE(STACK_PROTECTOR_LEVEL, 3)
641 stack_protector="-fno-stack-protector"
642 AC_DEFINE(STACK_PROTECTOR_LEVEL, 0)
644 AC_SUBST(libc_cv_ssp)
645 AC_SUBST(stack_protector)
646 AC_SUBST(no_stack_protector)
648 if test -n "$stack_protector"; then
649 dnl Don't run configure tests with stack-protection on, to avoid problems with
651 no_ssp=-fno-stack-protector
655 if test "$enable_stack_protector" != no; then
656 AC_MSG_ERROR([--enable-stack-protector=$enable_stack_protector specified, but specified level of stack protection is not supported by the compiler.])
660 # For the multi-arch option we need support in the assembler & linker.
661 AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
662 libc_cv_ld_gnu_indirect_function, [dnl
663 cat > conftest.S <<EOF
664 .type foo,%gnu_indirect_function
677 libc_cv_ld_gnu_indirect_function=no
678 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
679 -nostartfiles -nostdlib $no_ssp \
680 -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
681 # Do a link to see if the backend supports IFUNC relocs.
682 $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
683 LC_ALL=C $READELF -Wr conftest | grep -q 'IRELATIVE\|R_SPARC_JMP_IREL' && {
684 libc_cv_ld_gnu_indirect_function=yes
689 # Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
690 AC_CACHE_CHECK([for gcc attribute ifunc support],
691 libc_cv_gcc_indirect_function, [dnl
692 cat > conftest.c <<EOF
693 extern int func (int);
694 int used_func (int a)
698 static void *resolver ()
702 extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
704 libc_cv_gcc_indirect_function=no
705 if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
706 2>&AS_MESSAGE_LOG_FD ; then
707 if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&AS_MESSAGE_LOG_FD; then
708 libc_cv_gcc_indirect_function=yes
713 # Check if linker supports textrel relocation with ifunc (used on elf/tests).
714 # Note that it relies on libc_cv_ld_gnu_indirect_function test above.
715 AC_CACHE_CHECK([whether the linker supports textrels along with ifunc],
716 libc_cv_textrel_ifunc, [dnl
717 cat > conftest.S <<EOF
718 .type foo,%gnu_indirect_function
739 libc_cv_textrel_ifunc=no
740 if test $libc_cv_ld_gnu_indirect_function = yes; then
741 if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib $no_ssp -pie -o conftest conftest.S); then
742 libc_cv_textrel_ifunc=yes
746 AC_SUBST(libc_cv_textrel_ifunc)
748 # Check if CC supports attribute retain as it is used in attribute_used_retain macro.
749 AC_CACHE_CHECK([for GNU attribute retain support],
750 libc_cv_gnu_retain, [dnl
751 cat > conftest.c <<EOF
752 static int var __attribute__ ((used, retain, section ("__libc_atexit")));
754 libc_cv_gnu_retain=no
755 if ${CC-cc} -Werror -c conftest.c -o /dev/null 1>&AS_MESSAGE_LOG_FD \
756 2>&AS_MESSAGE_LOG_FD ; then
757 libc_cv_gnu_retain=yes
760 if test $libc_cv_gnu_retain = yes; then
761 AC_DEFINE(HAVE_GNU_RETAIN)
763 LIBC_CONFIG_VAR([have-gnu-retain], [$libc_cv_gnu_retain])
765 # Check if gcc warns about alias for function with incompatible types.
766 AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
767 libc_cv_gcc_incompatible_alias, [dnl
768 cat > conftest.c <<EOF
769 int __redirect_foo (const void *s, int c);
771 __typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
772 __typeof (__redirect_foo) *foo_impl (void)
777 extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
779 libc_cv_gcc_incompatible_alias=yes
780 if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
781 libc_cv_gcc_incompatible_alias=no
785 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
786 if test x"$multi_arch" = xyes; then
787 AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
792 if test x"$libc_cv_gcc_indirect_function" != xyes; then
793 # GCC 8+ emits a warning for alias with incompatible types and it might
794 # fail to build ifunc resolvers aliases to either weak or internal
795 # symbols. Disables multiarch build in this case.
796 if test x"$libc_cv_gcc_incompatible_alias" = xyes; then
797 AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types])
798 if test x"$multi_arch" = xyes; then
799 AC_MSG_ERROR([--enable-multi-arch support requires a gcc with gnu-indirect-function support])
801 AC_MSG_WARN([Multi-arch is disabled.])
803 elif test x"$multi_arch" = xyes; then
804 AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
805 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
809 if test x"$multi_arch" != xno; then
810 multi_arch_d=/multiarch
813 # Compute the list of sysdep directories for this configuration.
814 # This can take a while to compute.
815 sysdep_dir=$srcdir/sysdeps
816 AC_MSG_CHECKING(sysdep dirs)
817 dnl We need to use [ and ] for other purposes for a while now.
819 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
820 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
822 test "x$base_os" != x || case "$os" in
829 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
832 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
836 o=`echo $tail | sed 's/[0-9]*$//'`
837 if test $o != $tail; then
840 # For linux-gnu, try linux-gnu, then linux.
841 o=`echo $tail | sed 's/-.*$//'`
842 if test $o != $tail; then
846 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
849 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
855 # For sparc/sparc32, try sparc/sparc32 and then sparc.
857 tail=$machine${submachine:+/$submachine}
858 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
860 # Prepend the machine's FPU directory unless the architecture specific
861 # preconfigure disables it.
862 if test "$libc_cv_with_fp" = yes; then
867 # For each machine term, try it with and then without /multiarch.
868 for try_fpu in $maybe_fpu ''; do
869 for try_multi in $multi_arch_d ''; do
870 mach="$mach /$1$try_fpu$try_multi"
876 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
879 # Find what sysdep directories exist.
881 for b in $base ''; do
882 for m0 in $mach ''; do
883 for v in /$vendor ''; do
884 test "$v" = / && continue
885 for o in /$ostry ''; do
886 test "$o" = / && continue
887 for m in $mach ''; do
888 try_suffix="$m0$b$v$o$m"
889 if test -n "$try_suffix"; then
890 try_srcdir="${srcdir}/"
891 try="sysdeps$try_suffix"
892 test -n "$enable_debug_configure" &&
893 echo "$0 [DEBUG]: try $try" >&2
894 if test -d "$try_srcdir$try"; then
895 sysnames="$sysnames $try"
896 { test -n "$o" || test -n "$b"; } && os_used=t
897 { test -n "$m" || test -n "$m0"; } && machine_used=t
899 x*/$submachine) submachine_used=t ;;
909 # If the assembler supports gnu_indirect_function symbol type and the
910 # architecture supports multi-arch, we enable multi-arch by default.
915 test x"$multi_arch" = xdefault && multi_arch=no
918 if test x"$multi_arch" != xno; then
919 AC_DEFINE(USE_MULTIARCH)
923 if test -z "$os_used" && test "$os" != none; then
924 AC_MSG_ERROR(Operating system $os is not supported.)
926 if test -z "$machine_used" && test "$machine" != none; then
927 AC_MSG_ERROR(The $machine is not supported.)
929 if test -z "$submachine_used" && test -n "$submachine"; then
930 AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
934 # We have now validated the configuration.
936 # Expand the list of system names into a full list of directories
937 # from each element's parent name and Implies file (if present).
940 while test $# -gt 0; do
944 case " $names " in *" $name "*)
945 # Already in the list.
949 # Report each name as we discover it, so there is no long pause in output.
950 echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
952 name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
956 *) xsrcdir=$srcdir/ ;;
958 test -n "$enable_debug_configure" &&
959 echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
961 for implies_file in Implies Implies-before Implies-after; do
962 implies_type=`echo $implies_file | sed s/-/_/`
963 eval ${implies_type}=
964 if test -f $xsrcdir$name/$implies_file; then
965 # Collect more names from the `Implies' file (removing comments).
966 implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/$implies_file`"
967 for x in $implied_candidate; do
969 if test -d $xsrcdir$name_base/$x; then
970 eval "${implies_type}=\"\$${implies_type} \$name_base/\$x\""
975 test -n "$enable_debug_configure" &&
976 echo "[DEBUG]: $name $implies_file $x try() {$try_srcdir}$try" >&2
977 if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
979 eval "${implies_type}=\"\$${implies_type} \$try\""
982 if test $found = no; then
983 AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
989 # Add NAME to the list of names.
992 # Find the parent of NAME, using the empty string if it has none.
994 parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
997 test -n "$enable_debug_configure" &&
998 echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
999 Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
1001 # Add the names implied by NAME, and NAME's parent (if it has one), to
1002 # the list of names to be processed (the argument list). We prepend the
1003 # implied names to the list and append the parent. We want implied
1004 # directories to come before further directories inferred from the
1005 # configuration components; this ensures that for sysv4, unix/common
1006 # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
1008 sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
1009 test -n "$sysnames" && set $sysnames
1012 # Add the default directories.
1013 default_sysnames="sysdeps/generic"
1014 sysnames="$names $default_sysnames"
1016 # The other names were emitted during the scan.
1017 AC_MSG_RESULT($default_sysnames)
1019 # if using special system headers, find out the compiler's sekrit
1020 # header directory and add that to the list. NOTE: Only does the right
1021 # thing on a system that doesn't need fixincludes. (Not presently a problem.)
1022 if test -n "$sysheaders"; then
1023 SYSINCLUDES=-nostdinc
1024 for d in include include-fixed; do
1025 i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
1026 SYSINCLUDES="$SYSINCLUDES -isystem $i"
1028 SYSINCLUDES="$SYSINCLUDES \
1029 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
1030 if test -n "$CXX"; then
1032 for cxxheaders in `$CXX -v -S -x c++ /dev/null -o /dev/null 2>&1 \
1033 | sed -n -e '1,/#include/d' -e 's/^ \(\/.*\/[cg]++\)/\1/p'`; do
1034 test "x$cxxheaders" != x &&
1035 CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders"
1039 AC_SUBST(SYSINCLUDES)
1040 AC_SUBST(CXX_SYSINCLUDES)
1042 # Obtain some C++ header file paths. This is used to make a local
1043 # copy of those headers in Makerules.
1044 if test -n "$CXX"; then
1045 find_cxx_header () {
1046 echo "#include <$1>" | $CXX -H -fsyntax-only -x c++ - 2>&1 \
1047 | $AWK '$1 == "."{print $2}'
1049 CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
1050 CXX_CMATH_HEADER="$(find_cxx_header cmath)"
1051 CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
1053 AC_SUBST(CXX_CSTDLIB_HEADER)
1054 AC_SUBST(CXX_CMATH_HEADER)
1055 AC_SUBST(CXX_BITS_STD_ABS_H)
1057 # Test if LD_LIBRARY_PATH contains the notation for the current directory
1058 # since this would lead to problems installing/building glibc.
1059 # LD_LIBRARY_PATH contains the current directory if one of the following
1061 # - one of the terminals (":" and ";") is the first or last sign
1062 # - two terminals occur directly after each other
1063 # - the path contains an element with a dot in it
1064 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
1066 case ${LD_LIBRARY_PATH} in
1067 [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
1068 ld_library_path_setting="contains current directory"
1071 ld_library_path_setting="ok"
1075 AC_MSG_RESULT($ld_library_path_setting)
1076 if test "$ld_library_path_setting" != "ok"; then
1078 *** LD_LIBRARY_PATH shouldn't contain the current directory when
1079 *** building glibc. Please change the environment variable
1080 *** and run configure again.])
1083 AC_PATH_PROG(BASH_SHELL, bash, no)
1085 AC_PATH_PROG(PERL, perl, no)
1086 if test "$PERL" != no &&
1087 (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1090 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1091 $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1093 AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
1094 cat > conftest.s <<EOF
1097 .set glibc_conftest_frobozz,foo
1098 .globl glibc_conftest_frobozz
1100 # The alpha-dec-osf1 assembler gives only a warning for `.set'
1101 # (but it doesn't work), so we must do a linking check to be sure.
1102 cat > conftest1.c <<\EOF
1103 extern int glibc_conftest_frobozz;
1104 void _start() { glibc_conftest_frobozz = 1; }
1106 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1107 -nostartfiles -nostdlib $no_ssp \
1108 -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1109 libc_cv_asm_set_directive=yes
1111 libc_cv_asm_set_directive=no
1114 if test $libc_cv_asm_set_directive = yes; then
1115 AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1118 AC_CACHE_CHECK(linker support for protected data symbol,
1119 libc_cv_protected_data,
1120 [cat > conftest.c <<EOF
1121 int bar __attribute__ ((visibility ("protected"))) = 1;
1123 libc_cv_protected_data=no
1124 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -o conftest.so); then
1125 cat > conftest.c <<EOF
1127 int main (void) { return bar; }
1129 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp conftest.c -o conftest conftest.so); then
1130 libc_cv_protected_data=yes
1135 AC_SUBST(libc_cv_protected_data)
1137 AC_CACHE_CHECK(linker support for INSERT in linker script,
1139 [cat > conftest.c <<EOF
1140 int __attribute__ ((section(".bar"))) bar = 0x12345678;
1141 int test (void) { return bar; }
1143 cat > conftest.t <<EOF
1148 INSERT AFTER .rela.dyn;
1151 if AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -Wl,-T,conftest.t -o conftest.so]); then
1156 AC_SUBST(libc_cv_insert)
1158 AC_CACHE_CHECK(for broken __attribute__((alias())),
1159 libc_cv_broken_alias_attribute,
1160 [cat > conftest.c <<EOF
1161 extern int foo (int x) __asm ("xyzzy");
1162 int bar (int x) { return x; }
1163 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1165 extern __typeof (dfoo) dfoo __asm ("abccb");
1168 libc_cv_broken_alias_attribute=yes
1169 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1170 if grep 'xyzzy' conftest.s >/dev/null &&
1171 grep 'abccb' conftest.s >/dev/null; then
1172 libc_cv_broken_alias_attribute=no
1175 rm -f conftest.c conftest.s
1177 if test $libc_cv_broken_alias_attribute = yes; then
1178 AC_MSG_ERROR(working alias attribute support required)
1181 AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
1182 libc_cv_have_sdata_section,
1183 [echo "int i;" > conftest.c
1184 libc_cv_have_sdata_section=no
1185 if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
1186 | grep '\.sdata' >/dev/null; then
1187 libc_cv_have_sdata_section=yes
1189 rm -f conftest.c conftest.so
1191 if test $libc_cv_have_sdata_section = yes; then
1192 AC_DEFINE(HAVE_SDATA_SECTION)
1195 AC_CACHE_CHECK(for libunwind-support in compiler,
1196 libc_cv_cc_with_libunwind, [
1197 cat > conftest.c <<EOF
1198 int main (void) { return 0; }
1200 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
1201 conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
1202 libc_cv_cc_with_libunwind=yes
1204 libc_cv_cc_with_libunwind=no
1207 AC_SUBST(libc_cv_cc_with_libunwind)
1208 if test $libc_cv_cc_with_libunwind = yes; then
1209 AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
1213 AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1214 libc_cv_as_noexecstack, [dnl
1215 cat > conftest.c <<EOF
1218 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1219 -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1220 && grep .note.GNU-stack conftest.s >/dev/null \
1221 && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1222 -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1224 libc_cv_as_noexecstack=yes
1226 libc_cv_as_noexecstack=no
1229 if test $libc_cv_as_noexecstack = yes; then
1230 ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1232 AC_SUBST(ASFLAGS_config)
1234 LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
1235 [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
1236 AC_SUBST(libc_cv_z_execstack)
1238 LIBC_LINKER_FEATURE([-z start-stop-gc], [-Wl,-z,start-stop-gc],
1239 [libc_cv_z_start_stop_gc=yes], [libc_cv_z_start_stop_gc=no])
1240 LIBC_CONFIG_VAR([have-z-start-stop-gc], [$libc_cv_z_start_stop_gc])
1242 LIBC_LINKER_FEATURE([--depaudit], [-Wl,--depaudit,x],
1243 [libc_cv_depaudit=yes], [libc_cv_depaudit=no])
1244 LIBC_CONFIG_VAR([have-depaudit], [$libc_cv_depaudit])
1246 LIBC_LINKER_FEATURE([-z pack-relative-relocs],
1247 [-Wl,-z,pack-relative-relocs],
1248 [libc_cv_dt_relr=yes], [libc_cv_dt_relr=no])
1249 LIBC_CONFIG_VAR([have-dt-relr], [$libc_cv_dt_relr])
1251 LIBC_LINKER_FEATURE([--no-dynamic-linker],
1252 [-Wl,--no-dynamic-linker],
1253 [libc_cv_no_dynamic_linker=yes],
1254 [libc_cv_no_dynamic_linker=no])
1255 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
1257 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
1258 LIBC_TRY_CC_OPTION([-static-pie],
1259 [libc_cv_static_pie=yes],
1260 [libc_cv_static_pie=no])
1262 LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie])
1264 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1265 LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
1268 AC_SUBST(libc_cv_fpie)
1270 AC_CACHE_CHECK(for GLOB_DAT reloc,
1271 libc_cv_has_glob_dat, [dnl
1272 cat > conftest.c <<EOF
1274 int foo (void) { return mumble; }
1276 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1277 -fPIC -shared -o conftest.so conftest.c
1278 -nostdlib -nostartfiles $no_ssp
1279 1>&AS_MESSAGE_LOG_FD])
1281 dnl look for GLOB_DAT relocation.
1282 if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
1283 libc_cv_has_glob_dat=yes
1285 libc_cv_has_glob_dat=no
1288 libc_cv_has_glob_dat=no
1291 AC_SUBST(libc_cv_has_glob_dat)
1293 AC_CACHE_CHECK([for tls descriptor support], libc_cv_mtls_descriptor,
1295 cat > conftest.c <<EOF
1302 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -fPIC -mtls-dialect=$mtls_descriptor -nostdlib -nostartfiles
1303 -shared conftest.c -o conftest 1>&AS_MESSAGE_LOG_FD])
1305 libc_cv_mtls_descriptor=$mtls_descriptor
1307 libc_cv_mtls_descriptor=no
1310 AC_SUBST(libc_cv_mtls_descriptor)
1311 LIBC_CONFIG_VAR([have-mtls-descriptor], [$libc_cv_mtls_descriptor])
1313 dnl clang emits an warning for a double alias redirection, to warn the
1314 dnl original symbol is sed even when weak definition overrides it.
1315 dnl It is a usual pattern for weak_alias, where multiple alias point to
1317 AC_CACHE_CHECK([if -Wno-ignored-attributes is required for aliases],
1318 libc_cv_wno_ignored_attributes, [dnl
1319 cat > conftest.c <<EOF
1323 extern __typeof (__foo) foo __attribute__ ((weak, alias ("__foo")));
1324 extern __typeof (__foo) bar __attribute__ ((weak, alias ("foo")));
1326 libc_cv_wno_ignored_attributes=""
1327 if ! AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
1329 libc_cv_wno_ignored_attributes="-Wno-ignored-attributes"
1332 LIBC_CONFIG_VAR([config-cflags-wno-ignored-attributes],
1333 [$libc_cv_wno_ignored_attributes])
1335 AC_CACHE_CHECK(whether cc puts quotes around section names,
1336 libc_cv_have_section_quotes,
1337 [cat > conftest.c <<EOF
1338 static const int foo
1339 __attribute__ ((section ("bar"))) = 1;
1341 if ${CC-cc} -S conftest.c -o conftest.s; then
1342 if grep '\.section.*"bar"' conftest.s >/dev/null; then
1343 libc_cv_have_section_quotes=yes
1345 libc_cv_have_section_quotes=no
1348 libc_cv_have_section_quotes=unknown
1350 rm -f conftest.{c,s}
1352 if test $libc_cv_have_section_quotes = yes; then
1353 AC_DEFINE(HAVE_SECTION_QUOTES)
1356 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1357 cat > conftest.c <<\EOF
1360 __builtin_memset (x, 0, 1000);
1364 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "memset" > /dev/null]);
1366 libc_cv_gcc_builtin_memset=no
1368 libc_cv_gcc_builtin_memset=yes
1371 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1372 AC_DEFINE(HAVE_BUILTIN_MEMSET)
1375 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1376 cat > conftest.c <<\EOF
1377 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1378 char *foo (const char *a, const char *b)
1380 return __builtin_strstr (a, b);
1384 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null]);
1386 libc_cv_gcc_builtin_redirection=yes
1388 libc_cv_gcc_builtin_redirection=no
1391 if test "$libc_cv_gcc_builtin_redirection" = no; then
1392 AC_MSG_ERROR([support for the symbol redirection needed])
1395 dnl Determine how to disable generation of FMA instructions.
1396 AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1397 libc_cv_cc_nofma, [dnl
1399 for opt in -ffp-contract=off -mno-fused-madd; do
1400 LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1402 AC_SUBST(libc_cv_cc_nofma)
1404 if test -n "$submachine"; then
1405 AC_CACHE_CHECK([for compiler option for CPU variant],
1406 libc_cv_cc_submachine, [dnl
1407 libc_cv_cc_submachine=no
1408 for opt in "-march=$submachine" "-mcpu=$submachine"; do
1409 LIBC_TRY_CC_OPTION([$opt], [
1410 libc_cv_cc_submachine="$opt"
1413 if test "x$libc_cv_cc_submachine" = xno; then
1414 AC_MSG_ERROR([${CC-cc} does not support $submachine])
1417 AC_SUBST(libc_cv_cc_submachine)
1419 dnl Determine if compiler supports -fsignaling-nans
1420 AC_CACHE_CHECK([for compiler option that -fsignaling-nans],
1421 libc_cv_cc_signaling_nans, [dnl
1422 LIBC_TRY_CC_OPTION([-Werror -fsignaling-nans],
1423 [libc_cv_cc_signaling_nans=-fsignaling-nans],
1424 [libc_cv_cc_signaling_nans=])
1426 LIBC_CONFIG_VAR([config-cflags-signaling-nans],
1427 [$libc_cv_cc_signaling_nans])
1429 AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
1430 __attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
1431 cat > conftest.c <<EOF
1433 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
1436 libc_cv_cc_loop_to_function=no
1437 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c])
1439 libc_cv_cc_loop_to_function=yes
1442 if test $libc_cv_cc_loop_to_function = yes; then
1443 AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
1445 AC_SUBST(libc_cv_cc_loop_to_function)
1447 dnl Check whether we have the gd library available.
1448 AC_MSG_CHECKING(for libgd)
1449 if test "$with_gd" != "no"; then
1450 old_CFLAGS="$CFLAGS"
1451 CFLAGS="$CFLAGS $libgd_include"
1452 old_LDFLAGS="$LDFLAGS"
1453 LDFLAGS="$LDFLAGS $libgd_ldflags"
1455 LIBS="$LIBS -lgd -lpng -lz -lm"
1456 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gd.h>]], [[gdImagePng (0, 0)]])],
1457 [LIBGD=yes], [LIBGD=no])
1458 CFLAGS="$old_CFLAGS"
1459 LDFLAGS="$old_LDFLAGS"
1464 AC_MSG_RESULT($LIBGD)
1468 if test x$with_selinux = xno ; then
1471 # See if we have the SELinux library
1472 AC_CHECK_LIB(selinux, is_selinux_enabled,
1473 have_selinux=yes, have_selinux=no)
1474 if test x$with_selinux = xyes ; then
1475 if test x$have_selinux = xno ; then
1476 AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
1480 # Check if we're building with SELinux support.
1481 if test "x$have_selinux" = xyes; then
1482 AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
1484 # See if we have the libaudit library
1485 AC_CHECK_LIB(audit, audit_log_user_avc_message,
1486 have_libaudit=yes, have_libaudit=no)
1487 if test "x$have_libaudit" = xyes; then
1488 AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
1490 AC_SUBST(have_libaudit)
1492 # See if we have the libcap library
1493 AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
1494 if test "x$have_libcap" = xyes; then
1495 AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
1497 AC_SUBST(have_libcap)
1499 AC_SUBST(have_selinux)
1501 dnl Check if we support the requested _FORTIFY_SOURCE level
1502 dnl If not, then don't use it.
1503 dnl Note that _FORTIFY_SOURCE may have been set through FLAGS too.
1504 dnl _FORTIFY_SOURCE value will be selectively disabled for function that can't
1506 no_fortify_source="-Wp,-U_FORTIFY_SOURCE"
1507 fortify_source="${no_fortify_source}"
1509 AC_CACHE_CHECK([for maximum supported _FORTIFY_SOURCE level],
1510 [libc_cv_supported_fortify_source], [
1511 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_dynamic_object_size("", 0)])],
1512 [libc_cv_supported_fortify_source=3],
1513 [libc_cv_supported_fortify_source=2])
1516 AS_CASE([$enable_fortify_source],
1517 [yes], [libc_cv_fortify_source=yes enable_fortify_source=$libc_cv_supported_fortify_source],
1518 [1|2], [libc_cv_fortify_source=yes],
1519 [3], [AS_IF([test $libc_cv_supported_fortify_source = 3],
1520 [libc_cv_fortify_source=yes],
1521 [AC_MSG_ERROR([Compiler doesn't provide necessary support for _FORTIFY_SOURCE=3])])],
1522 [libc_cv_fortify_source=no])
1524 AS_IF([test "$libc_cv_fortify_source" = yes],
1525 [fortify_source="${fortify_source},-D_FORTIFY_SOURCE=${enable_fortify_source}"]
1528 AC_SUBST(enable_fortify_source)
1529 AC_SUBST(libc_cv_fortify_source)
1530 AC_SUBST(no_fortify_source)
1531 AC_SUBST(fortify_source)
1532 LIBC_CONFIG_VAR([supported-fortify], [$libc_cv_supported_fortify_source])
1534 dnl Starting with binutils 2.35, GAS can attach multiple symbol versions
1535 dnl to one symbol (PR 23840).
1536 AC_CACHE_CHECK(whether the assembler requires one version per symbol,
1537 libc_cv_symver_needs_alias, [dnl
1538 cat > conftest.s <<EOF
1542 .symver testfunc, testfunc1@VERSION1
1543 .symver testfunc, testfunc1@VERSION2
1545 libc_cv_symver_needs_alias=no
1546 if ${CC-cc} $ASFLAGS -c conftest.s 2>&AS_MESSAGE_LOG_FD; then
1547 libc_cv_symver_needs_alias=no
1549 libc_cv_symver_needs_alias=yes
1553 if test "$libc_cv_symver_needs_alias" = yes; then
1554 AC_DEFINE(SYMVER_NEEDS_ALIAS)
1557 AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
1558 libc_cv_builtin_trap, [dnl
1559 libc_cv_builtin_trap=no
1560 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[__builtin_trap ()]])],[
1561 libc_undefs=`$NM -u conftest.o |
1562 LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1563 2>&AS_MESSAGE_LOG_FD` || {
1564 AC_MSG_ERROR([confusing output from $NM -u])
1566 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1567 if test -z "$libc_undefs"; then
1568 libc_cv_builtin_trap=yes
1570 if test $libc_cv_builtin_trap = yes; then
1571 AC_DEFINE([HAVE_BUILTIN_TRAP])
1574 dnl C++ feature tests.
1577 AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
1578 libc_cv_cxx_thread_local, [
1579 old_CXXFLAGS="$CXXFLAGS"
1580 CXXFLAGS="$CXXFLAGS -std=gnu++11"
1581 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1584 // Compiler support.
1591 S * get () { return &s; }
1593 // libstdc++ support.
1594 #ifndef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
1595 #error __cxa_thread_atexit_impl not supported
1598 [libc_cv_cxx_thread_local=yes],
1599 [libc_cv_cxx_thread_local=no])
1600 CXXFLAGS="$old_CXXFLAGS"
1602 AC_SUBST(libc_cv_cxx_thread_local)
1605 dnl End of C++ feature tests.
1607 ### End of automated tests.
1608 ### Now run sysdeps configure fragments.
1610 # They also can set these variables.
1612 ldd_rewrite_script=no
1613 libc_cv_sysconfdir=$sysconfdir
1614 libc_cv_localstatedir=$localstatedir
1615 libc_cv_gcc_unwind_find_fde=no
1619 # Iterate over all the sysdep directories we will use, running their
1620 # configure fragments.
1621 for dir in $sysnames; do
1624 *) dest=$srcdir/$dir ;;
1626 if test -r $dest/configure; then
1627 AC_MSG_RESULT(running configure fragment for $dir)
1632 if test x"$build_mathvec" = xnotset; then
1635 LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
1637 AC_SUBST(libc_extra_cflags)
1638 AC_SUBST(libc_extra_cppflags)
1640 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
1641 AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
1643 AC_SUBST(libc_cv_gcc_unwind_find_fde)
1645 # A sysdeps configure fragment can reset this if IFUNC is not actually
1646 # usable even though the assembler knows how to generate the symbol type.
1647 if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
1648 AC_DEFINE(HAVE_IFUNC)
1650 LIBC_CONFIG_VAR([have-ifunc], [$libc_cv_ld_gnu_indirect_function])
1652 if test x"$libc_cv_gcc_indirect_function" = xyes; then
1653 AC_DEFINE(HAVE_GCC_IFUNC)
1655 LIBC_CONFIG_VAR([have-gcc-ifunc], [$libc_cv_gcc_indirect_function])
1657 # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
1658 # configure fragment can override the value to prevent this AC_DEFINE.
1660 if test "x$use_nscd" != xno; then
1661 AC_DEFINE([USE_NSCD])
1663 if test "x$build_nscd" = xdefault; then
1664 build_nscd=$use_nscd
1667 AC_SUBST(libc_cv_slibdir)
1668 AC_SUBST(libc_cv_rtlddir)
1669 AC_SUBST(libc_cv_complocaledir)
1670 AC_SUBST(libc_cv_sysconfdir)
1671 AC_SUBST(libc_cv_localstatedir)
1672 AC_SUBST(libc_cv_rootsbindir)
1674 if test x$use_ldconfig = xyes; then
1675 AC_DEFINE(USE_LDCONFIG)
1677 AC_SUBST(use_ldconfig)
1678 AC_SUBST(ldd_rewrite_script)
1683 AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
1684 [libc_cv_pic_default=yes
1685 cat > conftest.c <<EOF
1686 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
1687 # error PIC is default.
1690 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1691 libc_cv_pic_default=no
1694 LIBC_CONFIG_VAR([build-pic-default], [$libc_cv_pic_default])
1696 AC_CACHE_CHECK([whether -fPIE is default], libc_cv_cc_pie_default,
1697 [libc_cv_cc_pie_default=yes
1698 cat > conftest.c <<EOF
1699 #if defined __PIE__ || defined __pie__ || defined PIE || defined pie
1700 # error PIE is default.
1703 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1704 libc_cv_cc_pie_default=no
1707 LIBC_CONFIG_VAR([cc-pie-default], [$libc_cv_cc_pie_default])
1709 AC_MSG_CHECKING(if we can build programs as PIE)
1710 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifdef PIE_UNSUPPORTED
1711 # error PIE is not supported
1712 #endif]])], [libc_cv_pie_supported=yes], [libc_cv_pie_supported=no])
1713 AC_MSG_RESULT($libc_cv_pie_supported)
1714 # Disable build-pie-default if target does not support it or glibc is
1715 # configured with --disable-default-pie.
1716 if test "x$default_pie" = xno; then
1717 build_pie_default=no
1719 build_pie_default=$libc_cv_pie_supported
1721 LIBC_CONFIG_VAR([build-pie-default], [$build_pie_default])
1723 AC_MSG_CHECKING(if we can build static PIE programs)
1724 libc_cv_static_pie_supported=$libc_cv_pie_supported
1725 if test "x$libc_cv_pie_supported" != xno \
1726 -a "$libc_cv_no_dynamic_linker" = yes; then
1727 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef SUPPORT_STATIC_PIE
1728 # error static PIE is not supported
1729 #endif]])], [libc_cv_static_pie_supported=yes],
1730 [libc_cv_static_pie_supported=no])
1732 AC_MSG_RESULT($libc_cv_static_pie_supported)
1734 # Enable static-pie only if it is available and glibc isn't configured
1735 # with --disable-default-pie.
1736 if test "x$default_pie" = xno; then
1737 libc_cv_static_pie=no
1739 libc_cv_static_pie=$libc_cv_static_pie_supported
1741 if test "$libc_cv_static_pie" = "yes"; then
1742 AC_DEFINE(ENABLE_STATIC_PIE)
1744 LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
1746 # Set the `multidir' variable by grabbing the variable from the compiler.
1747 # We do it once and save the result in a generated makefile.
1748 libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
1749 AC_SUBST(libc_cv_multidir)
1752 AC_SUBST(static_nss)
1756 dnl See sysdeps/mach/configure.ac for this variable.
1757 AC_SUBST(mach_interface_list)
1759 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
1760 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
1764 if test "$pthread_in_libc" = yes; then
1765 AC_DEFINE(PTHREAD_IN_LIBC)
1767 AC_SUBST(pthread_in_libc)
1769 AC_CONFIG_FILES([config.make Makefile])
1770 AC_CONFIG_COMMANDS([default],[[
1771 case $CONFIG_FILES in *config.make*)
1772 echo "$config_vars" >> config.make;;
1774 test -d bits || mkdir bits]],[[config_vars='$config_vars']])