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