]> git.ipfire.org Git - thirdparty/glibc.git/blob - configure.ac
Fix build of nptl/tst-thread_local1.cc with GCC 12
[thirdparty/glibc.git] / configure.ac
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/], [glibc])
4 AC_CONFIG_SRCDIR([include/features.h])
5 AC_CONFIG_HEADERS([config.h])
6 AC_CONFIG_AUX_DIR([scripts])
7
8 ACX_PKGVERSION([GNU libc])
9 ACX_BUGURL([http://www.gnu.org/software/libc/bugs.html])
10 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"],
11 [Package description])
12 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"],
13 [Bug reporting address])
14
15 # Glibc should not depend on any header files
16 AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
17 [m4_divert_text([DEFAULTS],
18 [ac_includes_default='/* none */'])])
19
20 # We require GCC, and by default use its preprocessor. Override AC_PROG_CPP
21 # here to work around the Autoconf issue discussed in
22 # <https://sourceware.org/ml/libc-alpha/2013-01/msg00721.html>.
23 AC_DEFUN([AC_PROG_CPP],
24 [AC_REQUIRE([AC_PROG_CC])dnl
25 AC_ARG_VAR([CPP], [C preprocessor])dnl
26 _AC_ARG_VAR_CPPFLAGS()dnl
27 # On Suns, sometimes $CPP names a directory.
28 if test -n "$CPP" && test -d "$CPP"; then
29 CPP=
30 fi
31 if test -z "$CPP"; then
32 CPP="$CC -E"
33 fi
34 AC_SUBST(CPP)dnl
35 ])# AC_PROG_CPP
36
37 # We require GCC. Override _AC_PROG_CC_C89 here to work around the Autoconf
38 # issue discussed in
39 # <https://sourceware.org/ml/libc-alpha/2013-01/msg00757.html>.
40 AC_DEFUN([_AC_PROG_CC_C89], [[$1]])
41
42 dnl This is here so we can set $subdirs directly based on configure fragments.
43 AC_CONFIG_SUBDIRS()
44
45 AC_CANONICAL_HOST
46
47 AC_PROG_CC
48 if test $host != $build; then
49 AC_CHECK_PROGS(BUILD_CC, gcc cc)
50 fi
51 AC_SUBST(cross_compiling)
52 AC_PROG_CPP
53 AC_CHECK_TOOL(READELF, readelf, false)
54
55 # We need the C++ compiler only for testing.
56 AC_PROG_CXX
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
59 AC_LANG_PUSH([C++])
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])
64 # Static case.
65 old_LDFLAGS="$LDFLAGS"
66 LDFLAGS="$LDFLAGS -static"
67 AC_LINK_IFELSE([AC_LANG_SOURCE([
68 #include <iostream>
69
70 int
71 main()
72 {
73 std::cout << "Hello, world!";
74 return 0;
75 }
76 ])],
77 [],
78 [libc_cv_cxx_link_ok=no])
79 LDFLAGS="$old_LDFLAGS"
80 AC_LANG_POP([C++])])
81 AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
82
83 if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
84 AC_MSG_ERROR([you must configure in a separate build directory])
85 fi
86
87 # This will get text that should go into config.make.
88 config_vars=
89
90 # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
91 AC_ARG_WITH([gd],
92 AC_HELP_STRING([--with-gd=DIR],
93 [find libgd include dir and library with prefix DIR]),
94 [dnl
95 case "$with_gd" in
96 yes|''|no) ;;
97 *) libgd_include="-I$withval/include"
98 libgd_ldflags="-L$withval/lib" ;;
99 esac
100 ])
101 AC_ARG_WITH([gd-include],
102 AC_HELP_STRING([--with-gd-include=DIR],
103 [find libgd include files in DIR]),
104 [dnl
105 case "$with_gd_include" in
106 ''|no) ;;
107 *) libgd_include="-I$withval" ;;
108 esac
109 ])
110 AC_ARG_WITH([gd-lib],
111 AC_HELP_STRING([--with-gd-lib=DIR],
112 [find libgd library files in DIR]),
113 [dnl
114 case "$with_gd_lib" in
115 ''|no) ;;
116 *) libgd_ldflags="-L$withval" ;;
117 esac
118 ])
119
120 if test -n "$libgd_include"; then
121 config_vars="$config_vars
122 CFLAGS-memusagestat.c = $libgd_include"
123 fi
124 if test -n "$libgd_ldflags"; then
125 config_vars="$config_vars
126 libgd-LDFLAGS = $libgd_ldflags"
127 fi
128
129 dnl Arguments to specify presence of other packages/features.
130 AC_ARG_WITH([binutils],
131 AC_HELP_STRING([--with-binutils=PATH],
132 [specify location of binutils (as and ld)]),
133 [path_binutils=$withval],
134 [path_binutils=''])
135 AC_ARG_WITH([selinux],
136 AC_HELP_STRING([--with-selinux],
137 [if building with SELinux support]),
138 [with_selinux=$withval],
139 [with_selinux=auto])
140 dnl This is a temporary hack, to help sort out wired-in GCC assumptions.
141 AC_ARG_WITH([clang],
142 AC_HELP_STRING([--with-clang],
143 [if building with clang (temporary)]),
144 [with_clang=$withval],
145 [with_clang=no])
146 LIBC_CONFIG_VAR([with-clang], [$with_clang])
147 dnl This is a temporary hack, to help with BFD LD vs LLD debugging.
148 AC_ARG_WITH([lld],
149 AC_HELP_STRING([--with-lld],
150 [if building/linking with lld (temporary)]),
151 [with_lld=$withval],
152 [with_lld=no])
153 LIBC_CONFIG_VAR([with-lld], [$with_lld])
154
155 AC_ARG_WITH([headers],
156 AC_HELP_STRING([--with-headers=PATH],
157 [location of system headers to use
158 (for example /usr/src/linux/include)
159 @<:@default=compiler default@:>@]),
160 [sysheaders=$withval],
161 [sysheaders=''])
162 AC_SUBST(sysheaders)
163
164 AC_SUBST(use_default_link)
165 AC_ARG_WITH([default-link],
166 AC_HELP_STRING([--with-default-link],
167 [do not use explicit linker scripts]),
168 [use_default_link=$withval],
169 [use_default_link=default])
170
171 AC_ARG_ENABLE([sanity-checks],
172 AC_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],
175 [enable_sanity=yes])
176
177 AC_ARG_ENABLE([shared],
178 AC_HELP_STRING([--enable-shared],
179 [build shared library @<:@default=yes if GNU ld@:>@]),
180 [shared=$enableval],
181 [shared=yes])
182 AC_ARG_ENABLE([profile],
183 AC_HELP_STRING([--enable-profile],
184 [build profiled library @<:@default=no@:>@]),
185 [profile=$enableval],
186 [profile=no])
187 AC_ARG_ENABLE([static-pie],
188 AC_HELP_STRING([--enable-static-pie],
189 [enable static PIE support and use it in the testsuite @<:@default=no@:>@]),
190 [static_pie=$enableval],
191 [static_pie=no])
192 AC_ARG_ENABLE([timezone-tools],
193 AC_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)
198
199 AC_ARG_ENABLE([hardcoded-path-in-tests],
200 AC_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)
205
206 AC_ARG_ENABLE([stackguard-randomization],
207 AC_HELP_STRING([--enable-stackguard-randomization],
208 [initialize __stack_chk_guard canary with a random number at program start]),
209 [enable_stackguard_randomize=$enableval],
210 [enable_stackguard_randomize=no])
211 if test "$enable_stackguard_randomize" = yes; then
212 AC_DEFINE(ENABLE_STACKGUARD_RANDOMIZE)
213 fi
214
215 AC_ARG_ENABLE([hidden-plt],
216 AC_HELP_STRING([--disable-hidden-plt],
217 [do not hide internal function calls to avoid PLT]),
218 [hidden=$enableval],
219 [hidden=yes])
220 if test "x$hidden" = xno; then
221 AC_DEFINE(NO_HIDDEN)
222 fi
223
224 AC_ARG_ENABLE([bind-now],
225 AC_HELP_STRING([--enable-bind-now],
226 [disable lazy relocations in DSOs]),
227 [bindnow=$enableval],
228 [bindnow=no])
229 AC_SUBST(bindnow)
230 if test "x$bindnow" = xyes; then
231 AC_DEFINE(BIND_NOW)
232 fi
233
234 dnl Build glibc with -fstack-protector, -fstack-protector-all, or
235 dnl -fstack-protector-strong.
236 AC_ARG_ENABLE([stack-protector],
237 AC_HELP_STRING([--enable-stack-protector=@<:@yes|no|all|strong@:>@],
238 [Use -fstack-protector[-all|-strong] to detect glibc buffer overflows]),
239 [enable_stack_protector=$enableval],
240 [enable_stack_protector=no])
241 case "$enable_stack_protector" in
242 all|yes|no|strong) ;;
243 *) AC_MSG_ERROR([Not a valid argument for --enable-stack-protector: \"$enable_stack_protector\"]);;
244 esac
245
246 dnl On some platforms we cannot use dynamic loading. We must provide
247 dnl static NSS modules.
248 AC_ARG_ENABLE([static-nss],
249 AC_HELP_STRING([--enable-static-nss],
250 [build static NSS modules @<:@default=no@:>@]),
251 [static_nss=$enableval],
252 [static_nss=no])
253 dnl Enable static NSS also if we build no shared objects.
254 if test x"$static_nss" = xyes || test x"$shared" = xno; then
255 static_nss=yes
256 AC_DEFINE(DO_STATIC_NSS)
257 fi
258
259 AC_ARG_ENABLE([force-install],
260 AC_HELP_STRING([--disable-force-install],
261 [don't force installation of files from this package, even if they are older than the installed files]),
262 [force_install=$enableval],
263 [force_install=yes])
264 AC_SUBST(force_install)
265
266 AC_ARG_ENABLE([maintainer-mode],
267 AC_HELP_STRING([--enable-maintainer-mode],
268 [enable make rules and dependencies not useful (and sometimes confusing) to the casual installer]),
269 [maintainer=$enableval],
270 [maintainer=no])
271
272 dnl On some platforms we allow dropping compatibility with all kernel
273 dnl versions.
274 AC_ARG_ENABLE([kernel],
275 AC_HELP_STRING([--enable-kernel=VERSION],
276 [compile for compatibility with kernel not older than VERSION]),
277 [minimum_kernel=$enableval],
278 [])
279 dnl Prevent unreasonable values.
280 if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
281 # Better nothing than this.
282 minimum_kernel=""
283 else
284 if test "$minimum_kernel" = current; then
285 minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
286 fi
287 fi
288
289 dnl For the development we sometimes want gcc to issue even more warnings.
290 dnl This is not the default since many of the extra warnings are not
291 dnl appropriate.
292 AC_ARG_ENABLE([all-warnings],
293 AC_HELP_STRING([--enable-all-warnings],
294 [enable all useful warnings gcc can issue]),
295 [all_warnings=$enableval],
296 [])
297 AC_SUBST(all_warnings)
298
299 AC_ARG_ENABLE([werror],
300 AC_HELP_STRING([--disable-werror],
301 [do not build with -Werror]),
302 [enable_werror=$enableval],
303 [enable_werror=yes])
304 AC_SUBST(enable_werror)
305
306 AC_ARG_ENABLE([multi-arch],
307 AC_HELP_STRING([--enable-multi-arch],
308 [enable single DSO with optimizations for multiple architectures]),
309 [multi_arch=$enableval],
310 [multi_arch=default])
311
312 AC_ARG_ENABLE([experimental-malloc],
313 AC_HELP_STRING([--disable-experimental-malloc],
314 [disable experimental malloc features]),
315 [experimental_malloc=$enableval],
316 [experimental_malloc=yes])
317 AC_SUBST(experimental_malloc)
318
319 AC_ARG_ENABLE([nss-crypt],
320 AC_HELP_STRING([--enable-nss-crypt],
321 [enable libcrypt to use nss]),
322 [nss_crypt=$enableval],
323 [nss_crypt=no])
324 if test x$nss_crypt = xyes; then
325 nss_includes=-I$(nss-config --includedir 2>/dev/null)
326 if test $? -ne 0; then
327 AC_MSG_ERROR([cannot find include directory with nss-config])
328 fi
329 nspr_includes=-I$(nspr-config --includedir 2>/dev/null)
330 if test $? -ne 0; then
331 AC_MSG_ERROR([cannot find include directory with nspr-config])
332 fi
333 old_CFLAGS="$CFLAGS"
334 CFLAGS="$CFLAGS $nss_includes $nspr_includes"
335 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
336 #include <hasht.h>
337 #include <nsslowhash.h>
338 void f (void) { NSSLOW_Init (); }])],
339 libc_cv_nss_crypt=yes,
340 AC_MSG_ERROR([
341 cannot find NSS headers with lowlevel hash function interfaces]))
342 old_LIBS="$LIBS"
343 old_LDFLAGS="$LDFLAGS"
344 LIBS="$LIBS -lfreebl3"
345 AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
346 #include <hasht.h>
347 #include <nsslowhash.h>],
348 [NSSLOW_Init();])],
349 libc_cv_nss_crypt=yes,
350 AC_MSG_ERROR([
351 cannot link program using lowlevel NSS hash functions]))
352 # Check to see if there is a static NSS cryptographic library.
353 # If there isn't then we can't link anything with libcrypt.a,
354 # and that might mean disabling some static tests.
355 LDFLAGS="$LDFLAGS -static"
356 AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
357 #include <hasht.h>
358 #include <nsslowhash.h>],
359 [NSSLOW_Init();])],
360 libc_cv_static_nss_crypt=yes,
361 libc_cv_static_nss_crypt=no)
362 LDFLAGS="$old_LDFLAGS"
363 CFLAGS="$old_CFLAGS"
364 LIBS="$old_LIBS"
365 else
366 libc_cv_nss_crypt=no
367 libc_cv_static_nss_crypt=no
368 fi
369 AC_SUBST(libc_cv_nss_crypt)
370 AC_SUBST(libc_cv_static_nss_crypt)
371
372
373 AC_ARG_ENABLE([obsolete-rpc],
374 AC_HELP_STRING([--enable-obsolete-rpc],
375 [build and install the obsolete RPC code for link-time usage]),
376 [link_obsolete_rpc=$enableval],
377 [link_obsolete_rpc=no])
378 AC_SUBST(link_obsolete_rpc)
379
380 if test "$link_obsolete_rpc" = yes; then
381 AC_DEFINE(LINK_OBSOLETE_RPC)
382 fi
383
384 AC_ARG_ENABLE([obsolete-nsl],
385 AC_HELP_STRING([--enable-obsolete-nsl],
386 [build and install the obsolete libnsl library and depending NSS modules]),
387 [build_obsolete_nsl=$enableval],
388 [build_obsolete_nsl=no])
389 AC_SUBST(build_obsolete_nsl)
390
391 if test "$build_obsolete_nsl" = yes; then
392 AC_DEFINE(LINK_OBSOLETE_NSL)
393 fi
394
395 AC_ARG_ENABLE([systemtap],
396 [AS_HELP_STRING([--enable-systemtap],
397 [enable systemtap static probe points @<:@default=no@:>@])],
398 [systemtap=$enableval],
399 [systemtap=no])
400 if test "x$systemtap" != xno; then
401 AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
402 old_CFLAGS="$CFLAGS"
403 CFLAGS="-std=gnu11 $CFLAGS"
404 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
405 void foo (int i, void *p)
406 {
407 asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
408 :: STAP_PROBE_ASM_OPERANDS (2, i, p));
409 }]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
410 CFLAGS="$old_CFLAGS"])
411 if test $libc_cv_sdt = yes; then
412 AC_DEFINE([USE_STAP_PROBE])
413 elif test "x$systemtap" != xauto; then
414 AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
415 fi
416 fi
417
418 AC_ARG_ENABLE([build-nscd],
419 [AS_HELP_STRING([--disable-build-nscd],
420 [disable building and installing the nscd daemon])],
421 [build_nscd=$enableval],
422 [build_nscd=default])
423 AC_SUBST(build_nscd)
424
425 # Note the use of $use_nscd is near the bottom of the file.
426 AC_ARG_ENABLE([nscd],
427 [AS_HELP_STRING([--disable-nscd],
428 [library functions will not contact the nscd daemon])],
429 [use_nscd=$enableval],
430 [use_nscd=yes])
431
432 AC_ARG_ENABLE([pt_chown],
433 [AS_HELP_STRING([--enable-pt_chown],
434 [Enable building and installing pt_chown])],
435 [build_pt_chown=$enableval],
436 [build_pt_chown=no])
437 AC_SUBST(build_pt_chown)
438 if test "$build_pt_chown" = yes; then
439 AC_DEFINE(HAVE_PT_CHOWN)
440 fi
441
442 AC_ARG_ENABLE([tunables],
443 [AS_HELP_STRING([--enable-tunables],
444 [Enable tunables support. Known values are 'yes', 'no' and 'valstring'])],
445 [have_tunables=$enableval],
446 [have_tunables=yes])
447 AC_SUBST(have_tunables)
448 if test "$have_tunables" = yes; then
449 AC_DEFINE(HAVE_TUNABLES)
450 fi
451
452 AC_ARG_ENABLE([float128],
453 AC_HELP_STRING([--disable-float128],
454 [disable float128 support]),
455 [enable_float128=$enableval],
456 [enable_float128=yes])
457 AC_SUBST(enable_float128)
458 if test "$enable_float128" = yes; then
459 AC_DEFINE(WANT_FLOAT128)
460 fi
461
462 # The abi-tags file uses a fairly simplistic model for name recognition that
463 # can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
464 # $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
465 # This doesn't get used much beyond that, so it's fairly safe.
466 case "$host_os" in
467 linux*)
468 ;;
469 gnu*)
470 host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
471 ;;
472 esac
473
474 AC_ARG_ENABLE([mathvec],
475 [AS_HELP_STRING([--enable-mathvec],
476 [Enable building and installing mathvec @<:@default depends on architecture@:>@])],
477 [build_mathvec=$enableval],
478 [build_mathvec=notset])
479
480 # We keep the original values in `$config_*' and never modify them, so we
481 # can write them unchanged into config.make. Everything else uses
482 # $machine, $vendor, and $os, and changes them whenever convenient.
483 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
484
485 # Don't allow vendor == "unknown"
486 test "$config_vendor" = unknown && config_vendor=
487 config_os="`echo $config_os | sed 's/^unknown-//'`"
488
489 # Some configurations imply other options.
490 elf=yes
491
492 # The configure fragment of a port can modify these to supplement
493 # or override the table in the case statement below. No fragment should
494 # ever change the config_* variables, however.
495 machine=$config_machine
496 vendor=$config_vendor
497 os=$config_os
498 base_os=''
499
500 submachine=
501 AC_ARG_WITH([cpu],
502 AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
503 [dnl
504 case "$withval" in
505 yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
506 no) ;;
507 *) submachine="$withval" ;;
508 esac
509 ])
510
511 # An preconfigure script can set this when it wants to disable the sanity
512 # check below.
513 libc_config_ok=no
514
515 # A preconfigure script for a system that may or may not use fpu
516 # sysdeps directories sets this to a preprocessor conditional for
517 # whether to use such directories.
518 with_fp_cond=1
519
520 dnl Let sysdeps/*/preconfigure act here.
521 LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
522
523
524 ###
525 ### By using the undocumented --enable-hacker-mode option for configure
526 ### one can skip this test to make the configuration not fail for unsupported
527 ### platforms.
528 ###
529 if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
530 case "$machine-$host_os" in
531 *-linux* | *-gnu*)
532 ;;
533 *)
534 AC_MSG_ERROR([
535 *** The GNU C library is currently unavailable for this platform.
536 *** If you are interested in seeing glibc on this platform visit
537 *** the "How to submit a new port" in the wiki:
538 *** https://sourceware.org/glibc/wiki/#Development
539 *** and join the community!])
540 ;;
541 esac
542 fi
543
544 # Set base_machine if not set by a preconfigure fragment.
545 test -n "$base_machine" || base_machine=$machine
546 AC_SUBST(base_machine)
547
548 # Determine whether to use fpu or nofpu sysdeps directories.
549 AC_CACHE_CHECK([for use of fpu sysdeps directories],
550 libc_cv_with_fp, [dnl
551 cat > conftest.c <<EOF
552 #if $with_fp_cond
553 int dummy;
554 #else
555 # error "no hardware floating point"
556 #endif
557 EOF
558 libc_cv_with_fp=no
559 if ${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c -o conftest.s \
560 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
561 libc_cv_with_fp=yes
562 fi
563 rm -f conftest*])
564 AC_SUBST(libc_cv_with_fp)
565
566 AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
567 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
568 [libc_cv_ssp=yes],
569 [libc_cv_ssp=no])
570 ])
571
572 AC_CACHE_CHECK(for -fstack-protector-strong, libc_cv_ssp_strong, [dnl
573 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-strong],
574 [libc_cv_ssp_strong=yes],
575 [libc_cv_ssp_strong=no])
576 ])
577
578 AC_CACHE_CHECK(for -fstack-protector-all, libc_cv_ssp_all, [dnl
579 LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-all],
580 [libc_cv_ssp_all=yes],
581 [libc_cv_ssp_all=no])
582 ])
583
584 stack_protector=
585 no_stack_protector=
586 if test "$libc_cv_ssp" = yes; then
587 no_stack_protector="-fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0"
588 AC_DEFINE(HAVE_CC_NO_STACK_PROTECTOR)
589 fi
590
591 if test "$enable_stack_protector" = yes && test "$libc_cv_ssp" = yes; then
592 stack_protector="-fstack-protector"
593 AC_DEFINE(STACK_PROTECTOR_LEVEL, 1)
594 elif test "$enable_stack_protector" = all && test "$libc_cv_ssp_all" = yes; then
595 stack_protector="-fstack-protector-all"
596 AC_DEFINE(STACK_PROTECTOR_LEVEL, 2)
597 elif test "$enable_stack_protector" = strong && test "$libc_cv_ssp_strong" = yes; then
598 stack_protector="-fstack-protector-strong"
599 AC_DEFINE(STACK_PROTECTOR_LEVEL, 3)
600 else
601 stack_protector="-fno-stack-protector"
602 AC_DEFINE(STACK_PROTECTOR_LEVEL, 0)
603 fi
604 AC_SUBST(libc_cv_ssp)
605 AC_SUBST(stack_protector)
606 AC_SUBST(no_stack_protector)
607
608 if test -n "$stack_protector"; then
609 dnl Don't run configure tests with stack-protection on, to avoid problems with
610 dnl bootstrapping.
611 no_ssp=-fno-stack-protector
612 else
613 no_ssp=
614
615 if test "$enable_stack_protector" != no; then
616 AC_MSG_ERROR([--enable-stack-protector=$enable_stack_protector specified, but specified level of stack protection is not supported by the compiler.])
617 fi
618 fi
619
620 # For the multi-arch option we need support in the assembler & linker.
621 AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
622 libc_cv_ld_gnu_indirect_function, [dnl
623 cat > conftest.S <<EOF
624 .type foo,%gnu_indirect_function
625 foo:
626 .globl _start
627 _start:
628 .globl __start
629 __start:
630 .data
631 #ifdef _LP64
632 .quad foo
633 #else
634 .long foo
635 #endif
636 EOF
637 libc_cv_ld_gnu_indirect_function=no
638 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
639 -nostartfiles -nostdlib $no_ssp \
640 -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
641 # Do a link to see if the backend supports IFUNC relocs.
642 $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
643 LC_ALL=C $READELF -r conftest | grep 'no relocations' >/dev/null || {
644 libc_cv_ld_gnu_indirect_function=yes
645 }
646 fi
647 rm -f conftest*])
648
649 # Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
650 AC_CACHE_CHECK([for gcc attribute ifunc support],
651 libc_cv_gcc_indirect_function, [dnl
652 cat > conftest.c <<EOF
653 extern int func (int);
654 int used_func (int a)
655 {
656 return a;
657 }
658 static void *resolver ()
659 {
660 return &used_func;
661 }
662 extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
663 EOF
664 libc_cv_gcc_indirect_function=no
665 if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
666 2>&AS_MESSAGE_LOG_FD ; then
667 if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&AS_MESSAGE_LOG_FD; then
668 libc_cv_gcc_indirect_function=yes
669 fi
670 fi
671 rm -f conftest*])
672
673 # Check if CC supports attribute retain as it is used in attribute_used_retain macro.
674 AC_CACHE_CHECK([for GNU attribute retain support],
675 libc_cv_gnu_retain, [dnl
676 cat > conftest.c <<EOF
677 static int var __attribute__ ((used, retain, section ("__libc_atexit")));
678 EOF
679 libc_cv_gnu_retain=no
680 if ${CC-cc} -Werror -c conftest.c -o /dev/null 1>&AS_MESSAGE_LOG_FD \
681 2>&AS_MESSAGE_LOG_FD ; then
682 libc_cv_gnu_retain=yes
683 fi
684 rm -f conftest*])
685 if test $libc_cv_gnu_retain = yes; then
686 AC_DEFINE(HAVE_GNU_RETAIN)
687 fi
688 LIBC_CONFIG_VAR([have-gnu-retain], [$libc_cv_gnu_retain])
689
690 # Check if gcc warns about alias for function with incompatible types.
691 AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
692 libc_cv_gcc_incompatible_alias, [dnl
693 cat > conftest.c <<EOF
694 int __redirect_foo (const void *s, int c);
695
696 __typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
697 __typeof (__redirect_foo) *foo_impl (void)
698 {
699 return 0;
700 }
701
702 extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
703 EOF
704 libc_cv_gcc_incompatible_alias=yes
705 if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
706 libc_cv_gcc_incompatible_alias=no
707 fi
708 rm -f conftest*])
709
710 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
711 if test x"$multi_arch" = xyes; then
712 AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
713 else
714 multi_arch=no
715 fi
716 fi
717 if test x"$libc_cv_gcc_indirect_function" != xyes; then
718 # GCC 8+ emits a warning for alias with incompatible types and it might
719 # fail to build ifunc resolvers aliases to either weak or internal
720 # symbols. Disables multiarch build in this case.
721 if test x"$libc_cv_gcc_incompatible_alias" == xyes; then
722 AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types])
723 if test x"$multi_arch" = xyes; then
724 AC_MSG_ERROR([--enable-multi-arch support requires a gcc with gnu-indirect-function support])
725 fi
726 AC_MSG_WARN([Multi-arch is disabled.])
727 multi_arch=no
728 elif test x"$multi_arch" = xyes; then
729 AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
730 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
731 fi
732 fi
733 multi_arch_d=
734 if test x"$multi_arch" != xno; then
735 multi_arch_d=/multiarch
736 fi
737
738 # Compute the list of sysdep directories for this configuration.
739 # This can take a while to compute.
740 sysdep_dir=$srcdir/sysdeps
741 AC_MSG_CHECKING(sysdep dirs)
742 dnl We need to use [ and ] for other purposes for a while now.
743 changequote(,)dnl
744 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
745 os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
746
747 test "x$base_os" != x || case "$os" in
748 gnu*)
749 base_os=mach/hurd ;;
750 linux*)
751 base_os=unix/sysv ;;
752 esac
753
754 # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
755 tail=$os
756 ostry=$os
757 while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
758 ostry="$ostry /$o"
759 tail=$o
760 done
761 o=`echo $tail | sed 's/[0-9]*$//'`
762 if test $o != $tail; then
763 ostry="$ostry /$o"
764 fi
765 # For linux-gnu, try linux-gnu, then linux.
766 o=`echo $tail | sed 's/-.*$//'`
767 if test $o != $tail; then
768 ostry="$ostry /$o"
769 fi
770
771 # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
772 base=
773 tail=$base_os
774 while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
775 set $b
776 base="$base /$1"
777 tail="$2"
778 done
779
780 # For sparc/sparc32, try sparc/sparc32 and then sparc.
781 mach=
782 tail=$machine${submachine:+/$submachine}
783 while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
784 set $m
785 # Prepend the machine's FPU directory unless --without-fp.
786 if test "$libc_cv_with_fp" = yes; then
787 maybe_fpu=/fpu
788 else
789 maybe_fpu=/nofpu
790 fi
791 # For each machine term, try it with and then without /multiarch.
792 for try_fpu in $maybe_fpu ''; do
793 for try_multi in $multi_arch_d ''; do
794 mach="$mach /$1$try_fpu$try_multi"
795 done
796 done
797 tail="$2"
798 done
799
800 dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
801 changequote([,])dnl
802
803 # Find what sysdep directories exist.
804 sysnames=
805 for b in $base ''; do
806 for m0 in $mach ''; do
807 for v in /$vendor ''; do
808 test "$v" = / && continue
809 for o in /$ostry ''; do
810 test "$o" = / && continue
811 for m in $mach ''; do
812 try_suffix="$m0$b$v$o$m"
813 if test -n "$try_suffix"; then
814 try_srcdir="${srcdir}/"
815 try="sysdeps$try_suffix"
816 test -n "$enable_debug_configure" &&
817 echo "$0 [DEBUG]: try $try" >&2
818 if test -d "$try_srcdir$try"; then
819 sysnames="$sysnames $try"
820 { test -n "$o" || test -n "$b"; } && os_used=t
821 { test -n "$m" || test -n "$m0"; } && machine_used=t
822 case x${m0:-$m} in
823 x*/$submachine) submachine_used=t ;;
824 esac
825 fi
826 fi
827 done
828 done
829 done
830 done
831 done
832
833 # If the assembler supports gnu_indirect_function symbol type and the
834 # architecture supports multi-arch, we enable multi-arch by default.
835 case $sysnames in
836 *"$multi_arch_d"*)
837 ;;
838 *)
839 test x"$multi_arch" = xdefault && multi_arch=no
840 ;;
841 esac
842 if test x"$multi_arch" != xno; then
843 AC_DEFINE(USE_MULTIARCH)
844 fi
845 AC_SUBST(multi_arch)
846
847 if test -z "$os_used" && test "$os" != none; then
848 AC_MSG_ERROR(Operating system $os is not supported.)
849 fi
850 if test -z "$machine_used" && test "$machine" != none; then
851 AC_MSG_ERROR(The $machine is not supported.)
852 fi
853 if test -z "$submachine_used" && test -n "$submachine"; then
854 AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
855 fi
856 AC_SUBST(submachine)
857
858 # We have now validated the configuration.
859
860 # Expand the list of system names into a full list of directories
861 # from each element's parent name and Implies file (if present).
862 set $sysnames
863 names=
864 while test $# -gt 0; do
865 name=$1
866 shift
867
868 case " $names " in *" $name "*)
869 # Already in the list.
870 continue
871 esac
872
873 # Report each name as we discover it, so there is no long pause in output.
874 echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
875
876 name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
877
878 case $name in
879 /*) xsrcdir= ;;
880 *) xsrcdir=$srcdir/ ;;
881 esac
882 test -n "$enable_debug_configure" &&
883 echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
884
885 for implies_file in Implies Implies-before Implies-after; do
886 implies_type=`echo $implies_file | sed s/-/_/`
887 eval ${implies_type}=
888 if test -f $xsrcdir$name/$implies_file; then
889 # Collect more names from the `Implies' file (removing comments).
890 implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/$implies_file`"
891 for x in $implied_candidate; do
892 found=no
893 if test -d $xsrcdir$name_base/$x; then
894 eval "${implies_type}=\"\$${implies_type} \$name_base/\$x\""
895 found=yes
896 fi
897 try="sysdeps/$x"
898 try_srcdir=$srcdir/
899 test -n "$enable_debug_configure" &&
900 echo "[DEBUG]: $name $implies_file $x try() {$try_srcdir}$try" >&2
901 if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
902 then
903 eval "${implies_type}=\"\$${implies_type} \$try\""
904 found=yes
905 fi
906 if test $found = no; then
907 AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
908 fi
909 done
910 fi
911 done
912
913 # Add NAME to the list of names.
914 names="$names $name"
915
916 # Find the parent of NAME, using the empty string if it has none.
917 changequote(,)dnl
918 parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
919 changequote([,])dnl
920
921 test -n "$enable_debug_configure" &&
922 echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
923 Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
924
925 # Add the names implied by NAME, and NAME's parent (if it has one), to
926 # the list of names to be processed (the argument list). We prepend the
927 # implied names to the list and append the parent. We want implied
928 # directories to come before further directories inferred from the
929 # configuration components; this ensures that for sysv4, unix/common
930 # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
931 # after sysv4).
932 sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
933 test -n "$sysnames" && set $sysnames
934 done
935
936 # Add the default directories.
937 default_sysnames="sysdeps/generic"
938 sysnames="$names $default_sysnames"
939 AC_SUBST(sysnames)
940 # The other names were emitted during the scan.
941 AC_MSG_RESULT($default_sysnames)
942
943
944 ### Locate tools.
945
946 AC_PROG_INSTALL
947 if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
948 # The makefiles need to use a different form to find it in $srcdir.
949 INSTALL='\$(..)./scripts/install-sh -c'
950 fi
951 AC_PROG_LN_S
952
953 LIBC_PROG_BINUTILS
954
955 if test "$with_clang" = no; then
956 # Accept binutils 2.25 or newer.
957 AC_CHECK_PROG_VER(AS, $AS, --version,
958 [GNU assembler.* \([0-9]*\.[0-9.]*\)],
959 [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
960 AS=: critic_missing="$critic_missing as")
961 fi
962
963 if test "$with_lld" = no; then
964 if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
965 # Accept gold 1.14 or higher
966 AC_CHECK_PROG_VER(LD, $LD, --version,
967 [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
968 [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
969 LD=: critic_missing="$critic_missing GNU gold")
970 else
971 AC_CHECK_PROG_VER(LD, $LD, --version,
972 [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
973 [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
974 LD=: critic_missing="$critic_missing GNU ld")
975 fi
976 fi
977
978 # These programs are version sensitive.
979 AC_CHECK_TOOL_PREFIX
980 AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
981 [GNU Make[^0-9]*\([0-9][0-9.]*\)],
982 [3.79* | 3.[89]* | [4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
983
984 AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
985 [GNU gettext.* \([0-9]*\.[0-9.]*\)],
986 [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
987 MSGFMT=: aux_missing="$aux_missing msgfmt")
988 AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
989 [GNU texinfo.* \([0-9][0-9.]*\)],
990 [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
991 MAKEINFO=: aux_missing="$aux_missing makeinfo")
992 AC_CHECK_PROG_VER(SED, sed, --version,
993 [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
994 [3.0[2-9]*|3.[1-9]*|[4-9]*],
995 SED=: aux_missing="$aux_missing sed")
996 AC_CHECK_PROG_VER(AWK, gawk, --version,
997 [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
998 [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
999 AC_CHECK_PROG_VER(BISON, bison, --version,
1000 [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
1001 [2.7*|[3-9].*|[1-9][0-9]*], critic_missing="$critic_missing bison")
1002
1003 AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
1004 AC_TRY_COMPILE([], [
1005 #if !defined __GNUC__ || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)
1006 #if !defined __clang__
1007 #error insufficient compiler
1008 #endif
1009 #endif],
1010 [libc_cv_compiler_ok=yes],
1011 [libc_cv_compiler_ok=no])])
1012 AS_IF([test $libc_cv_compiler_ok != yes],
1013 [critic_missing="$critic_missing compiler"])
1014
1015 AC_CHECK_TOOL(NM, nm, false)
1016
1017 if test "x$maintainer" = "xyes"; then
1018 AC_CHECK_PROGS(AUTOCONF, autoconf, no)
1019 case "x$AUTOCONF" in
1020 xno|x|x:) AUTOCONF=no ;;
1021 *)
1022 AC_CACHE_CHECK(dnl
1023 whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
1024 if (cd $srcdir; $AUTOCONF $ACFLAGS configure.ac > /dev/null 2>&1); then
1025 libc_cv_autoconf_works=yes
1026 else
1027 libc_cv_autoconf_works=no
1028 fi])
1029 test $libc_cv_autoconf_works = yes || AUTOCONF=no
1030 ;;
1031 esac
1032 if test "x$AUTOCONF" = xno; then
1033 aux_missing="$aux_missing autoconf"
1034 fi
1035 else
1036 AUTOCONF=no
1037 fi
1038
1039 # Check for python3 if available, or else python.
1040 AC_CHECK_PROGS(PYTHON_PROG, python3 python,no)
1041 case "x$PYTHON_PROG" in
1042 xno|x|x:) PYTHON_PROG=no ;;
1043 *) ;;
1044 esac
1045
1046 if test "x$PYTHON_PROG" = xno; then
1047 aux_missing="$aux_missing python"
1048 else
1049 PYTHON="$PYTHON_PROG -B"
1050 AC_SUBST(PYTHON)
1051 fi
1052
1053 test -n "$critic_missing" && AC_MSG_ERROR([
1054 *** These critical programs are missing or too old:$critic_missing
1055 *** Check the INSTALL file for required versions.])
1056
1057 test -n "$aux_missing" && AC_MSG_WARN([
1058 *** These auxiliary programs are missing or incompatible versions:$aux_missing
1059 *** some features or tests will be disabled.
1060 *** Check the INSTALL file for required versions.])
1061
1062 # if using special system headers, find out the compiler's sekrit
1063 # header directory and add that to the list. NOTE: Only does the right
1064 # thing on a system that doesn't need fixincludes. (Not presently a problem.)
1065 if test -n "$sysheaders"; then
1066 SYSINCLUDES=-nostdinc
1067 for d in include include-fixed; do
1068 i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
1069 SYSINCLUDES="$SYSINCLUDES -isystem $i"
1070 done
1071 SYSINCLUDES="$SYSINCLUDES \
1072 -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
1073 if test -n "$CXX"; then
1074 CXX_SYSINCLUDES=
1075 for cxxheaders in `$CXX -v -S -x c++ /dev/null -o /dev/null 2>&1 \
1076 | sed -n -e '1,/#include/d' -e 's/^ \(\/.*\/[cg]++\)/\1/p'`; do
1077 test "x$cxxheaders" != x &&
1078 CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders"
1079 done
1080 fi
1081 fi
1082 AC_SUBST(SYSINCLUDES)
1083 AC_SUBST(CXX_SYSINCLUDES)
1084
1085 # Obtain some C++ header file paths. This is used to make a local
1086 # copy of those headers in Makerules.
1087 changequote(,)dnl
1088 if test -n "$CXX"; then
1089 # In theory the clang and gcc regexes can be merged, but the
1090 # result is incomprehensible.
1091 if test "$with_clang" != no; then
1092 find_cxx_header () {
1093 echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
1094 | sed -n "\,^[o.-]*[ :] /.*/$1 [\]$,{s,^[o.-]*[ :] /,/,;s/ [\]$//;p}"
1095 }
1096 else
1097 find_cxx_header () {
1098 echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
1099 | sed -n "\,$1:,{s/:\$//;p}"
1100 }
1101 fi
1102 CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
1103 CXX_CMATH_HEADER="$(find_cxx_header cmath)"
1104 CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
1105 fi
1106 changequote([,])dnl
1107 AC_SUBST(CXX_CSTDLIB_HEADER)
1108 AC_SUBST(CXX_CMATH_HEADER)
1109 AC_SUBST(CXX_BITS_STD_ABS_H)
1110
1111 # Test if LD_LIBRARY_PATH contains the notation for the current directory
1112 # since this would lead to problems installing/building glibc.
1113 # LD_LIBRARY_PATH contains the current directory if one of the following
1114 # is true:
1115 # - one of the terminals (":" and ";") is the first or last sign
1116 # - two terminals occur directly after each other
1117 # - the path contains an element with a dot in it
1118 AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
1119 changequote(,)dnl
1120 case ${LD_LIBRARY_PATH} in
1121 [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
1122 ld_library_path_setting="contains current directory"
1123 ;;
1124 *)
1125 ld_library_path_setting="ok"
1126 ;;
1127 esac
1128 changequote([,])dnl
1129 AC_MSG_RESULT($ld_library_path_setting)
1130 if test "$ld_library_path_setting" != "ok"; then
1131 AC_MSG_ERROR([
1132 *** LD_LIBRARY_PATH shouldn't contain the current directory when
1133 *** building glibc. Please change the environment variable
1134 *** and run configure again.])
1135 fi
1136
1137 AC_PATH_PROG(BASH_SHELL, bash, no)
1138
1139 AC_PATH_PROG(PERL, perl, no)
1140 if test "$PERL" != no &&
1141 (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
1142 PERL=no
1143 fi
1144 AC_PATH_PROG(INSTALL_INFO, install-info, no,
1145 $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
1146
1147 AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
1148 cat > conftest.s <<EOF
1149 .text
1150 foo:
1151 .set glibc_conftest_frobozz,foo
1152 .globl glibc_conftest_frobozz
1153 EOF
1154 # The alpha-dec-osf1 assembler gives only a warning for `.set'
1155 # (but it doesn't work), so we must do a linking check to be sure.
1156 cat > conftest1.c <<\EOF
1157 extern int glibc_conftest_frobozz;
1158 void _start() { glibc_conftest_frobozz = 1; }
1159 EOF
1160 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
1161 -nostartfiles -nostdlib $no_ssp \
1162 -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
1163 libc_cv_asm_set_directive=yes
1164 else
1165 libc_cv_asm_set_directive=no
1166 fi
1167 rm -f conftest*])
1168 if test $libc_cv_asm_set_directive = yes; then
1169 AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
1170 fi
1171
1172 AC_CACHE_CHECK(linker support for protected data symbol,
1173 libc_cv_protected_data,
1174 [cat > conftest.c <<EOF
1175 int bar __attribute__ ((visibility ("protected"))) = 1;
1176 EOF
1177 libc_cv_protected_data=no
1178 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -o conftest.so); then
1179 cat > conftest.c <<EOF
1180 extern int bar;
1181 int main (void) { return bar; }
1182 EOF
1183 if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp conftest.c -o conftest conftest.so); then
1184 libc_cv_protected_data=yes
1185 fi
1186 fi
1187 rm -f conftest.*
1188 ])
1189 AC_SUBST(libc_cv_protected_data)
1190
1191 AC_CACHE_CHECK(linker support for INSERT in linker script,
1192 libc_cv_insert,
1193 [cat > conftest.c <<EOF
1194 const int __attribute__ ((section(".bar"))) bar = 0x12345678;
1195 int test (void) { return bar; }
1196 EOF
1197 cat > conftest.t <<EOF
1198 SECTIONS
1199 {
1200 .bar : { *(.bar) }
1201 }
1202 INSERT AFTER .rela.dyn;
1203 EOF
1204 libc_cv_insert=no
1205 if AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -Wl,-T,conftest.t -o conftest.so]); then
1206 libc_cv_insert=yes
1207 fi
1208 rm -f conftest.*
1209 ])
1210 AC_SUBST(libc_cv_insert)
1211
1212 AC_CACHE_CHECK(for broken __attribute__((alias())),
1213 libc_cv_broken_alias_attribute,
1214 [cat > conftest.c <<EOF
1215 extern int foo (int x) __asm ("xyzzy");
1216 int bar (int x) { return x; }
1217 extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
1218 extern int dfoo;
1219 extern __typeof (dfoo) dfoo __asm ("abccb");
1220 int dfoo = 1;
1221 EOF
1222 libc_cv_broken_alias_attribute=yes
1223 if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
1224 if grep 'xyzzy' conftest.s >/dev/null &&
1225 grep 'abccb' conftest.s >/dev/null; then
1226 libc_cv_broken_alias_attribute=no
1227 fi
1228 fi
1229 rm -f conftest.c conftest.s
1230 ])
1231 if test $libc_cv_broken_alias_attribute = yes; then
1232 AC_MSG_ERROR(working alias attribute support required)
1233 fi
1234
1235 AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
1236 libc_cv_have_sdata_section,
1237 [echo "int i;" > conftest.c
1238 libc_cv_have_sdata_section=no
1239 if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
1240 | grep '\.sdata' >/dev/null; then
1241 libc_cv_have_sdata_section=yes
1242 fi
1243 rm -f conftest.c conftest.so
1244 ])
1245 if test $libc_cv_have_sdata_section = yes; then
1246 AC_DEFINE(HAVE_SDATA_SECTION)
1247 fi
1248
1249 AC_CACHE_CHECK(whether to use .ctors/.dtors header and trailer,
1250 libc_cv_ctors_header, [dnl
1251 libc_cv_ctors_header=yes
1252 LIBC_TRY_LINK_STATIC([
1253 __attribute__ ((constructor)) void ctor (void) { asm (""); }
1254 __attribute__ ((destructor)) void dtor (void) { asm (""); }
1255 ],
1256 [dnl
1257 AS_IF([$READELF -WS conftest$ac_exeext | $AWK '
1258 { gsub(/\@<:@ */, "@<:@") }
1259 $2 == ".ctors" || $2 == ".dtors" {
1260 size = strtonum("0x" $6)
1261 align = strtonum("0x" $NF)
1262 seen@<:@$2@:>@ = 1
1263 stub@<:@$2@:>@ = size == align * 2
1264 }
1265 END {
1266 ctors_ok = !seen@<:@".ctors"@:>@ || stub@<:@".ctors"@:>@
1267 dtors_ok = !seen@<:@".dtors"@:>@ || stub@<:@".dtors"@:>@
1268 exit ((ctors_ok && dtors_ok) ? 0 : 1)
1269 }
1270 '], [libc_cv_ctors_header=no])
1271 ], [dnl
1272 AC_MSG_ERROR([missing __attribute__ ((constructor)) support??])
1273 ])
1274 ])
1275 if test $libc_cv_ctors_header = no; then
1276 AC_DEFINE(NO_CTORS_DTORS_SECTIONS)
1277 fi
1278
1279 AC_CACHE_CHECK(for libunwind-support in compiler,
1280 libc_cv_cc_with_libunwind, [
1281 cat > conftest.c <<EOF
1282 int main (void) { return 0; }
1283 EOF
1284 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
1285 conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
1286 libc_cv_cc_with_libunwind=yes
1287 else
1288 libc_cv_cc_with_libunwind=no
1289 fi
1290 rm -f conftest*])
1291 AC_SUBST(libc_cv_cc_with_libunwind)
1292 if test $libc_cv_cc_with_libunwind = yes; then
1293 AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
1294 fi
1295
1296 ASFLAGS_config=
1297 AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
1298 libc_cv_as_noexecstack, [dnl
1299 cat > conftest.c <<EOF
1300 void foo (void) { }
1301 EOF
1302 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
1303 -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
1304 && grep .note.GNU-stack conftest.s >/dev/null \
1305 && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
1306 -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
1307 then
1308 libc_cv_as_noexecstack=yes
1309 else
1310 libc_cv_as_noexecstack=no
1311 fi
1312 rm -f conftest*])
1313 if test $libc_cv_as_noexecstack = yes; then
1314 ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
1315 fi
1316 AC_SUBST(ASFLAGS_config)
1317
1318 AC_CACHE_CHECK(for -z combreloc,
1319 libc_cv_z_combreloc, [dnl
1320 cat > conftest.c <<EOF
1321 extern int bar (int);
1322 extern int mumble;
1323 int foo (void) { return bar (mumble); }
1324 EOF
1325 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1326 -fPIC -shared $no_ssp -o conftest.so conftest.c
1327 -nostdlib -nostartfiles
1328 -Wl,-z,combreloc 1>&AS_MESSAGE_LOG_FD])
1329 then
1330 dnl The following test is a bit weak. We must use a tool which can test
1331 dnl cross-platform since the gcc used can be a cross compiler. Without
1332 dnl introducing new options this is not easily doable. Instead use a tool
1333 dnl which always is cross-platform: readelf. To detect whether -z combreloc
1334 dnl look for a section named .rel.dyn or .rela.dyn.
1335 if $READELF -S conftest.so | grep -E '.rela?.dyn' > /dev/null; then
1336 libc_cv_z_combreloc=yes
1337 else
1338 libc_cv_z_combreloc=no
1339 fi
1340 else
1341 libc_cv_z_combreloc=no
1342 fi
1343 rm -f conftest*])
1344 if test "$libc_cv_z_combreloc" = yes; then
1345 AC_DEFINE(HAVE_Z_COMBRELOC)
1346 fi
1347 AC_SUBST(libc_cv_z_combreloc)
1348
1349 LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
1350 [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
1351 AC_SUBST(libc_cv_z_execstack)
1352
1353 LIBC_LINKER_FEATURE([-z start-stop-gc], [-Wl,-z,start-stop-gc],
1354 [libc_cv_z_start_stop_gc=yes], [libc_cv_z_start_stop_gc=no])
1355 LIBC_CONFIG_VAR([have-z-start-stop-gc], [$libc_cv_z_start_stop_gc])
1356
1357 LIBC_LINKER_FEATURE([-z pack-relative-relocs],
1358 [-Wl,-z,pack-relative-relocs],
1359 [libc_cv_dt_relr=yes], [libc_cv_dt_relr=no])
1360 LIBC_CONFIG_VAR([have-dt-relr], [$libc_cv_dt_relr])
1361
1362 LIBC_LINKER_FEATURE([--no-dynamic-linker],
1363 [-Wl,--no-dynamic-linker],
1364 [libc_cv_no_dynamic_linker=yes],
1365 [libc_cv_no_dynamic_linker=no])
1366 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
1367
1368 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
1369 LIBC_TRY_CC_OPTION([-static-pie],
1370 [libc_cv_static_pie=yes],
1371 [libc_cv_static_pie=no])
1372 ])
1373 LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie])
1374
1375 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
1376 LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
1377 ])
1378
1379 AC_SUBST(libc_cv_fpie)
1380
1381 AC_CACHE_CHECK(for --hash-style option,
1382 libc_cv_hashstyle, [dnl
1383 cat > conftest.c <<EOF
1384 int _start (void) { return 42; }
1385 EOF
1386 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
1387 -fPIC -shared -o conftest.so conftest.c
1388 -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
1389 then
1390 libc_cv_hashstyle=yes
1391 else
1392 libc_cv_hashstyle=no
1393 fi
1394 rm -f conftest*])
1395 AC_SUBST(libc_cv_hashstyle)
1396
1397 # The linker's default -shared behavior is good enough if it
1398 # does these things that our custom linker scripts ensure that
1399 # all allocated NOTE sections come first.
1400 if test "$use_default_link" = default; then
1401 AC_CACHE_CHECK([for sufficient default -shared layout],
1402 libc_cv_use_default_link, [dnl
1403 libc_cv_use_default_link=no
1404 cat > conftest.s <<\EOF
1405 .section .note.a,"a",%note
1406 .balign 4
1407 .long 4,4,9
1408 .string "GNU"
1409 .string "foo"
1410 .section .note.b,"a",%note
1411 .balign 4
1412 .long 4,4,9
1413 .string "GNU"
1414 .string "bar"
1415 EOF
1416 if AC_TRY_COMMAND([dnl
1417 ${CC-cc} $ASFLAGS -shared -o conftest.so conftest.s 1>&AS_MESSAGE_LOG_FD]) &&
1418 ac_try=`$READELF -S conftest.so | sed -n \
1419 ['${x;p;}
1420 s/^ *\[ *[1-9][0-9]*\] *\([^ ][^ ]*\) *\([^ ][^ ]*\) .*$/\2 \1/
1421 t a
1422 b
1423 : a
1424 H']`
1425 then
1426 libc_seen_a=no libc_seen_b=no
1427 set -- $ac_try
1428 while test $# -ge 2 -a "$1" = NOTE; do
1429 case "$2" in
1430 .note.a) libc_seen_a=yes ;;
1431 .note.b) libc_seen_b=yes ;;
1432 esac
1433 shift 2
1434 done
1435 case "$libc_seen_a$libc_seen_b" in
1436 yesyes)
1437 libc_cv_use_default_link=yes
1438 ;;
1439 *)
1440 echo >&AS_MESSAGE_LOG_FD "\
1441 $libc_seen_a$libc_seen_b from:
1442 $ac_try"
1443 ;;
1444 esac
1445 fi
1446 rm -f conftest*])
1447 use_default_link=$libc_cv_use_default_link
1448 fi
1449
1450 AC_CACHE_CHECK(for GLOB_DAT reloc,
1451 libc_cv_has_glob_dat, [dnl
1452 cat > conftest.c <<EOF
1453 extern int mumble;
1454 int foo (void) { return mumble; }
1455 EOF
1456 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1457 -fPIC -shared -o conftest.so conftest.c
1458 -nostdlib -nostartfiles $no_ssp
1459 1>&AS_MESSAGE_LOG_FD])
1460 then
1461 dnl look for GLOB_DAT relocation.
1462 if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
1463 libc_cv_has_glob_dat=yes
1464 else
1465 libc_cv_has_glob_dat=no
1466 fi
1467 else
1468 libc_cv_has_glob_dat=no
1469 fi
1470 rm -f conftest*])
1471 AC_SUBST(libc_cv_has_glob_dat)
1472
1473 AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
1474 cat > conftest.c <<EOF
1475 int foo;
1476 EOF
1477 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder -fno-section-anchors
1478 conftest.c 1>&AS_MESSAGE_LOG_FD])
1479 then
1480 libc_cv_fno_toplevel_reorder=yes
1481 else
1482 libc_cv_fno_toplevel_reorder=no
1483 fi
1484 rm -f conftest*])
1485 if test $libc_cv_fno_toplevel_reorder = yes; then
1486 fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
1487 else
1488 fno_unit_at_a_time=-fno-unit-at-a-time
1489 fi
1490 AC_SUBST(fno_unit_at_a_time)
1491
1492 AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
1493 [dnl
1494 cat > conftest.c <<EOF
1495 __thread int i;
1496 void foo (void)
1497 {
1498 i = 10;
1499 }
1500 EOF
1501 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fPIC -mtls-dialect=gnu2
1502 conftest.c 1>&AS_MESSAGE_LOG_FD])
1503 then
1504 libc_cv_mtls_dialect_gnu2=yes
1505 else
1506 libc_cv_mtls_dialect_gnu2=no
1507 fi
1508 rm -f conftest*])
1509 AC_SUBST(libc_cv_mtls_dialect_gnu2)
1510 LIBC_CONFIG_VAR([have-mtls-dialect-gnu2], [$libc_cv_mtls_dialect_gnu2])
1511
1512 AC_CACHE_CHECK(whether cc puts quotes around section names,
1513 libc_cv_have_section_quotes,
1514 [cat > conftest.c <<EOF
1515 static const int foo
1516 __attribute__ ((section ("bar"))) = 1;
1517 EOF
1518 if ${CC-cc} -S conftest.c -o conftest.s; then
1519 if grep '\.section.*"bar"' conftest.s >/dev/null; then
1520 libc_cv_have_section_quotes=yes
1521 else
1522 libc_cv_have_section_quotes=no
1523 fi
1524 else
1525 libc_cv_have_section_quotes=unknown
1526 fi
1527 rm -f conftest.{c,s}
1528 ])
1529 if test $libc_cv_have_section_quotes = yes; then
1530 AC_DEFINE(HAVE_SECTION_QUOTES)
1531 fi
1532
1533 AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
1534 cat > conftest.c <<\EOF
1535 void zero (void *x)
1536 {
1537 __builtin_memset (x, 0, 1000);
1538 }
1539 EOF
1540 dnl
1541 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "memset" > /dev/null]);
1542 then
1543 libc_cv_gcc_builtin_memset=no
1544 else
1545 libc_cv_gcc_builtin_memset=yes
1546 fi
1547 rm -f conftest* ])
1548 if test "$libc_cv_gcc_builtin_memset" = yes ; then
1549 AC_DEFINE(HAVE_BUILTIN_MEMSET)
1550 fi
1551
1552 AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
1553 cat > conftest.c <<\EOF
1554 extern char *strstr (const char *, const char *) __asm ("my_strstr");
1555 char *foo (const char *a, const char *b)
1556 {
1557 return __builtin_strstr (a, b);
1558 }
1559 EOF
1560 dnl
1561 if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "strstr" > /dev/null]);
1562 then
1563 libc_cv_gcc_builtin_redirection=yes
1564 else
1565 libc_cv_gcc_builtin_redirection=no
1566 fi
1567 rm -f conftest* ])
1568 if test "$libc_cv_gcc_builtin_redirection" = no; then
1569 AC_MSG_ERROR([support for the symbol redirection needed])
1570 fi
1571
1572 dnl Determine how to disable generation of FMA instructions.
1573 AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
1574 libc_cv_cc_nofma, [dnl
1575 libc_cv_cc_nofma=
1576 for opt in -ffp-contract=off -mno-fused-madd; do
1577 LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
1578 done])
1579 AC_SUBST(libc_cv_cc_nofma)
1580
1581 if test -n "$submachine"; then
1582 AC_CACHE_CHECK([for compiler option for CPU variant],
1583 libc_cv_cc_submachine, [dnl
1584 libc_cv_cc_submachine=no
1585 for opt in "-march=$submachine" "-mcpu=$submachine"; do
1586 LIBC_TRY_CC_OPTION([$opt], [
1587 libc_cv_cc_submachine="$opt"
1588 break], [])
1589 done])
1590 if test "x$libc_cv_cc_submachine" = xno; then
1591 AC_MSG_ERROR([${CC-cc} does not support $submachine])
1592 fi
1593 fi
1594 AC_SUBST(libc_cv_cc_submachine)
1595
1596 AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
1597 __attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
1598 cat > conftest.c <<EOF
1599 void
1600 __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
1601 foo (void) {}
1602 EOF
1603 libc_cv_cc_loop_to_function=no
1604 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
1605 then
1606 libc_cv_cc_loop_to_function=yes
1607 fi
1608 rm -f conftest*])
1609 if test $libc_cv_cc_loop_to_function = yes; then
1610 AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
1611 fi
1612 AC_SUBST(libc_cv_cc_loop_to_function)
1613
1614 dnl Check whether we have the gd library available.
1615 AC_MSG_CHECKING(for libgd)
1616 if test "$with_gd" != "no"; then
1617 old_CFLAGS="$CFLAGS"
1618 CFLAGS="$CFLAGS $libgd_include"
1619 old_LDFLAGS="$LDFLAGS"
1620 LDFLAGS="$LDFLAGS $libgd_ldflags"
1621 old_LIBS="$LIBS"
1622 LIBS="$LIBS -lgd -lpng -lz -lm"
1623 AC_TRY_LINK([#include <gd.h>], [gdImagePng (0, 0)], LIBGD=yes, LIBGD=no)
1624 CFLAGS="$old_CFLAGS"
1625 LDFLAGS="$old_LDFLAGS"
1626 LIBS="$old_LIBS"
1627 else
1628 LIBGD=no
1629 fi
1630 AC_MSG_RESULT($LIBGD)
1631 AC_SUBST(LIBGD)
1632
1633 # SELinux detection
1634 if test x$with_selinux = xno ; then
1635 have_selinux=no;
1636 else
1637 # See if we have the SELinux library
1638 AC_CHECK_LIB(selinux, is_selinux_enabled,
1639 have_selinux=yes, have_selinux=no)
1640 if test x$with_selinux = xyes ; then
1641 if test x$have_selinux = xno ; then
1642 AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
1643 fi
1644 fi
1645 fi
1646 # Check if we're building with SELinux support.
1647 if test "x$have_selinux" = xyes; then
1648 AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
1649
1650 # See if we have the libaudit library
1651 AC_CHECK_LIB(audit, audit_log_user_avc_message,
1652 have_libaudit=yes, have_libaudit=no)
1653 if test "x$have_libaudit" = xyes; then
1654 AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
1655 fi
1656 AC_SUBST(have_libaudit)
1657
1658 # See if we have the libcap library
1659 AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
1660 if test "x$have_libcap" = xyes; then
1661 AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
1662 fi
1663 AC_SUBST(have_libcap)
1664 fi
1665 AC_SUBST(have_selinux)
1666
1667 CPPUNDEFS=
1668 dnl Check for silly hacked compilers predefining _FORTIFY_SOURCE.
1669 dnl Since we are building the implementations of the fortified functions here,
1670 dnl having the macro defined interacts very badly.
1671 AC_CACHE_CHECK([for _FORTIFY_SOURCE predefine], libc_cv_predef_fortify_source,
1672 [AC_TRY_COMPILE([], [
1673 #ifdef _FORTIFY_SOURCE
1674 # error bogon
1675 #endif],
1676 [libc_cv_predef_fortify_source=no],
1677 [libc_cv_predef_fortify_source=yes])])
1678 if test $libc_cv_predef_fortify_source = yes; then
1679 CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE"
1680 fi
1681 AC_SUBST(CPPUNDEFS)
1682
1683 AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
1684 libc_cv_builtin_trap, [dnl
1685 libc_cv_builtin_trap=no
1686 AC_TRY_COMPILE([], [__builtin_trap ()], [
1687 libc_undefs=`$NM -u conftest.o |
1688 LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
1689 2>&AS_MESSAGE_LOG_FD` || {
1690 AC_MSG_ERROR([confusing output from $NM -u])
1691 }
1692 echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
1693 if test -z "$libc_undefs"; then
1694 libc_cv_builtin_trap=yes
1695 fi])])
1696 if test $libc_cv_builtin_trap = yes; then
1697 AC_DEFINE([HAVE_BUILTIN_TRAP])
1698 fi
1699
1700 dnl C++ feature tests.
1701 AC_LANG_PUSH([C++])
1702
1703 AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
1704 libc_cv_cxx_thread_local, [
1705 old_CXXFLAGS="$CXXFLAGS"
1706 CXXFLAGS="$CXXFLAGS -std=gnu++11"
1707 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1708 #include <thread>
1709
1710 // Compiler support.
1711 struct S
1712 {
1713 S ();
1714 ~S ();
1715 };
1716 thread_local S s;
1717 S * get () { return &s; }
1718
1719 // libstdc++ support.
1720 #ifndef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
1721 #error __cxa_thread_atexit_impl not supported
1722 #endif
1723 ])],
1724 [libc_cv_cxx_thread_local=yes],
1725 [libc_cv_cxx_thread_local=no])
1726 CXXFLAGS="$old_CXXFLAGS"
1727 ])
1728 AC_SUBST(libc_cv_cxx_thread_local)
1729
1730 AC_LANG_POP([C++])
1731 dnl End of C++ feature tests.
1732
1733 ### End of automated tests.
1734 ### Now run sysdeps configure fragments.
1735
1736 # They also can set these variables.
1737 use_ldconfig=no
1738 ldd_rewrite_script=no
1739 libc_cv_sysconfdir=$sysconfdir
1740 libc_cv_localstatedir=$localstatedir
1741 libc_cv_gcc_unwind_find_fde=no
1742 libc_cv_idn=no
1743
1744 # Iterate over all the sysdep directories we will use, running their
1745 # configure fragments.
1746 for dir in $sysnames; do
1747 case $dir in
1748 /*) dest=$dir ;;
1749 *) dest=$srcdir/$dir ;;
1750 esac
1751 if test -r $dest/configure; then
1752 AC_MSG_RESULT(running configure fragment for $dir)
1753 . $dest/configure
1754 fi
1755 done
1756
1757 if test x"$build_mathvec" = xnotset; then
1758 build_mathvec=no
1759 fi
1760 LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
1761
1762 AC_SUBST(libc_extra_cflags)
1763 AC_SUBST(libc_extra_cppflags)
1764
1765 if test x$libc_cv_gcc_unwind_find_fde = xyes; then
1766 AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
1767 fi
1768 AC_SUBST(libc_cv_gcc_unwind_find_fde)
1769
1770 # A sysdeps configure fragment can reset this if IFUNC is not actually
1771 # usable even though the assembler knows how to generate the symbol type.
1772 if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
1773 AC_DEFINE(HAVE_IFUNC)
1774 fi
1775
1776 if test x"$libc_cv_gcc_indirect_function" = xyes; then
1777 AC_DEFINE(HAVE_GCC_IFUNC)
1778 fi
1779
1780 # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
1781 # configure fragment can override the value to prevent this AC_DEFINE.
1782 AC_SUBST(use_nscd)
1783 if test "x$use_nscd" != xno; then
1784 AC_DEFINE([USE_NSCD])
1785 fi
1786 if test "x$build_nscd" = xdefault; then
1787 build_nscd=$use_nscd
1788 fi
1789
1790 AC_SUBST(libc_cv_slibdir)
1791 AC_SUBST(libc_cv_rtlddir)
1792 AC_SUBST(libc_cv_complocaledir)
1793 AC_SUBST(libc_cv_sysconfdir)
1794 AC_SUBST(libc_cv_localstatedir)
1795 AC_SUBST(libc_cv_rootsbindir)
1796
1797 if test x$use_ldconfig = xyes; then
1798 AC_DEFINE(USE_LDCONFIG)
1799 fi
1800 AC_SUBST(use_ldconfig)
1801 AC_SUBST(ldd_rewrite_script)
1802
1803 AC_SUBST(static)
1804 AC_SUBST(shared)
1805
1806 AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
1807 [libc_cv_pic_default=yes
1808 cat > conftest.c <<EOF
1809 #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
1810 # error PIC is default.
1811 #endif
1812 EOF
1813 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1814 libc_cv_pic_default=no
1815 fi
1816 rm -f conftest.*])
1817 AC_SUBST(libc_cv_pic_default)
1818
1819 AC_CACHE_CHECK([whether -fPIE is default], libc_cv_cc_pie_default,
1820 [libc_cv_cc_pie_default=yes
1821 cat > conftest.c <<EOF
1822 #if defined __PIE__ || defined __pie__ || defined PIE || defined pie
1823 # error PIE is default.
1824 #endif
1825 EOF
1826 if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
1827 libc_cv_cc_pie_default=no
1828 fi
1829 rm -f conftest.*])
1830 libc_cv_pie_default=$libc_cv_cc_pie_default
1831 AC_SUBST(libc_cv_cc_pie_default)
1832 AC_SUBST(libc_cv_pie_default)
1833
1834 # Set the `multidir' variable by grabbing the variable from the compiler.
1835 # We do it once and save the result in a generated makefile.
1836 libc_cv_multidir=.
1837 if test "$with_clang" = no; then
1838 libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
1839 fi
1840 AC_SUBST(libc_cv_multidir)
1841
1842 if test "$static_pie" = yes; then
1843 # The linker must support --no-dynamic-linker.
1844 if test "$libc_cv_no_dynamic_linker" != yes; then
1845 AC_MSG_ERROR([linker support for --no-dynamic-linker needed])
1846 fi
1847 # Default to PIE.
1848 libc_cv_pie_default=yes
1849 AC_DEFINE(ENABLE_STATIC_PIE)
1850 fi
1851 LIBC_CONFIG_VAR([enable-static-pie], [$static_pie])
1852
1853 AC_SUBST(profile)
1854 AC_SUBST(static_nss)
1855
1856 AC_SUBST(DEFINES)
1857
1858 dnl See sysdeps/mach/configure.ac for this variable.
1859 AC_SUBST(mach_interface_list)
1860
1861 VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
1862 RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
1863 AC_SUBST(VERSION)
1864 AC_SUBST(RELEASE)
1865
1866 AC_CONFIG_FILES([config.make Makefile])
1867 AC_CONFIG_COMMANDS([default],[[
1868 case $CONFIG_FILES in *config.make*)
1869 echo "$config_vars" >> config.make;;
1870 esac
1871 test -d bits || mkdir bits]],[[config_vars='$config_vars']])
1872 AC_OUTPUT