1 dnl Process this file with autoconf to produce a configure script.
3 dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
5 dnl This file is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3 of the License, or
8 dnl (at your option) any later version.
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 dnl GNU General Public License for more details.
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; see the file COPYING3. If not see
17 dnl <http://www.gnu.org/licenses/>.
21 AC_CONFIG_SRCDIR(gold.cc)
25 AM_INIT_AUTOMAKE([no-dist parallel-tests])
26 AM_SILENT_RULES([yes])
28 AM_CONFIG_HEADER(config.h:config.in)
30 AC_USE_SYSTEM_EXTENSIONS
33 AH_VERBATIM([00_CONFIG_H_CHECK],
34 [/* Check that config.h is #included before system headers
35 (this works only for glibc, but that should be enough). */
36 #if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
37 # error config.h must be #included before system headers
39 #define __CONFIG_H__ 1])
42 [ --with-sysroot[=DIR] search for usr/lib et al within DIR],
43 [sysroot=$withval], [sysroot=no])
45 if test "$sysroot" = "yes"; then
46 sysroot='${exec_prefix}/${target_alias}/sys-root'
47 elif test "$sysroot" = "no"; then
52 if test -n "$sysroot"; then
54 "${prefix}" | "${prefix}/"* | \
55 "${exec_prefix}" | "${exec_prefix}/"* | \
56 '${prefix}' | '${prefix}/'*| \
57 '${exec_prefix}' | '${exec_prefix}/'*)
63 AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT, "$sysroot",
64 [System root for target files])
65 AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT_RELOCATABLE, $sysroot_relocatable,
66 [Whether the system root can be relocated])
68 dnl "install_as_default" is true if the linker to be installed as the
69 dnl default linker, ld.
70 dnl "installed_linker" is the installed gold linker name.
72 installed_linker=ld.gold
74 [[ --enable-gold[=ARG] build gold [ARG={default,yes,no}]]],
75 [case "${enableval}" in
77 install_as_default=yes
80 if test x${enable_ld} = xno; then
81 install_as_default=yes
85 [install_as_default=no])
86 AC_SUBST(install_as_default)
87 AC_SUBST(installed_linker)
90 if test "$plugins" = "yes"; then
91 AC_DEFINE(ENABLE_PLUGINS, 1,
92 [Define to enable linker plugins])
94 AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
96 # Decide if -z relro should be enabled in ELF linker by default.
97 ac_default_ld_z_relro=unset
98 # Provide a configure time option to override our default.
100 AS_HELP_STRING([--enable-relro],
101 [enable -z relro in ELF linker by default]),
102 [case "${enableval}" in
103 yes) ac_default_ld_z_relro=1 ;;
104 no) ac_default_ld_z_relro=0 ;;
106 if test "${ac_default_ld_z_relro}" = unset; then
107 ac_default_ld_z_relro=1
109 AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_RELRO,
110 $ac_default_ld_z_relro,
111 [Define to 1 if you want to enable -z relro in ELF linker by default.])
113 AC_ARG_ENABLE([targets],
114 [ --enable-targets alternative target configurations],
115 [case "${enableval}" in
117 AC_MSG_ERROR([--enable-targets option must specify target names or 'all'])
123 enable_targets=$enableval
126 [# For now, enable all targets by default
130 # Canonicalize the enabled targets.
131 if test -n "$enable_targets"; then
132 for targ in `echo $enable_targets | sed -e 's/,/ /g'`; do
133 result=`$ac_config_sub $targ 2>/dev/null`
134 if test -n "$result"; then
135 canon_targets="$canon_targets $result"
137 # Permit unrecognized target names, like "all".
138 canon_targets="$canon_targets $targ"
143 # Decide which "--hash-style" to use by default
144 # Provide a configure time option to override our default.
145 AC_ARG_ENABLE([default-hash-style],
146 AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}],
147 [use this default hash style]),
148 [case "${enable_default_hash_style}" in
149 sysv | gnu | both) ;;
150 *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;;
153 # Enable gnu hash only on GNU targets, but not mips
154 mips*-*-*) enable_default_hash_style=sysv ;;
155 *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
156 *) enable_default_hash_style=sysv ;;
159 AC_DEFINE_UNQUOTED([DEFAULT_HASH_STYLE],
160 ["${enable_default_hash_style}"],
161 [Set the default --hash-style value])
163 # See which specific instantiations we need.
169 default_osabi=ELFOSABI_NONE
174 for targ in $target $canon_targets; do
175 if test "$targ" = "all"; then
182 . ${srcdir}/configure.tgt
184 if test "$targ_obj" = "UNKNOWN"; then
185 AC_MSG_ERROR("unsupported target $targ")
187 targetobjs="$targetobjs ${targ_obj}.\$(OBJEXT)"
188 if test "$targ_extra_obj" != ""; then
189 targetobjs="$targetobjs ${targ_extra_obj}.\$(OBJEXT)"
191 if test "$targ_size" = "32" -o "$targ_extra_size" = "32"; then
192 if test "$targ_big_endian" = "true" \
193 -o "$targ_extra_big_endian" = "true"; then
196 if test "$targ_big_endian" = "false" \
197 -o "$targ_extra_big_endian" = "false"; then
201 if test "$targ_size" = "64" -o "$targ_extra_size" = "64"; then
202 if test "$targ_big_endian" = "true" \
203 -o "$targ_extra_big_endian" = "true"; then
206 if test "$targ_big_endian" = "false" \
207 -o "$targ_extra_big_endian" = "false"; then
212 if test "$target" = "$targ"; then
213 default_machine=$targ_machine
214 default_size=$targ_size
215 default_big_endian=$targ_big_endian
216 default_osabi=$targ_osabi
218 AM_CONDITIONAL(DEFAULT_TARGET_AARCH64, test "$targ_obj" = "aarch64")
219 AM_CONDITIONAL(DEFAULT_TARGET_ARM, test "$targ_obj" = "arm")
220 AM_CONDITIONAL(DEFAULT_TARGET_I386, test "$targ_obj" = "i386")
221 AM_CONDITIONAL(DEFAULT_TARGET_POWERPC, test "$targ_obj" = "powerpc")
222 AM_CONDITIONAL(DEFAULT_TARGET_SPARC, test "$targ_obj" = "sparc")
223 AM_CONDITIONAL(DEFAULT_TARGET_S390, test "$targ_obj" = "s390")
226 if test "$targ_obj" = "x86_64"; then
228 x86_64*-linux-gnux32)
237 AM_CONDITIONAL(DEFAULT_TARGET_X86_64, test "$target_x86_64" = "yes")
238 AM_CONDITIONAL(DEFAULT_TARGET_X32, test "$target_x32" = "yes")
239 AM_CONDITIONAL(DEFAULT_TARGET_X86_64_OR_X32,
240 test "$target_x86_64" = "yes" -o "$target_x32" = "yes")
241 AM_CONDITIONAL(DEFAULT_TARGET_TILEGX, test "$targ_obj" = "tilegx")
242 AM_CONDITIONAL(DEFAULT_TARGET_MIPS, test "$targ_obj" = "mips")
243 DEFAULT_TARGET=${targ_obj}
244 AC_SUBST(DEFAULT_TARGET)
250 # Remove any duplicates.
252 for t in $targetobjs; do
260 if test -n "$targ_32_little"; then
261 AC_DEFINE(HAVE_TARGET_32_LITTLE, 1,
262 [Define to support 32-bit little-endian targets])
264 if test -n "$targ_32_big"; then
265 AC_DEFINE(HAVE_TARGET_32_BIG, 1,
266 [Define to support 32-bit big-endian targets])
268 if test -n "$targ_64_little"; then
269 AC_DEFINE(HAVE_TARGET_64_LITTLE, 1,
270 [Define to support 64-bit little-endian targets])
272 if test -n "$targ_64_big"; then
273 AC_DEFINE(HAVE_TARGET_64_BIG, 1,
274 [Define to support 64-bit big-endian targets])
277 if test -n "$all_targets"; then
278 TARGETOBJS='$(ALL_TARGETOBJS)'
280 TARGETOBJS="$targetobjs"
284 AC_DEFINE_UNQUOTED(GOLD_DEFAULT_MACHINE, $default_machine,
285 [Default machine code])
286 AC_DEFINE_UNQUOTED(GOLD_DEFAULT_SIZE, $default_size,
287 [Default size (32 or 64)])
288 AC_DEFINE_UNQUOTED(GOLD_DEFAULT_BIG_ENDIAN, $default_big_endian,
289 [Default big endian (true or false)])
290 AC_DEFINE_UNQUOTED(GOLD_DEFAULT_OSABI, $default_osabi,
291 [Default OSABI code])
293 AC_ARG_WITH(lib-path,
294 [ --with-lib-path=dir1:dir2... set default LIB_PATH],
296 yes) LIB_PATH='"/lib:/usr/lib"' ;;
298 *) LIB_PATH='"'"$withval"'"' ;;
300 [LIB_PATH='"::DEFAULT::"'])
301 AC_DEFINE_UNQUOTED(LIB_PATH, $LIB_PATH,
302 [Default library search path])
303 if test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias"; then
304 AC_DEFINE(NATIVE_LINKER, 1, [Whether configured as a native linker])
307 AC_CHECK_TOOL(NM, nm)
318 ZW_GNU_GETTEXT_SISTER_DIR
325 AM_CONDITIONAL(NATIVE_LINKER,
326 test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias")
327 AM_CONDITIONAL(GCC, test "$GCC" = yes)
329 AM_CONDITIONAL(NATIVE_OR_CROSS_LINKER,
330 test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias" -o "x$host_alias" = "x$build_alias")
332 dnl Test for whether static linking is supported. Some systems do not
333 dnl install static libraries. This only affects the set of tests that
335 AC_CACHE_CHECK([whether static linking works], [gold_cv_lib_static],
336 [LDFLAGS_hold=$LDFLAGS
337 LDFLAGS="$LDFLAGS -static"
339 AC_LANG_PROGRAM([[void f() { }]])],
340 [gold_cv_lib_static=yes], [gold_cv_lib_static=no])
341 LDFLAGS=$LDFLAGS_hold])
342 AM_CONDITIONAL(HAVE_STATIC, test "$gold_cv_lib_static" = "yes")
344 dnl Some architectures do not support taking pointers of functions
345 dnl defined in shared libraries except in -fPIC mode. We need to
346 dnl tell the unittest framework if we're compiling for one of those
347 dnl targets, so it doesn't try to run the tests that do that.
348 AM_CONDITIONAL(FN_PTRS_IN_SO_WITHOUT_PIC, [
357 dnl Test for gcc 4.1 or later. Full support for -mcmodel=medium is
358 dnl only available in gcc 4.1.
359 AC_CACHE_CHECK([for gcc >= 4.1], [gold_cv_prog_gcc41],
360 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
361 #if !defined __GNUC__
363 #elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
366 ])], [gold_cv_prog_gcc41=yes], [gold_cv_prog_gcc41=no])])
368 save_CFLAGS="$CFLAGS"
369 CFLAGS="$CFLAGS -mcmodel=medium"
370 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [have_mcmodel_medium=yes], [have_mcmodel_medium=no])
371 CFLAGS="$save_CFLAGS"
372 dnl Whether we can test -mcmodel=medium.
373 AM_CONDITIONAL(MCMODEL_MEDIUM,
374 [test "$target_cpu" = "x86_64" -a "$have_mcmodel_medium" = "yes" -a "$gold_cv_prog_gcc41" = "yes"])
376 dnl Test for gcc 9 or later. Some incremental tests fail with GCC 9 or
378 AC_CACHE_CHECK([for gcc >= 9], [gold_cv_prog_gcc9],
379 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
380 #if !defined __GNUC__ || __GNUC__ < 9
383 ])], [gold_cv_prog_gcc9=yes], [gold_cv_prog_gcc9=no])])
384 AM_CONDITIONAL(GCC9, [test "$gold_cv_prog_gcc9" = "yes"])
386 dnl Test for -fcf-protection on x86-64. Some incremental tests fail with
388 AC_CACHE_CHECK([for -fcf-protection], [gold_cv_cflags_cf_protection],
389 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
390 #if !defined __x86_64__ || !defined __CET__
393 ])], [gold_cv_cflags_cf_protection=yes], [gold_cv_cflags_cf_protection=no])])
394 AM_CONDITIONAL(CFLAGS_CF_PROTECTION, [test "$gold_cv_cflags_cf_protection" = "yes"])
396 AC_CACHE_CHECK([whether $CC supports -fmerge-constants],
397 [gold_cv_merge_constants], [
398 save_CFLAGS="$CFLAGS"
399 CFLAGS="$CFLAGS -fmerge-constants"
400 AC_COMPILE_IFELSE([AC_LANG_SOURCE([const char *s = "foo";])],
401 [gold_cv_merge_constants=yes],
402 [gold_cv_merge_constants=no])
403 CFLAGS="$save_CFLAGS"])
404 AC_SUBST([MERGE_CONSTANTS_FLAG])
405 AS_IF([test "$gold_cv_merge_constants" = yes],
406 [MERGE_CONSTANTS_FLAG=-fmerge-constants],
407 [MERGE_CONSTANTS_FLAG=])
409 dnl Test for __thread support.
410 AC_CACHE_CHECK([for thread support], [gold_cv_c_thread],
411 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([__thread int i = 1;])],
412 [gold_cv_c_thread=yes], [gold_cv_c_thread=no])])
414 AM_CONDITIONAL(TLS, test "$gold_cv_c_thread" = "yes")
416 dnl On GNU/Linux TLS in static programs only works when using glibc
418 AC_CACHE_CHECK([for glibc >= 2.4], [gold_cv_lib_glibc24],
419 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
420 #include <features.h>
421 #if !defined __GLIBC__
423 #elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4)
426 ])], [gold_cv_lib_glibc24=yes], [gold_cv_lib_glibc24=no])])
428 AM_CONDITIONAL(STATIC_TLS, test "$gold_cv_lib_glibc24" = "yes")
430 dnl Test for #pragma omp threadprivate
431 AC_CACHE_CHECK([for omp support], [gold_cv_c_threadprivate],
432 [save_CFLAGS="$CFLAGS"
433 CFLAGS="$CFLAGS -fopenmp"
434 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
437 #pragma omp threadprivate (i)
438 ])], [gold_cv_c_threadprivate=yes], [gold_cv_c_threadprivate=no])
439 CFLAGS="$save_CFLAGS"])
440 if test "$gold_cv_c_threadprivate" = "yes"; then
441 AC_DEFINE(HAVE_OMP_SUPPORT, 1,
442 [Define if compiler supports #pragma omp threadprivate])
444 AM_CONDITIONAL(OMP_SUPPORT, test "$gold_cv_c_threadprivate" = "yes")
446 dnl Test for the -ftls-dialect=gnu2 option.
447 dnl Use -Werror in case of compilers that make unknown -m options warnings.
448 dnl They would pass the test here, but fail in actual use when $WARN_CFLAGS
449 dnl gets set later by default Autoconf magic to include -Werror. (We are
450 dnl assuming here that there is no compiler that groks -mtls-dialect=gnu2
451 dnl but does not grok -Werror.)
452 save_CFLAGS="$CFLAGS"
453 CFLAGS="$CFLAGS -Werror -fpic -mtls-dialect=gnu2"
454 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
460 ])], [have_tls_gnu2=yes], [have_tls_gnu2=no])
461 CFLAGS="$save_CFLAGS"
462 AM_CONDITIONAL(TLS_GNU2_DIALECT, test "$have_tls_gnu2" = "yes")
464 dnl On GNU/Linux TLS descriptors are supported by the dynamic loader
465 dnl only with glibc 2.9 or later.
466 AC_CACHE_CHECK([for glibc >= 2.9], [gold_cv_lib_glibc29],
467 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
468 #include <features.h>
469 #if !defined __GLIBC__
471 #elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 9)
474 ])], [gold_cv_lib_glibc29=yes], [gold_cv_lib_glibc29=no])])
476 AM_CONDITIONAL(TLS_DESCRIPTORS, test "$gold_cv_lib_glibc29" = "yes")
478 dnl Test for the -frandom-seed option.
479 AC_CACHE_CHECK([for -frandom-seed support], [gold_cv_c_random_seed],
480 [save_CFLAGS="$CFLAGS"
481 CFLAGS="$CFLAGS -frandom-seed=foo"
482 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [gold_cv_c_random_seed=yes],
483 [gold_cv_c_random_seed=no])
484 CFLAGS="$save_CFLAGS"])
485 if test "$gold_cv_c_random_seed" = "yes"; then
486 # In Makefile, '$@' will be expanded to be the name of the file
487 # being built, providing a unique seed for each file.
488 RANDOM_SEED_CFLAGS=-frandom-seed=\$@
490 AC_SUBST(RANDOM_SEED_CFLAGS)
492 dnl On GNU/Linux ifunc is supported by the dynamic linker in glibc
493 dnl 2.11 or later, and by binutils 2.20.1 or later.
494 AC_CACHE_CHECK([for glibc ifunc support], [gold_cv_lib_glibc_ifunc],
495 [save_LDFLAGS="$LDFLAGS"
496 LDFLAGS="$LDFLAGS -static"
497 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
498 #include <features.h>
499 #if !defined __GLIBC__
501 #elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 11)
506 __asm__(".type invoke, %gnu_indirect_function");
507 typedef void (*funcptr) (void);
508 funcptr dispatch (void) __asm__ ("invoke");
509 funcptr dispatch (void) { return &func; }]],
512 if ${NM} conftest$EXEEXT | grep "__rela\?_iplt_start" >/dev/null 2>&1; then
513 gold_cv_lib_glibc_ifunc=both
515 gold_cv_lib_glibc_ifunc=dyn
516 fi], [gold_cv_lib_glibc_ifunc=no])
517 LDFLAGS="$save_LDFLAGS"])
519 AM_CONDITIONAL(IFUNC, test "$gold_cv_lib_glibc_ifunc" != "no")
520 AM_CONDITIONAL(IFUNC_STATIC, test "$gold_cv_lib_glibc_ifunc" = "both")
524 WARN_CXXFLAGS=`echo ${WARN_CFLAGS} | sed -e 's/-Wstrict-prototypes//' -e 's/-Wmissing-prototypes//' -e 's/-Wshadow//'`
525 AC_SUBST(WARN_CXXFLAGS)
527 AC_ARG_WITH(gold-ldflags,
528 [ --with-gold-ldflags=FLAGS additional link flags for gold],
529 [if test "$withval" = "no" -o "$withval" = "yes"; then
532 GOLD_LDFLAGS=$withval
535 AC_SUBST(GOLD_LDFLAGS)
537 AC_ARG_WITH(gold-ldadd,
538 [ --with-gold-ldadd=LIBS additional libraries for gold],
539 [if test "$withval" = "no" -o "$withval" = "yes"; then
547 dnl Force support for large files by default. This may need to be
548 dnl host dependent. If build == host, we can check getconf LFS_CFLAGS.
549 LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
552 AC_CHECK_HEADERS(sys/mman.h)
553 AC_CHECK_FUNCS(chsize mmap link)
554 AC_REPLACE_FUNCS(pread ftruncate ffsll)
556 AC_CACHE_CHECK([mremap with MREMAP_MAYMOVE], [gold_cv_lib_mremap_maymove],
559 #include <sys/mman.h>
560 void f() { mremap (0, 0, 0, MREMAP_MAYMOVE); }
561 ]])], [gold_cv_lib_mremap_maymove=yes], [gold_cv_lib_mremap_maymove=no])])
562 if test "$gold_cv_lib_mremap_maymove" = "yes"; then
563 AC_DEFINE(HAVE_MREMAP, 1,
564 [Define to 1 if you have the mremap function with MREMAP_MAYMOVE support])
569 # Link in zlib/zstd if we can. This allows us to write compressed sections.
572 AM_CONDITIONAL(HAVE_ZSTD, test "$pkg_cv_ZSTD_LIBS" != "")
574 AC_ARG_ENABLE([threads],
575 [[ --enable-threads[=ARG] multi-threaded linking [ARG={auto,yes,no}]]],
576 [case "${enableval}" in
577 yes | "") threads=yes ;;
579 auto) threads=auto ;;
584 if test "$threads" = "yes"; then
585 AX_PTHREAD([threads=yes], AC_MSG_ERROR([pthread not found]))
586 elif test "$threads" = "auto"; then
587 AX_PTHREAD([threads=yes], [threads=no])
590 if test "$threads" = "yes"; then
591 AC_DEFINE(ENABLE_THREADS, 1,
592 [Define to do multi-threaded linking])
594 AM_CONDITIONAL(THREADS, test "$threads" = "yes")
596 # Used to validate --package-metadata= input. Disabled by default.
597 AC_ARG_ENABLE([jansson],
598 [AS_HELP_STRING([--enable-jansson],
599 [enable jansson [default=no]])],
600 [enable_jansson=$enableval],
601 [enable_jansson="no"])
603 if test "x$enable_jansson" != "xno"; then
605 AS_IF([test -n "$PKG_CONFIG"],
607 PKG_CHECK_MODULES(JANSSON, [jansson],
609 AC_DEFINE(HAVE_JANSSON, 1, [The jansson library is to be used])
610 AC_SUBST([JANSSON_CFLAGS])
611 AC_SUBST([JANSSON_LIBS])
614 AC_MSG_ERROR([Cannot find jansson library])
618 AC_MSG_ERROR([Cannot find pkg-config])
622 dnl We have to check these in C, not C++, because autoconf generates
623 dnl tests which have no type information, and current glibc provides
624 dnl multiple declarations of functions like basename when compiling
626 AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp])
628 dnl Check if gcc supports the -gpubnames option.
629 dnl Use -Werror in case of compilers that make unknown -g options warnings.
630 dnl They would pass the test here, but fail in actual use when $WARN_CFLAGS
631 dnl gets set later by default Autoconf magic to include -Werror. (We are
632 dnl assuming here that there is no compiler that groks -gpubnames
633 dnl but does not grok -Werror.)
634 save_CFLAGS="$CFLAGS"
635 CFLAGS="$CFLAGS -Werror -gpubnames"
636 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [have_pubnames=yes], [have_pubnames=no])
637 CFLAGS="$save_CFLAGS"
638 AM_CONDITIONAL(HAVE_PUBNAMES, test "$have_pubnames" = "yes")
640 dnl Check if gcc supports the -fno-use-linker-plugin option.
641 save_CFLAGS="$CFLAGS"
642 CFLAGS="$CFLAGS -Werror -fno-use-linker-plugin"
643 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [have_no_use_linker_plugin=yes], [have_no_use_linker_plugin=no])
644 CFLAGS="$save_CFLAGS"
645 AM_CONDITIONAL(HAVE_NO_USE_LINKER_PLUGIN, test "$have_no_use_linker_plugin" = "yes")
649 AC_CHECK_HEADERS(unordered_set unordered_map)
650 AC_CHECK_HEADERS(tr1/unordered_set tr1/unordered_map)
651 AC_CHECK_HEADERS(ext/hash_map ext/hash_set)
652 AC_CHECK_HEADERS(byteswap.h)
654 dnl Check for bswap_{16,32,64}
655 AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]])
657 dnl When plugins enabled dynamic loader interface is required. Check headers
658 dnl which may provide this interface. Add the necessary library to link.
659 AC_CHECK_HEADERS(windows.h)
660 AC_CHECK_HEADERS(dlfcn.h)
661 AC_SEARCH_LIBS(dlopen, [dl dld])
662 case "$ac_cv_search_dlopen" in
663 no*) DLOPEN_LIBS="";;
664 *) DLOPEN_LIBS="$ac_cv_search_dlopen";;
666 AC_SUBST(DLOPEN_LIBS)
668 AC_CHECK_FUNCS(mallinfo mallinfo2 posix_fallocate fallocate readv sysconf times mkdtemp)
669 AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem])
671 # Use of ::std::tr1::unordered_map::rehash causes undefined symbols
672 # at link time with some versions of GCC.
673 AC_CACHE_CHECK([whether ::std::tr1::unordered_map::rehash is usable.],
674 [gold_cv_unordered_map_rehash],
675 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
676 #include <tr1/unordered_map>
677 void bar() { ::std::tr1::unordered_map<int, int> x; x.rehash(10); }
678 ]])], [gold_cv_unordered_map_rehash=yes], [gold_cv_unordered_map_rehash=no])])
679 if test "$gold_cv_unordered_map_rehash" = "yes"; then
680 AC_DEFINE(HAVE_TR1_UNORDERED_MAP_REHASH, 1,
681 [Define if ::std::tr1::unordered_map::rehash is usable])
684 # Use of tr1/unordered_map with off_t as a key is not supported on GCC
685 # 4.1.xx when compiling in 32-bit mode with a 64-bit off_t type.
686 AC_CACHE_CHECK([whether std::tr1::hash<off_t> is defined],
687 [gold_cv_hash_off_t],
688 [CXXFLAGS_hold=$CXXFLAGS
689 CXXFLAGS="$CXXFLAGS $LFS_CFLAGS"
690 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
691 #include <sys/types.h>
692 #include <tr1/unordered_map>
693 std::tr1::hash<off_t> h;
695 [gold_cv_hash_off_t=yes],
696 [gold_cv_hash_off_t=no])
697 CXXFLAGS=$CXXFLAGS_hold])
698 if test "$gold_cv_hash_off_t" = "yes"; then
699 AC_DEFINE(HAVE_TR1_HASH_OFF_T, 1,
700 [Define if std::tr1::hash<off_t> is usable])
703 # gcc 4.3.0 doesn't recognize the printf attribute on a template
704 # function. Check for that. This is gcc bug 35546. This test can
705 # probably be removed after the bug has been fixed for a while.
706 AC_CACHE_CHECK([whether we can use attributes with template functions],
707 [gold_cv_template_attribute],
708 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
709 template<typename T> extern void foo(const char*, ...)
710 __attribute__ ((__format__ (__printf__, 1, 2)));
711 template<typename T> void foo(const char* format, ...) {}
712 void bar() { foo<int>("%s\n", "foo"); }
713 ])], [gold_cv_template_attribute=yes], [gold_cv_template_attribute=no])])
714 if test "$gold_cv_template_attribute" = "yes"; then
715 AC_DEFINE(HAVE_TEMPLATE_ATTRIBUTES, 1,
716 [Define if attributes work on C++ templates])
719 dnl Check if the system has struct stat::st_mtim.
720 AC_CACHE_CHECK([for struct stat::st_mtim.],
721 [gold_cv_stat_st_mtim],
722 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
723 #include <sys/stat.h>
724 long bar() { struct stat s; return (long)(s.st_mtim.tv_sec + s.st_mtim.tv_sec);}
725 ]])], [gold_cv_stat_st_mtim=yes], [gold_cv_stat_st_mtim=no])])
726 if test "$gold_cv_stat_st_mtim" = "yes"; then
727 AC_DEFINE(HAVE_STAT_ST_MTIM, 1,
728 [Define if struct stat has a field st_mtim with timespec for mtime])
733 AC_CHECK_HEADERS(locale.h)
734 AC_CHECK_FUNCS(setlocale)
739 AC_OUTPUT(Makefile testsuite/Makefile po/Makefile.in:po/Make-in)