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)
54 AC_CHECK_TOOL(READELF, readelf, false)
56 # We need the C++ compiler only for testing.
58 # It's useless to us if it can't link programs (e.g. missing -lstdc++).
59 AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl
61 # Default, dynamic case.
62 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
63 [libc_cv_cxx_link_ok=yes],
64 [libc_cv_cxx_link_ok=no])
66 old_LDFLAGS="$LDFLAGS"
67 LDFLAGS="$LDFLAGS -static"
68 AC_LINK_IFELSE([AC_LANG_SOURCE([
74 std::cout << "Hello, world!";
79 [libc_cv_cxx_link_ok=no])
80 LDFLAGS="$old_LDFLAGS"
82 AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
84 if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
85 AC_MSG_ERROR([you must configure in a separate build directory])
88 # This will get text that should go into config.make.
91 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
93 AS_HELP_STRING([--with-gd=DIR],
94 [find libgd include dir and library with prefix DIR]),
98 *) libgd_include="-I$withval/include"
99 libgd_ldflags="-L$withval/lib" ;;
102 AC_ARG_WITH([gd-include],
103 AS_HELP_STRING([--with-gd-include=DIR],
104 [find libgd include files in DIR]),
106 case "$with_gd_include" in
108 *) libgd_include="-I$withval" ;;
111 AC_ARG_WITH([gd-lib],
112 AS_HELP_STRING([--with-gd-lib=DIR],
113 [find libgd library files in DIR]),
115 case "$with_gd_lib" in
117 *) libgd_ldflags="-L$withval" ;;
121 if test -n "$libgd_include"; then
122 config_vars="$config_vars
123 CFLAGS-memusagestat.c = $libgd_include"
125 if test -n "$libgd_ldflags"; then
126 config_vars="$config_vars
127 libgd-LDFLAGS = $libgd_ldflags"
130 dnl Arguments to specify presence of other packages/features.
131 AC_ARG_WITH([binutils],
132 AS_HELP_STRING([--with-binutils=PATH],
133 [specify location of binutils (as and ld)]),
134 [path_binutils=$withval],
136 AC_ARG_WITH([selinux],
137 AS_HELP_STRING([--with-selinux],
138 [if building with SELinux support]),
139 [with_selinux=$withval],
142 AC_ARG_WITH([headers],
143 AS_HELP_STRING([--with-headers=PATH],
144 [location of system headers to use
145 (for example /usr/src/linux/include)
146 @<:@default=compiler default@:>@]),
147 [sysheaders=$withval],
151 AC_SUBST(use_default_link)
152 AC_ARG_WITH([default-link],
153 AS_HELP_STRING([--with-default-link],
154 [do not use explicit linker scripts]),
155 [use_default_link=$withval],
156 [use_default_link=no])
158 dnl Additional build flags injection.
159 AC_ARG_WITH([nonshared-cflags],
160 AS_HELP_STRING([--with-nonshared-cflags=CFLAGS],
161 [build nonshared libraries with additional CFLAGS]),
162 [extra_nonshared_cflags=$withval],
163 [extra_nonshared_cflags=])
164 AC_SUBST(extra_nonshared_cflags)
165 AC_ARG_WITH([rtld-early-cflags],
166 AS_HELP_STRING([--with-rtld-early-cflags=CFLAGS],
167 [build early initialization with additional CFLAGS]),
168 [rtld_early_cflags=$withval],
169 [rtld_early_cflags=])
170 AC_SUBST(rtld_early_cflags)
172 AC_ARG_WITH([extra-version-id],
173 AS_HELP_STRING([--extra-version-id=STRING],
174 [specify an extra version string to use in internal ABI checks]),
175 [extra_version_id="$withval"])
177 AC_ARG_WITH([timeoutfactor],
178 AS_HELP_STRING([--with-timeoutfactor=NUM],
179 [specify an integer to scale the timeout]),
180 [timeoutfactor=$withval],
182 AC_DEFINE_UNQUOTED(TIMEOUTFACTOR, $timeoutfactor)
184 AC_ARG_ENABLE([sanity-checks],
185 AS_HELP_STRING([--disable-sanity-checks],
186 [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
187 [enable_sanity=$enableval],
190 AC_ARG_ENABLE([shared],
191 AS_HELP_STRING([--enable-shared],
192 [build shared library @<:@default=yes if GNU ld@:>@]),
195 AC_ARG_ENABLE([profile],
196 AS_HELP_STRING([--enable-profile],
197 [build profiled library @<:@default=no@:>@]),
198 [profile=$enableval],
200 AC_ARG_ENABLE([default-pie],
201 AS_HELP_STRING([--disable-default-pie],
202 [Do not build glibc programs and the testsuite as PIE @<:@default=no@:>@]),
203 [default_pie=$enableval],
205 AC_ARG_ENABLE([timezone-tools],
206 AS_HELP_STRING([--disable-timezone-tools],
207 [do not install timezone tools @<:@default=install@:>@]),
208 [enable_timezone_tools=$enableval],
209 [enable_timezone_tools=yes])
210 AC_SUBST(enable_timezone_tools)
212 AC_ARG_ENABLE([hardcoded-path-in-tests],
213 AS_HELP_STRING([--enable-hardcoded-path-in-tests],
214 [hardcode newly built glibc path in tests @<:@default=no@:>@]),
215 [hardcoded_path_in_tests=$enableval],
216 [hardcoded_path_in_tests=no])
217 AC_SUBST(hardcoded_path_in_tests)
219 AC_ARG_ENABLE([hidden-plt],
220 AS_HELP_STRING([--disable-hidden-plt],
221 [do not hide internal function calls to avoid PLT]),
224 if test "x$hidden" = xno; then
228 AC_ARG_ENABLE([bind-now],
229 AS_HELP_STRING([--enable-bind-now],
230 [disable lazy relocations in DSOs]),
231 [bindnow=$enableval],
234 if test "x$bindnow" = xyes; then
238 dnl Build glibc with -fstack-protector, -fstack-protector-all, or
239 dnl -fstack-protector-strong.
240 AC_ARG_ENABLE([stack-protector],
241 AS_HELP_STRING([--enable-stack-protector=@<:@yes|no|all|strong@:>@],
242 [Use -fstack-protector[-all|-strong] to detect glibc buffer overflows]),
243 [enable_stack_protector=$enableval],
244 [enable_stack_protector=no])
245 case "$enable_stack_protector" in
246 all|yes|no|strong) ;;
247 *) AC_MSG_ERROR([Not a valid argument for --enable-stack-protector: \"$enable_stack_protector\"]);;
250 dnl On some platforms we cannot use dynamic loading. We must provide
251 dnl static NSS modules.
252 AC_ARG_ENABLE([static-nss],
253 AS_HELP_STRING([--enable-static-nss],
254 [build static NSS modules @<:@default=no@:>@]),
255 [static_nss=$enableval],
257 dnl Enable static NSS also if we build no shared objects.
258 if test x"$static_nss" = xyes || test x"$shared" = xno; then
260 AC_DEFINE(DO_STATIC_NSS)
263 AC_ARG_ENABLE([force-install],
264 AS_HELP_STRING([--disable-force-install],
265 [don't force installation of files from this package, even if they are older than the installed files]),
266 [force_install=$enableval],
268 AC_SUBST(force_install)
270 AC_ARG_ENABLE([maintainer-mode],
271 AS_HELP_STRING([--enable-maintainer-mode],
272 [enable make rules and dependencies not useful (and sometimes confusing) to the casual installer]),
273 [maintainer=$enableval],
276 dnl On some platforms we allow dropping compatibility with all kernel
278 AC_ARG_ENABLE([kernel],
279 AS_HELP_STRING([--enable-kernel=VERSION],
280 [compile for compatibility with kernel not older than VERSION]),
281 [minimum_kernel=$enableval],
283 dnl Prevent unreasonable values.
284 if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
285 # Better nothing than this.
288 if test "$minimum_kernel" = current; then
289 minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
293 dnl For the development we sometimes want gcc to issue even more warnings.
294 dnl This is not the default since many of the extra warnings are not
296 AC_ARG_ENABLE([all-warnings],
297 AS_HELP_STRING([--enable-all-warnings],
298 [enable all useful warnings gcc can issue]),
299 [all_warnings=$enableval],
301 AC_SUBST(all_warnings)
303 AC_ARG_ENABLE([werror],
304 AS_HELP_STRING([--disable-werror],
305 [do not build with -Werror]),
306 [enable_werror=$enableval],
308 AC_SUBST(enable_werror)
310 AC_ARG_ENABLE([multi-arch],
311 AS_HELP_STRING([--enable-multi-arch],
312 [enable single DSO with optimizations for multiple architectures]),
313 [multi_arch=$enableval],
314 [multi_arch=default])
316 AC_ARG_ENABLE([experimental-malloc],
317 AS_HELP_STRING([--disable-experimental-malloc],
318 [disable experimental malloc features]),
319 [experimental_malloc=$enableval],
320 [experimental_malloc=yes])
321 AC_SUBST(experimental_malloc)
323 AC_ARG_ENABLE([memory-tagging],
324 AS_HELP_STRING([--enable-memory-tagging],
325 [enable memory tagging if supported by the architecture @<:@default=no@:>@]),
326 [memory_tagging=$enableval],
328 if test "$memory_tagging" = yes; then
329 # Only enable this on architectures that support it.
336 AC_SUBST(memory_tagging)
338 AC_ARG_ENABLE([crypt],
339 AS_HELP_STRING([--disable-crypt],
340 [do not build nor install the passphrase hashing library, libcrypt]),
341 [build_crypt=$enableval],
343 AC_SUBST(build_crypt)
345 AC_ARG_ENABLE([nss-crypt],
346 AS_HELP_STRING([--enable-nss-crypt],
347 [enable libcrypt to use nss]),
348 [nss_crypt=$enableval],
350 if test x$build_libcrypt = xno && test x$nss_crypt = xyes; then
351 AC_MSG_WARN([--enable-nss-crypt has no effect when libcrypt is disabled])
354 if test x$nss_crypt = xyes; then
355 nss_includes=-I$(nss-config --includedir 2>/dev/null)
356 if test $? -ne 0; then
357 AC_MSG_ERROR([cannot find include directory with nss-config])
359 nspr_includes=-I$(nspr-config --includedir 2>/dev/null)
360 if test $? -ne 0; then
361 AC_MSG_ERROR([cannot find include directory with nspr-config])
364 CFLAGS="$CFLAGS $nss_includes $nspr_includes"
365 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
367 #include <nsslowhash.h>
368 void f (void) { NSSLOW_Init (); }])],
369 libc_cv_nss_crypt=yes,
371 cannot find NSS headers with lowlevel hash function interfaces]))
373 old_LDFLAGS="$LDFLAGS"
374 LIBS="$LIBS -lfreebl3"
375 AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
377 #include <nsslowhash.h>],
379 libc_cv_nss_crypt=yes,
381 cannot link program using lowlevel NSS hash functions]))
382 # Check to see if there is a static NSS cryptographic library.
383 # If there isn't then we can't link anything with libcrypt.a,
384 # and that might mean disabling some static tests.
385 LDFLAGS="$LDFLAGS -static"
386 AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
388 #include <nsslowhash.h>],
390 libc_cv_static_nss_crypt=yes,
391 libc_cv_static_nss_crypt=no)
392 LDFLAGS="$old_LDFLAGS"
397 libc_cv_static_nss_crypt=no
399 AC_SUBST(libc_cv_nss_crypt)
400 AC_SUBST(libc_cv_static_nss_crypt)
403 AC_ARG_ENABLE([systemtap],
404 [AS_HELP_STRING([--enable-systemtap],
405 [enable systemtap static probe points @<:@default=no@:>@])],
406 [systemtap=$enableval],
408 if test "x$systemtap" != xno; then
409 AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
411 CFLAGS="-std=gnu11 $CFLAGS"
412 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
413 void foo (int i, void *p)
415 asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
416 :: STAP_PROBE_ASM_OPERANDS (2, i, p));
417 }]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
418 CFLAGS="$old_CFLAGS"])
419 if test $libc_cv_sdt = yes; then
420 AC_DEFINE([USE_STAP_PROBE])
421 elif test "x$systemtap" != xauto; then
422 AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
426 AC_ARG_ENABLE([build-nscd],
427 [AS_HELP_STRING([--disable-build-nscd],
428 [disable building and installing the nscd daemon])],
429 [build_nscd=$enableval],
430 [build_nscd=default])
433 # Note the use of $use_nscd is near the bottom of the file.
434 AC_ARG_ENABLE([nscd],
435 [AS_HELP_STRING([--disable-nscd],
436 [library functions will not contact the nscd daemon])],
437 [use_nscd=$enableval],
440 AC_ARG_ENABLE([pt_chown],
441 [AS_HELP_STRING([--enable-pt_chown],
442 [Enable building and installing pt_chown])],
443 [build_pt_chown=$enableval],
445 AC_SUBST(build_pt_chown)
446 if test "$build_pt_chown" = yes; then
447 AC_DEFINE(HAVE_PT_CHOWN)
450 AC_ARG_ENABLE([tunables],
451 [AS_HELP_STRING([--enable-tunables],
452 [Enable tunables support. Known values are 'yes', 'no' and 'valstring'])],
453 [have_tunables=$enableval],
455 AC_SUBST(have_tunables)
456 if test "$have_tunables" = yes; then
457 AC_DEFINE(HAVE_TUNABLES)
460 # The abi-tags file uses a fairly simplistic model for name recognition that
461 # can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
462 # $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
463 # This doesn't get used much beyond that, so it's fairly safe.
468 host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
472 AC_ARG_ENABLE([mathvec],
473 [AS_HELP_STRING([--enable-mathvec],
474 [Enable building and installing mathvec @<:@default depends on architecture@:>@])],
475 [build_mathvec=$enableval],
476 [build_mathvec=notset])
478 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
480 # error no CET compiler support
482 [libc_cv_compiler_default_cet=yes],
483 [libc_cv_compiler_default_cet=no])
486 AS_HELP_STRING([--enable-cet],
487 [enable Intel Control-flow Enforcement Technology (CET), x86 only]),
488 [enable_cet=$enableval],
489 [enable_cet=$libc_cv_compiler_default_cet])
492 AC_HELP_STRING([--disable-scv],
493 [syscalls will not use scv instruction, even if the kernel supports it, powerpc only]),
494 [use_scv=$enableval],
497 AS_IF([[test "$use_scv" != "no"]],[AC_DEFINE(USE_PPC_SCV)])
499 # We keep the original values in `$config_*' and never modify them, so we
500 # can write them unchanged into config.make. Everything else uses
501 # $machine, $vendor, and $os, and changes them whenever convenient.
502 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
504 # Don't allow vendor == "unknown"
505 test "$config_vendor" = unknown && config_vendor=
506 config_os="`echo $config_os | sed 's/^unknown-//'`"
508 # Some configurations imply other options.
511 # The configure fragment of a port can modify these to supplement
512 # or override the table in the case statement below. No fragment should
513 # ever change the config_* variables, however.
514 machine=$config_machine
515 vendor=$config_vendor
521 AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
524 yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
526 *) submachine="$withval" ;;
530 # An preconfigure script can set this when it wants to disable the sanity
534 # A preconfigure script for a system that may or may not use fpu
535 # sysdeps directories sets this to a preprocessor conditional for
536 # whether to use such directories.
539 dnl Let sysdeps/*/preconfigure act here.
540 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
544 ### By using the undocumented --enable-hacker-mode option for configure
545 ### one can skip this test to make the configuration not fail for unsupported
548 if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
549 case "$machine-$host_os" in
554 *** The GNU C library is currently unavailable for this platform.
555 *** If you are interested in seeing glibc on this platform visit
556 *** the "How to submit a new port" in the wiki:
557 *** https://sourceware.org/glibc/wiki/#Development
558 *** and join the community!])
563 # Set base_machine if not set by a preconfigure fragment.
564 test -n "$base_machine" || base_machine=$machine
565 AC_SUBST(base_machine)
567 # Determine whether to use fpu or nofpu sysdeps directories.
568 AC_CACHE_CHECK([for use of fpu sysdeps directories],
569 libc_cv_with_fp, [dnl
570 cat > conftest.c <<EOF
574 # error "no hardware floating point"
578 if ${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c -o conftest.s \
579 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
583 AC_SUBST(libc_cv_with_fp)
585 AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
586 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
591 AC_CACHE_CHECK(for -fstack-protector-strong, libc_cv_ssp_strong, [dnl
592 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-strong],
593 [libc_cv_ssp_strong=yes],
594 [libc_cv_ssp_strong=no])
597 AC_CACHE_CHECK(for -fstack-protector-all, libc_cv_ssp_all, [dnl
598 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-all],
599 [libc_cv_ssp_all=yes],
600 [libc_cv_ssp_all=no])
605 if test "$libc_cv_ssp" = yes; then
606 no_stack_protector="-fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0"
607 AC_DEFINE(HAVE_CC_NO_STACK_PROTECTOR)
610 if test "$enable_stack_protector" = yes && test "$libc_cv_ssp" = yes; then
611 stack_protector="-fstack-protector"
612 AC_DEFINE(STACK_PROTECTOR_LEVEL, 1)
613 elif test "$enable_stack_protector" = all && test "$libc_cv_ssp_all" = yes; then
614 stack_protector="-fstack-protector-all"
615 AC_DEFINE(STACK_PROTECTOR_LEVEL, 2)
616 elif test "$enable_stack_protector" = strong && test "$libc_cv_ssp_strong" = yes; then
617 stack_protector="-fstack-protector-strong"
618 AC_DEFINE(STACK_PROTECTOR_LEVEL, 3)
620 stack_protector="-fno-stack-protector"
621 AC_DEFINE(STACK_PROTECTOR_LEVEL, 0)
623 AC_SUBST(libc_cv_ssp)
624 AC_SUBST(stack_protector)
625 AC_SUBST(no_stack_protector)
627 if test -n "$stack_protector"; then
628 dnl Don't run configure tests with stack-protection on, to avoid problems with
630 no_ssp=-fno-stack-protector
634 if test "$enable_stack_protector" != no; then
635 AC_MSG_ERROR([--enable-stack-protector=$enable_stack_protector specified, but specified level of stack protection is not supported by the compiler.])
639 # For the multi-arch option we need support in the assembler & linker.
640 AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
641 libc_cv_ld_gnu_indirect_function, [dnl
642 cat > conftest.S <<EOF
643 .type foo,%gnu_indirect_function
656 libc_cv_ld_gnu_indirect_function=no
657 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
658 -nostartfiles -nostdlib $no_ssp \
659 -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
660 # Do a link to see if the backend supports IFUNC relocs.
661 $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
662 LC_ALL=C $READELF -Wr conftest | grep -q 'IRELATIVE\|R_SPARC_JMP_IREL' && {
663 libc_cv_ld_gnu_indirect_function=yes
668 # Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
669 AC_CACHE_CHECK([for gcc attribute ifunc support],
670 libc_cv_gcc_indirect_function, [dnl
671 cat > conftest.c <<EOF
672 extern int func (int);
673 int used_func (int a)
677 static void *resolver ()
681 extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
683 libc_cv_gcc_indirect_function=no
684 if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
685 2>&AS_MESSAGE_LOG_FD ; then
686 if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&AS_MESSAGE_LOG_FD; then
687 libc_cv_gcc_indirect_function=yes
692 # Check if linker supports textrel relocation with ifunc (used on elf/tests).
693 # Note that it relies on libc_cv_ld_gnu_indirect_function test above.
694 AC_CACHE_CHECK([whether the linker supports textrels along with ifunc],
695 libc_cv_textrel_ifunc, [dnl
696 cat > conftest.S <<EOF
697 .type foo,%gnu_indirect_function
718 libc_cv_textrel_ifunc=no
719 if test $libc_cv_ld_gnu_indirect_function = yes; then
720 if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib $no_ssp -pie -o conftest conftest.S); then
721 libc_cv_textrel_ifunc=yes
725 AC_SUBST(libc_cv_textrel_ifunc)
727 # Check if CC supports attribute retain as it is used in attribute_used_retain macro.
728 AC_CACHE_CHECK([for GNU attribute retain support],
729 libc_cv_gnu_retain, [dnl
730 cat > conftest.c <<EOF
731 static int var __attribute__ ((used, retain, section ("__libc_atexit")));
733 libc_cv_gnu_retain=no
734 if ${CC-cc} -Werror -c conftest.c -o /dev/null 1>&AS_MESSAGE_LOG_FD \
735 2>&AS_MESSAGE_LOG_FD ; then
736 libc_cv_gnu_retain=yes
739 if test $libc_cv_gnu_retain = yes; then
740 AC_DEFINE(HAVE_GNU_RETAIN)
742 LIBC_CONFIG_VAR([have-gnu-retain], [$libc_cv_gnu_retain])
744 # Check if gcc warns about alias for function with incompatible types.
745 AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
746 libc_cv_gcc_incompatible_alias, [dnl
747 cat > conftest.c <<EOF
748 int __redirect_foo (const void *s, int c);
750 __typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
751 __typeof (__redirect_foo) *foo_impl (void)
756 extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
758 libc_cv_gcc_incompatible_alias=yes
759 if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
760 libc_cv_gcc_incompatible_alias=no
764 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
765 if test x"$multi_arch" = xyes; then
766 AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
771 if test x"$libc_cv_gcc_indirect_function" != xyes; then
772 # GCC 8+ emits a warning for alias with incompatible types and it might
773 # fail to build ifunc resolvers aliases to either weak or internal
774 # symbols. Disables multiarch build in this case.
775 if test x"$libc_cv_gcc_incompatible_alias" = xyes; then
776 AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types])
777 if test x"$multi_arch" = xyes; then
778 AC_MSG_ERROR([--enable-multi-arch support requires a gcc with gnu-indirect-function support])
780 AC_MSG_WARN([Multi-arch is disabled.])
782 elif test x"$multi_arch" = xyes; then
783 AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
784 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
788 if test x"$multi_arch" != xno; then
789 multi_arch_d=/multiarch
792 # Compute the list of sysdep directories for this configuration.
793 # This can take a while to compute.
794 sysdep_dir=$srcdir/sysdeps
795 AC_MSG_CHECKING(sysdep dirs)
796 dnl We need to use [ and ] for other purposes for a while now.
798 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
799 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
801 test "x$base_os" != x || case "$os" in
808 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
811 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
815 o=`echo $tail | sed 's/[0-9]*$//'`
816 if test $o != $tail; then
819 # For linux-gnu, try linux-gnu, then linux.
820 o=`echo $tail | sed 's/-.*$//'`
821 if test $o != $tail; then
825 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
828 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
834 # For sparc/sparc32, try sparc/sparc32 and then sparc.
836 tail=$machine${submachine:+/$submachine}
837 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
839 # Prepend the machine's FPU directory unless the architecture specific
840 # preconfigure disables it.
841 if test "$libc_cv_with_fp" = yes; then
846 # For each machine term, try it with and then without /multiarch.
847 for try_fpu in $maybe_fpu ''; do
848 for try_multi in $multi_arch_d ''; do
849 mach="$mach /$1$try_fpu$try_multi"
855 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
858 # Find what sysdep directories exist.
860 for b in $base ''; do
861 for m0 in $mach ''; do
862 for v in /$vendor ''; do
863 test "$v" = / && continue
864 for o in /$ostry ''; do
865 test "$o" = / && continue
866 for m in $mach ''; do
867 try_suffix="$m0$b$v$o$m"
868 if test -n "$try_suffix"; then
869 try_srcdir="${srcdir}/"
870 try="sysdeps$try_suffix"
871 test -n "$enable_debug_configure" &&
872 echo "$0 [DEBUG]: try $try" >&2
873 if test -d "$try_srcdir$try"; then
874 sysnames="$sysnames $try"
875 { test -n "$o" || test -n "$b"; } && os_used=t
876 { test -n "$m" || test -n "$m0"; } && machine_used=t
878 x*/$submachine) submachine_used=t ;;
888 # If the assembler supports gnu_indirect_function symbol type and the
889 # architecture supports multi-arch, we enable multi-arch by default.
894 test x"$multi_arch" = xdefault && multi_arch=no
897 if test x"$multi_arch" != xno; then
898 AC_DEFINE(USE_MULTIARCH)
902 if test -z "$os_used" && test "$os" != none; then
903 AC_MSG_ERROR(Operating system $os is not supported.)
905 if test -z "$machine_used" && test "$machine" != none; then
906 AC_MSG_ERROR(The $machine is not supported.)
908 if test -z "$submachine_used" && test -n "$submachine"; then
909 AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
913 # We have now validated the configuration.
915 # Expand the list of system names into a full list of directories
916 # from each element's parent name and Implies file (if present).
919 while test $# -gt 0; do
923 case " $names " in *" $name "*)
924 # Already in the list.
928 # Report each name as we discover it, so there is no long pause in output.
929 echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
931 name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
935 *) xsrcdir=$srcdir/ ;;
937 test -n "$enable_debug_configure" &&
938 echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
940 for implies_file in Implies Implies-before Implies-after; do
941 implies_type=`echo $implies_file | sed s/-/_/`
942 eval ${implies_type}=
943 if test -f $xsrcdir$name/$implies_file; then
944 # Collect more names from the `Implies' file (removing comments).
945 implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/$implies_file`"
946 for x in $implied_candidate; do
948 if test -d $xsrcdir$name_base/$x; then
949 eval "${implies_type}=\"\$${implies_type} \$name_base/\$x\""
954 test -n "$enable_debug_configure" &&
955 echo "[DEBUG]: $name $implies_file $x try() {$try_srcdir}$try" >&2
956 if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
958 eval "${implies_type}=\"\$${implies_type} \$try\""
961 if test $found = no; then
962 AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
968 # Add NAME to the list of names.
971 # Find the parent of NAME, using the empty string if it has none.
973 parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
976 test -n "$enable_debug_configure" &&
977 echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
978 Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
980 # Add the names implied by NAME, and NAME's parent (if it has one), to
981 # the list of names to be processed (the argument list). We prepend the
982 # implied names to the list and append the parent. We want implied
983 # directories to come before further directories inferred from the
984 # configuration components; this ensures that for sysv4, unix/common
985 # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
987 sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
988 test -n "$sysnames" && set $sysnames
991 # Add the default directories.
992 default_sysnames="sysdeps/generic"
993 sysnames="$names $default_sysnames"
995 # The other names were emitted during the scan.
996 AC_MSG_RESULT($default_sysnames)
1002 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
1003 # The makefiles need to use a different form to find it in $srcdir.
1004 INSTALL='\$(..)./scripts/install-sh -c'
1010 # Accept binutils 2.25 or newer.
1011 AC_CHECK_PROG_VER(AS, $AS, --version,
1012 [GNU assembler.* \([0-9]*\.[0-9.]*\)],
1013 [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
1014 AS=: critic_missing="$critic_missing as")
1017 case $($LD --version) in
1019 # Accept gold 1.14 or higher
1020 AC_CHECK_PROG_VER(LD, $LD, --version,
1021 [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
1022 [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
1023 LD=: critic_missing="$critic_missing GNU gold")
1026 # Accept LLD 13.0.0 or higher
1027 AC_CHECK_PROG_VER(LD, $LD, --version,
1028 [LLD.* \([0-9][0-9]*\.[0-9.]*\)],
1029 [1[3-9].*|[2-9][0-9].*],
1030 LD=: critic_missing="$critic_missing LLD")
1031 libc_cv_with_lld=yes
1034 AC_CHECK_PROG_VER(LD, $LD, --version,
1035 [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
1036 [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
1037 LD=: critic_missing="$critic_missing GNU ld")
1040 LIBC_CONFIG_VAR([with-lld], [$libc_cv_with_lld])
1042 # These programs are version sensitive.
1043 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
1044 [GNU Make[^0-9]*\([0-9][0-9.]*\)],
1045 [[4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
1047 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
1048 [GNU gettext.* \([0-9]*\.[0-9.]*\)],
1049 [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
1050 MSGFMT=: aux_missing="$aux_missing msgfmt")
1051 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
1052 [GNU texinfo.* \([0-9][0-9.]*\)],
1053 [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
1054 MAKEINFO=: aux_missing="$aux_missing makeinfo")
1055 AC_CHECK_PROG_VER(SED, sed, --version,
1056 [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
1057 [3.0[2-9]*|3.[1-9]*|[4-9]*],
1058 SED=: aux_missing="$aux_missing sed")
1059 AC_CHECK_PROG_VER(AWK, gawk, --version,
1060 [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
1061 [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
1062 AC_CHECK_PROG_VER(BISON, bison, --version,
1063 [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
1064 [2.7*|[3-9].*|[1-9][0-9]*], critic_missing="$critic_missing bison")
1066 AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
1067 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
1068 #if !defined __GNUC__ || __GNUC__ < 6 || (__GNUC__ == 6 && __GNUC_MINOR__ < 2)
1069 #error insufficient compiler
1071 [libc_cv_compiler_ok=yes],
1072 [libc_cv_compiler_ok=no])])
1073 AS_IF([test $libc_cv_compiler_ok != yes],
1074 [critic_missing="$critic_missing compiler"])
1076 AC_CHECK_TOOL(NM, nm, false)
1078 if test "x$maintainer" = "xyes"; then
1079 AC_CHECK_PROGS(AUTOCONF, autoconf, no)
1080 case "x$AUTOCONF" in
1081 xno|x|x:) AUTOCONF=no ;;
1084 whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
1085 if (cd $srcdir; $AUTOCONF $ACFLAGS configure.ac > /dev/null 2>&1); then
1086 libc_cv_autoconf_works=yes
1088 libc_cv_autoconf_works=no
1090 test $libc_cv_autoconf_works = yes || AUTOCONF=no
1093 if test "x$AUTOCONF" = xno; then
1094 aux_missing="$aux_missing autoconf"
1100 # Check for python3 if available, or else python.
1101 AC_CHECK_PROG_VER(PYTHON_PROG, python3 python, --version,
1102 [Python \([0-9][0-9.]*\)],
1103 [3.[4-9]*|3.[1-9][0-9]*|[4-9].*|[1-9][0-9]*],
1104 critic_missing="$critic_missing python")
1105 PYTHON="$PYTHON_PROG -B"
1108 test -n "$critic_missing" && AC_MSG_ERROR([
1109 *** These critical programs are missing or too old:$critic_missing
1110 *** Check the INSTALL file for required versions.])
1112 test -n "$aux_missing" && AC_MSG_WARN([
1113 *** These auxiliary programs are missing or incompatible versions:$aux_missing
1114 *** some features or tests will be disabled.
1115 *** Check the INSTALL file for required versions.])
1117 # if using special system headers, find out the compiler's sekrit
1118 # header directory and add that to the list. NOTE: Only does the right
1119 # thing on a system that doesn't need fixincludes. (Not presently a problem.)
1120 if test -n "$sysheaders"; then
1121 SYSINCLUDES=-nostdinc
1122 for d in include include-fixed; do
1123 i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
1124 SYSINCLUDES="$SYSINCLUDES -isystem $i"
1126 SYSINCLUDES="$SYSINCLUDES \
1127 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
1128 if test -n "$CXX"; then
1130 for cxxheaders in `$CXX -v -S -x c++ /dev/null -o /dev/null 2>&1 \
1131 | sed -n -e '1,/#include/d' -e 's/^ \(\/.*\/[cg]++\)/\1/p'`; do
1132 test "x$cxxheaders" != x &&
1133 CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders"
1137 AC_SUBST(SYSINCLUDES)
1138 AC_SUBST(CXX_SYSINCLUDES)
1140 # Obtain some C++ header file paths. This is used to make a local
1141 # copy of those headers in Makerules.
1142 if test -n "$CXX"; then
1143 find_cxx_header () {
1144 echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
1145 | sed -n "\,$1:,{s/:\$//;p}"
1147 CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
1148 CXX_CMATH_HEADER="$(find_cxx_header cmath)"
1149 CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
1151 AC_SUBST(CXX_CSTDLIB_HEADER)
1152 AC_SUBST(CXX_CMATH_HEADER)
1153 AC_SUBST(CXX_BITS_STD_ABS_H)
1155 # Test if LD_LIBRARY_PATH contains the notation for the current directory
1156 # since this would lead to problems installing/building glibc.
1157 # LD_LIBRARY_PATH contains the current directory if one of the following
1159 # - one of the terminals (":" and ";") is the first or last sign
1160 # - two terminals occur directly after each other
1161 # - the path contains an element with a dot in it
1162 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
1164 case ${LD_LIBRARY_PATH} in
1165 [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
1166 ld_library_path_setting="contains current directory"
1169 ld_library_path_setting="ok"
1173 AC_MSG_RESULT($ld_library_path_setting)
1174 if test "$ld_library_path_setting" != "ok"; then
1176 *** LD_LIBRARY_PATH shouldn't contain the current directory when
1177 *** building glibc. Please change the environment variable
1178 *** and run configure again.])
1181 AC_PATH_PROG(BASH_SHELL, bash, no)
1183 AC_PATH_PROG(PERL, perl, no)
1184 if test "$PERL" != no &&
1185 (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1188 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1189 $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1191 AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
1192 cat > conftest.s <<EOF
1195 .set glibc_conftest_frobozz,foo
1196 .globl glibc_conftest_frobozz
1198 # The alpha-dec-osf1 assembler gives only a warning for `.set'
1199 # (but it doesn't work), so we must do a linking check to be sure.
1200 cat > conftest1.c <<\EOF
1201 extern int glibc_conftest_frobozz;
1202 void _start() { glibc_conftest_frobozz = 1; }
1204 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1205 -nostartfiles -nostdlib $no_ssp \
1206 -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1207 libc_cv_asm_set_directive=yes
1209 libc_cv_asm_set_directive=no
1212 if test $libc_cv_asm_set_directive = yes; then
1213 AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1216 AC_CACHE_CHECK(linker support for protected data symbol,
1217 libc_cv_protected_data,
1218 [cat > conftest.c <<EOF
1219 int bar __attribute__ ((visibility ("protected"))) = 1;
1221 libc_cv_protected_data=no
1222 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -o conftest.so); then
1223 cat > conftest.c <<EOF
1225 int main (void) { return bar; }
1227 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp conftest.c -o conftest conftest.so); then
1228 libc_cv_protected_data=yes
1233 AC_SUBST(libc_cv_protected_data)
1235 AC_CACHE_CHECK(linker support for INSERT in linker script,
1237 [cat > conftest.c <<EOF
1238 int __attribute__ ((section(".bar"))) bar = 0x12345678;
1239 int test (void) { return bar; }
1241 cat > conftest.t <<EOF
1246 INSERT AFTER .rela.dyn;
1249 if AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -Wl,-T,conftest.t -o conftest.so]); then
1254 AC_SUBST(libc_cv_insert)
1256 AC_CACHE_CHECK(for broken __attribute__((alias())),
1257 libc_cv_broken_alias_attribute,
1258 [cat > conftest.c <<EOF
1259 extern int foo (int x) __asm ("xyzzy");
1260 int bar (int x) { return x; }
1261 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1263 extern __typeof (dfoo) dfoo __asm ("abccb");
1266 libc_cv_broken_alias_attribute=yes
1267 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1268 if grep 'xyzzy' conftest.s >/dev/null &&
1269 grep 'abccb' conftest.s >/dev/null; then
1270 libc_cv_broken_alias_attribute=no
1273 rm -f conftest.c conftest.s
1275 if test $libc_cv_broken_alias_attribute = yes; then
1276 AC_MSG_ERROR(working alias attribute support required)
1279 AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
1280 libc_cv_have_sdata_section,
1281 [echo "int i;" > conftest.c
1282 libc_cv_have_sdata_section=no
1283 if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
1284 | grep '\.sdata' >/dev/null; then
1285 libc_cv_have_sdata_section=yes
1287 rm -f conftest.c conftest.so
1289 if test $libc_cv_have_sdata_section = yes; then
1290 AC_DEFINE(HAVE_SDATA_SECTION)
1293 AC_CACHE_CHECK(for libunwind-support in compiler,
1294 libc_cv_cc_with_libunwind, [
1295 cat > conftest.c <<EOF
1296 int main (void) { return 0; }
1298 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
1299 conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
1300 libc_cv_cc_with_libunwind=yes
1302 libc_cv_cc_with_libunwind=no
1305 AC_SUBST(libc_cv_cc_with_libunwind)
1306 if test $libc_cv_cc_with_libunwind = yes; then
1307 AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
1311 AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1312 libc_cv_as_noexecstack, [dnl
1313 cat > conftest.c <<EOF
1316 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1317 -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1318 && grep .note.GNU-stack conftest.s >/dev/null \
1319 && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1320 -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1322 libc_cv_as_noexecstack=yes
1324 libc_cv_as_noexecstack=no
1327 if test $libc_cv_as_noexecstack = yes; then
1328 ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1330 AC_SUBST(ASFLAGS_config)
1332 LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
1333 [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
1334 AC_SUBST(libc_cv_z_execstack)
1336 LIBC_LINKER_FEATURE([-z start-stop-gc], [-Wl,-z,start-stop-gc],
1337 [libc_cv_z_start_stop_gc=yes], [libc_cv_z_start_stop_gc=no])
1338 LIBC_CONFIG_VAR([have-z-start-stop-gc], [$libc_cv_z_start_stop_gc])
1340 LIBC_LINKER_FEATURE([--depaudit], [-Wl,--depaudit,x],
1341 [libc_cv_depaudit=yes], [libc_cv_depaudit=no])
1342 LIBC_CONFIG_VAR([have-depaudit], [$libc_cv_depaudit])
1344 LIBC_LINKER_FEATURE([-z pack-relative-relocs],
1345 [-Wl,-z,pack-relative-relocs],
1346 [libc_cv_dt_relr=yes], [libc_cv_dt_relr=no])
1347 LIBC_CONFIG_VAR([have-dt-relr], [$libc_cv_dt_relr])
1349 LIBC_LINKER_FEATURE([--no-dynamic-linker],
1350 [-Wl,--no-dynamic-linker],
1351 [libc_cv_no_dynamic_linker=yes],
1352 [libc_cv_no_dynamic_linker=no])
1353 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
1355 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
1356 LIBC_TRY_CC_OPTION([-static-pie],
1357 [libc_cv_static_pie=yes],
1358 [libc_cv_static_pie=no])
1360 LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie])
1362 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1363 LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
1366 AC_SUBST(libc_cv_fpie)
1368 AC_CACHE_CHECK(for GLOB_DAT reloc,
1369 libc_cv_has_glob_dat, [dnl
1370 cat > conftest.c <<EOF
1372 int foo (void) { return mumble; }
1374 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1375 -fPIC -shared -o conftest.so conftest.c
1376 -nostdlib -nostartfiles $no_ssp
1377 1>&AS_MESSAGE_LOG_FD])
1379 dnl look for GLOB_DAT relocation.
1380 if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
1381 libc_cv_has_glob_dat=yes
1383 libc_cv_has_glob_dat=no
1386 libc_cv_has_glob_dat=no
1389 AC_SUBST(libc_cv_has_glob_dat)
1391 AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
1393 cat > conftest.c <<EOF
1400 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -fPIC -mtls-dialect=gnu2 -nostdlib -nostartfiles
1401 conftest.c -o conftest 1>&AS_MESSAGE_LOG_FD])
1403 libc_cv_mtls_dialect_gnu2=yes
1405 libc_cv_mtls_dialect_gnu2=no
1408 AC_SUBST(libc_cv_mtls_dialect_gnu2)
1409 LIBC_CONFIG_VAR([have-mtls-dialect-gnu2], [$libc_cv_mtls_dialect_gnu2])
1411 AC_CACHE_CHECK(whether cc puts quotes around section names,
1412 libc_cv_have_section_quotes,
1413 [cat > conftest.c <<EOF
1414 static const int foo
1415 __attribute__ ((section ("bar"))) = 1;
1417 if ${CC-cc} -S conftest.c -o conftest.s; then
1418 if grep '\.section.*"bar"' conftest.s >/dev/null; then
1419 libc_cv_have_section_quotes=yes
1421 libc_cv_have_section_quotes=no
1424 libc_cv_have_section_quotes=unknown
1426 rm -f conftest.{c,s}
1428 if test $libc_cv_have_section_quotes = yes; then
1429 AC_DEFINE(HAVE_SECTION_QUOTES)
1432 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1433 cat > conftest.c <<\EOF
1436 __builtin_memset (x, 0, 1000);
1440 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "memset" > /dev/null]);
1442 libc_cv_gcc_builtin_memset=no
1444 libc_cv_gcc_builtin_memset=yes
1447 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1448 AC_DEFINE(HAVE_BUILTIN_MEMSET)
1451 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1452 cat > conftest.c <<\EOF
1453 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1454 char *foo (const char *a, const char *b)
1456 return __builtin_strstr (a, b);
1460 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null]);
1462 libc_cv_gcc_builtin_redirection=yes
1464 libc_cv_gcc_builtin_redirection=no
1467 if test "$libc_cv_gcc_builtin_redirection" = no; then
1468 AC_MSG_ERROR([support for the symbol redirection needed])
1471 dnl Determine how to disable generation of FMA instructions.
1472 AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1473 libc_cv_cc_nofma, [dnl
1475 for opt in -ffp-contract=off -mno-fused-madd; do
1476 LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1478 AC_SUBST(libc_cv_cc_nofma)
1480 if test -n "$submachine"; then
1481 AC_CACHE_CHECK([for compiler option for CPU variant],
1482 libc_cv_cc_submachine, [dnl
1483 libc_cv_cc_submachine=no
1484 for opt in "-march=$submachine" "-mcpu=$submachine"; do
1485 LIBC_TRY_CC_OPTION([$opt], [
1486 libc_cv_cc_submachine="$opt"
1489 if test "x$libc_cv_cc_submachine" = xno; then
1490 AC_MSG_ERROR([${CC-cc} does not support $submachine])
1493 AC_SUBST(libc_cv_cc_submachine)
1495 AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
1496 __attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
1497 cat > conftest.c <<EOF
1499 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
1502 libc_cv_cc_loop_to_function=no
1503 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c])
1505 libc_cv_cc_loop_to_function=yes
1508 if test $libc_cv_cc_loop_to_function = yes; then
1509 AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
1511 AC_SUBST(libc_cv_cc_loop_to_function)
1513 dnl Check whether we have the gd library available.
1514 AC_MSG_CHECKING(for libgd)
1515 if test "$with_gd" != "no"; then
1516 old_CFLAGS="$CFLAGS"
1517 CFLAGS="$CFLAGS $libgd_include"
1518 old_LDFLAGS="$LDFLAGS"
1519 LDFLAGS="$LDFLAGS $libgd_ldflags"
1521 LIBS="$LIBS -lgd -lpng -lz -lm"
1522 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gd.h>]], [[gdImagePng (0, 0)]])],
1523 [LIBGD=yes], [LIBGD=no])
1524 CFLAGS="$old_CFLAGS"
1525 LDFLAGS="$old_LDFLAGS"
1530 AC_MSG_RESULT($LIBGD)
1534 if test x$with_selinux = xno ; then
1537 # See if we have the SELinux library
1538 AC_CHECK_LIB(selinux, is_selinux_enabled,
1539 have_selinux=yes, have_selinux=no)
1540 if test x$with_selinux = xyes ; then
1541 if test x$have_selinux = xno ; then
1542 AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
1546 # Check if we're building with SELinux support.
1547 if test "x$have_selinux" = xyes; then
1548 AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
1550 # See if we have the libaudit library
1551 AC_CHECK_LIB(audit, audit_log_user_avc_message,
1552 have_libaudit=yes, have_libaudit=no)
1553 if test "x$have_libaudit" = xyes; then
1554 AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
1556 AC_SUBST(have_libaudit)
1558 # See if we have the libcap library
1559 AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
1560 if test "x$have_libcap" = xyes; then
1561 AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
1563 AC_SUBST(have_libcap)
1565 AC_SUBST(have_selinux)
1568 dnl Check for silly hacked compilers predefining _FORTIFY_SOURCE.
1569 dnl Since we are building the implementations of the fortified functions here,
1570 dnl having the macro defined interacts very badly.
1571 dnl _FORTIFY_SOURCE requires compiler optimization level 1 (gcc -O1)
1572 dnl and above (see "man FEATURE_TEST_MACROS").
1573 dnl So do NOT replace AC_COMPILE_IFELSE with AC_PREPROC_IFELSE.
1574 AC_CACHE_CHECK([for _FORTIFY_SOURCE predefine], libc_cv_predef_fortify_source,
1575 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1576 #ifdef _FORTIFY_SOURCE
1579 [libc_cv_predef_fortify_source=no],
1580 [libc_cv_predef_fortify_source=yes])])
1581 if test $libc_cv_predef_fortify_source = yes; then
1582 CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE"
1586 dnl Starting with binutils 2.35, GAS can attach multiple symbol versions
1587 dnl to one symbol (PR 23840).
1588 AC_CACHE_CHECK(whether the assembler requires one version per symbol,
1589 libc_cv_symver_needs_alias, [dnl
1590 cat > conftest.s <<EOF
1594 .symver testfunc, testfunc1@VERSION1
1595 .symver testfunc, testfunc1@VERSION2
1597 libc_cv_symver_needs_alias=no
1598 if ${CC-cc} $ASFLAGS -c conftest.s 2>&AS_MESSAGE_LOG_FD; then
1599 libc_cv_symver_needs_alias=no
1601 libc_cv_symver_needs_alias=yes
1605 if test "$libc_cv_symver_needs_alias" = yes; then
1606 AC_DEFINE(SYMVER_NEEDS_ALIAS)
1609 AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
1610 libc_cv_builtin_trap, [dnl
1611 libc_cv_builtin_trap=no
1612 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[__builtin_trap ()]])],[
1613 libc_undefs=`$NM -u conftest.o |
1614 LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1615 2>&AS_MESSAGE_LOG_FD` || {
1616 AC_MSG_ERROR([confusing output from $NM -u])
1618 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1619 if test -z "$libc_undefs"; then
1620 libc_cv_builtin_trap=yes
1622 if test $libc_cv_builtin_trap = yes; then
1623 AC_DEFINE([HAVE_BUILTIN_TRAP])
1626 dnl C++ feature tests.
1629 AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
1630 libc_cv_cxx_thread_local, [
1631 old_CXXFLAGS="$CXXFLAGS"
1632 CXXFLAGS="$CXXFLAGS -std=gnu++11"
1633 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1636 // Compiler support.
1643 S * get () { return &s; }
1645 // libstdc++ support.
1646 #ifndef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
1647 #error __cxa_thread_atexit_impl not supported
1650 [libc_cv_cxx_thread_local=yes],
1651 [libc_cv_cxx_thread_local=no])
1652 CXXFLAGS="$old_CXXFLAGS"
1654 AC_SUBST(libc_cv_cxx_thread_local)
1657 dnl End of C++ feature tests.
1659 ### End of automated tests.
1660 ### Now run sysdeps configure fragments.
1662 # They also can set these variables.
1664 ldd_rewrite_script=no
1665 libc_cv_sysconfdir=$sysconfdir
1666 libc_cv_localstatedir=$localstatedir
1667 libc_cv_gcc_unwind_find_fde=no
1671 # Iterate over all the sysdep directories we will use, running their
1672 # configure fragments.
1673 for dir in $sysnames; do
1676 *) dest=$srcdir/$dir ;;
1678 if test -r $dest/configure; then
1679 AC_MSG_RESULT(running configure fragment for $dir)
1684 if test x"$build_mathvec" = xnotset; then
1687 LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
1689 AC_SUBST(libc_extra_cflags)
1690 AC_SUBST(libc_extra_cppflags)
1692 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
1693 AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
1695 AC_SUBST(libc_cv_gcc_unwind_find_fde)
1697 # A sysdeps configure fragment can reset this if IFUNC is not actually
1698 # usable even though the assembler knows how to generate the symbol type.
1699 if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
1700 AC_DEFINE(HAVE_IFUNC)
1702 LIBC_CONFIG_VAR([have-ifunc], [$libc_cv_ld_gnu_indirect_function])
1704 if test x"$libc_cv_gcc_indirect_function" = xyes; then
1705 AC_DEFINE(HAVE_GCC_IFUNC)
1707 LIBC_CONFIG_VAR([have-gcc-ifunc], [$libc_cv_gcc_indirect_function])
1709 # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
1710 # configure fragment can override the value to prevent this AC_DEFINE.
1712 if test "x$use_nscd" != xno; then
1713 AC_DEFINE([USE_NSCD])
1715 if test "x$build_nscd" = xdefault; then
1716 build_nscd=$use_nscd
1719 AC_SUBST(libc_cv_slibdir)
1720 AC_SUBST(libc_cv_rtlddir)
1721 AC_SUBST(libc_cv_complocaledir)
1722 AC_SUBST(libc_cv_sysconfdir)
1723 AC_SUBST(libc_cv_localstatedir)
1724 AC_SUBST(libc_cv_rootsbindir)
1726 if test x$use_ldconfig = xyes; then
1727 AC_DEFINE(USE_LDCONFIG)
1729 AC_SUBST(use_ldconfig)
1730 AC_SUBST(ldd_rewrite_script)
1735 AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
1736 [libc_cv_pic_default=yes
1737 cat > conftest.c <<EOF
1738 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
1739 # error PIC is default.
1742 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1743 libc_cv_pic_default=no
1746 LIBC_CONFIG_VAR([build-pic-default], [$libc_cv_pic_default])
1748 AC_CACHE_CHECK([whether -fPIE is default], libc_cv_cc_pie_default,
1749 [libc_cv_cc_pie_default=yes
1750 cat > conftest.c <<EOF
1751 #if defined __PIE__ || defined __pie__ || defined PIE || defined pie
1752 # error PIE is default.
1755 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1756 libc_cv_cc_pie_default=no
1759 LIBC_CONFIG_VAR([cc-pie-default], [$libc_cv_cc_pie_default])
1761 AC_MSG_CHECKING(if we can build programs as PIE)
1762 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifdef PIE_UNSUPPORTED
1763 # error PIE is not supported
1764 #endif]])], [libc_cv_pie_supported=yes], [libc_cv_pie_supported=no])
1765 AC_MSG_RESULT($libc_cv_pie_supported)
1766 # Disable build-pie-default if target does not support it or glibc is
1767 # configured with --disable-default-pie.
1768 if test "x$default_pie" = xno; then
1769 build_pie_default=no
1771 build_pie_default=$libc_cv_pie_supported
1773 LIBC_CONFIG_VAR([build-pie-default], [$build_pie_default])
1775 AC_MSG_CHECKING(if we can build static PIE programs)
1776 libc_cv_static_pie_supported=$libc_cv_pie_supported
1777 if test "x$libc_cv_pie_supported" != xno \
1778 -a "$libc_cv_no_dynamic_linker" = yes; then
1779 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef SUPPORT_STATIC_PIE
1780 # error static PIE is not supported
1781 #endif]])], [libc_cv_static_pie_supported=yes],
1782 [libc_cv_static_pie_supported=no])
1784 AC_MSG_RESULT($libc_cv_static_pie_supported)
1786 # Enable static-pie only if it is available and glibc isn't configured
1787 # with --disable-default-pie.
1788 if test "x$default_pie" = xno; then
1789 libc_cv_static_pie=no
1791 libc_cv_static_pie=$libc_cv_static_pie_supported
1793 if test "$libc_cv_static_pie" = "yes"; then
1794 AC_DEFINE(ENABLE_STATIC_PIE)
1796 LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
1798 # Set the `multidir' variable by grabbing the variable from the compiler.
1799 # We do it once and save the result in a generated makefile.
1800 libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
1801 AC_SUBST(libc_cv_multidir)
1804 AC_SUBST(static_nss)
1808 dnl See sysdeps/mach/configure.ac for this variable.
1809 AC_SUBST(mach_interface_list)
1811 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
1812 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
1816 if test "$pthread_in_libc" = yes; then
1817 AC_DEFINE(PTHREAD_IN_LIBC)
1819 AC_SUBST(pthread_in_libc)
1821 AC_CONFIG_FILES([config.make Makefile])
1822 AC_CONFIG_COMMANDS([default],[[
1823 case $CONFIG_FILES in *config.make*)
1824 echo "$config_vars" >> config.make;;
1826 test -d bits || mkdir bits]],[[config_vars='$config_vars']])