1 dnl Process this file with autoconf to produce a configure script.
6 AC_CONFIG_SRCDIR(gold.cc)
10 AM_INIT_AUTOMAKE([no-dist parallel-tests])
12 AM_CONFIG_HEADER(config.h:config.in)
15 AH_VERBATIM([00_CONFIG_H_CHECK],
16 [/* Check that config.h is #included before system headers
17 (this works only for glibc, but that should be enough). */
18 #if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
19 # error config.h must be #included before system headers
21 #define __CONFIG_H__ 1])
24 [ --with-sysroot[=DIR] search for usr/lib et al within DIR],
25 [sysroot=$withval], [sysroot=no])
27 if test "$sysroot" = "yes"; then
28 sysroot='${exec_prefix}/${target_alias}/sys-root'
29 elif test "$sysroot" = "no"; then
34 if test -n "$sysroot"; then
36 "${prefix}" | "${prefix}/"* | \
37 "${exec_prefix}" | "${exec_prefix}/"* | \
38 '${prefix}' | '${prefix}/'*| \
39 '${exec_prefix}' | '${exec_prefix}/'*)
45 AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT, "$sysroot",
46 [System root for target files])
47 AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT_RELOCATABLE, $sysroot_relocatable,
48 [Whether the system root can be relocated])
50 dnl "install_as_default" is true if the linker to be installed as the
51 dnl default linker, ld.
52 dnl "installed_linker" is the installed gold linker name.
56 [[ --enable-ld[=ARG] build ld [ARG={default,yes,no}]]],
57 [case "${enableval}" in
64 [[ --enable-gold[=ARG] build gold [ARG={default,yes,no}]]],
65 [case "${enableval}" in
67 if test x${default_ld} = x; then
68 install_as_default=yes
70 installed_linker=ld.gold
75 AC_MSG_ERROR([invalid --enable-gold argument])
78 [install_as_default=no
79 installed_linker=ld.gold])
80 AC_SUBST(install_as_default)
81 AC_SUBST(installed_linker)
83 dnl For now threads are a configure time option.
84 AC_ARG_ENABLE([threads],
85 [ --enable-threads multi-threaded linking],
86 [case "${enableval}" in
87 yes | "") threads=yes ;;
92 if test "$threads" = "yes"; then
93 AC_DEFINE(ENABLE_THREADS, 1,
94 [Define to do multi-threaded linking])
96 AM_CONDITIONAL(THREADS, test "$threads" = "yes")
98 AC_ARG_ENABLE([plugins],
99 [ --enable-plugins linker plugins],
100 [case "${enableval}" in
101 yes | "") plugins=yes ;;
106 if test "$plugins" = "yes"; then
107 AC_DEFINE(ENABLE_PLUGINS, 1,
108 [Define to enable linker plugins])
110 AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
112 AC_ARG_ENABLE([targets],
113 [ --enable-targets alternative target configurations],
114 [case "${enableval}" in
116 AC_MSG_ERROR([--enable-targets option must specify target names or 'all'])
122 enable_targets=$enableval
125 [# For now, enable all targets by default
129 # Canonicalize the enabled targets.
130 if test -n "$enable_targets"; then
131 for targ in `echo $enable_targets | sed -e 's/,/ /g'`; do
132 result=`$ac_config_sub $targ 2>/dev/null`
133 if test -n "$result"; then
134 canon_targets="$canon_targets $result"
136 # Permit unrecognized target names, like "all".
137 canon_targets="$canon_targets $targ"
142 # See which specific instantiations we need.
148 default_osabi=ELFOSABI_NONE
153 for targ in $target $canon_targets; do
154 if test "$targ" = "all"; then
161 . ${srcdir}/configure.tgt
163 if test "$targ_obj" = "UNKNOWN"; then
164 AC_MSG_ERROR("unsupported target $targ")
166 targetobjs="$targetobjs ${targ_obj}.\$(OBJEXT)"
167 if test "$targ_extra_obj" != ""; then
168 targetobjs="$targetobjs ${targ_extra_obj}.\$(OBJEXT)"
170 if test "$targ_size" = "32" -o "$targ_extra_size" = "32"; then
171 if test "$targ_big_endian" = "true" \
172 -o "$targ_extra_big_endian" = "true"; then
175 if test "$targ_big_endian" = "false" \
176 -o "$targ_extra_big_endian" = "false"; then
180 if test "$targ_size" = "64" -o "$targ_extra_size" = "64"; then
181 if test "$targ_big_endian" = "true" \
182 -o "$targ_extra_big_endian" = "true"; then
185 if test "$targ_big_endian" = "false" \
186 -o "$targ_extra_big_endian" = "false"; then
191 if test "$target" = "$targ"; then
192 default_machine=$targ_machine
193 default_size=$targ_size
194 default_big_endian=$targ_big_endian
195 default_osabi=$targ_osabi
197 AM_CONDITIONAL(DEFAULT_TARGET_ARM, test "$targ_obj" = "arm")
198 AM_CONDITIONAL(DEFAULT_TARGET_I386, test "$targ_obj" = "i386")
199 AM_CONDITIONAL(DEFAULT_TARGET_POWERPC, test "$targ_obj" = "powerpc")
200 AM_CONDITIONAL(DEFAULT_TARGET_SPARC, test "$targ_obj" = "sparc")
201 AM_CONDITIONAL(DEFAULT_TARGET_X86_64, test "$targ_obj" = "x86_64")
202 AM_CONDITIONAL(DEFAULT_TARGET_TILEGX, test "$targ_obj" = "tilegx")
208 # Remove any duplicates.
210 for t in $targetobjs; do
218 if test -n "$targ_32_little"; then
219 AC_DEFINE(HAVE_TARGET_32_LITTLE, 1,
220 [Define to support 32-bit little-endian targets])
222 if test -n "$targ_32_big"; then
223 AC_DEFINE(HAVE_TARGET_32_BIG, 1,
224 [Define to support 32-bit big-endian targets])
226 if test -n "$targ_64_little"; then
227 AC_DEFINE(HAVE_TARGET_64_LITTLE, 1,
228 [Define to support 64-bit little-endian targets])
230 if test -n "$targ_64_big"; then
231 AC_DEFINE(HAVE_TARGET_64_BIG, 1,
232 [Define to support 64-bit big-endian targets])
235 if test -n "$all_targets"; then
236 TARGETOBJS='$(ALL_TARGETOBJS)'
238 TARGETOBJS="$targetobjs"
242 AC_DEFINE_UNQUOTED(GOLD_DEFAULT_MACHINE, $default_machine,
243 [Default machine code])
244 AC_DEFINE_UNQUOTED(GOLD_DEFAULT_SIZE, $default_size,
245 [Default size (32 or 64)])
246 AC_DEFINE_UNQUOTED(GOLD_DEFAULT_BIG_ENDIAN, $default_big_endian,
247 [Default big endian (true or false)])
248 AC_DEFINE_UNQUOTED(GOLD_DEFAULT_OSABI, $default_osabi,
249 [Default OSABI code])
251 AC_ARG_WITH(lib-path,
252 [ --with-lib-path=dir1:dir2... set default LIB_PATH],
254 yes) LIB_PATH='"/lib:/usr/lib"' ;;
256 *) LIB_PATH='"'"$withval"'"' ;;
258 [LIB_PATH='"::DEFAULT::"'])
259 AC_DEFINE_UNQUOTED(LIB_PATH, $LIB_PATH,
260 [Default library search path])
261 if test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias"; then
262 AC_DEFINE(NATIVE_LINKER, 1, [Whether configured as a native linker])
265 AC_CHECK_TOOL(NM, nm)
276 ZW_GNU_GETTEXT_SISTER_DIR
283 AM_CONDITIONAL(NATIVE_LINKER,
284 test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias")
285 AM_CONDITIONAL(GCC, test "$GCC" = yes)
287 AM_CONDITIONAL(NATIVE_OR_CROSS_LINKER,
288 test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias" -o "x$host_alias" = "x$build_alias")
290 dnl Test for whether static linking is supported. Some systems do not
291 dnl install static libraries. This only affects the set of tests that
293 AC_CACHE_CHECK([whether static linking works], [gold_cv_lib_static],
294 [LDFLAGS_hold=$LDFLAGS
295 LDFLAGS="$LDFLAGS -static"
297 AC_LANG_PROGRAM([[void f() { }]])],
298 [gold_cv_lib_static=yes], [gold_cv_lib_static=no])
299 LDFLAGS=$LDFLAGS_hold])
300 AM_CONDITIONAL(HAVE_STATIC, test "$gold_cv_lib_static" = "yes")
302 dnl Some architectures do not support taking pointers of functions
303 dnl defined in shared libraries except in -fPIC mode. We need to
304 dnl tell the unittest framework if we're compiling for one of those
305 dnl targets, so it doesn't try to run the tests that do that.
306 AM_CONDITIONAL(FN_PTRS_IN_SO_WITHOUT_PIC, [
314 dnl Test for gcc 4.1 or later. Full support for -mcmodel=medium is
315 dnl only available in gcc 4.1.
316 AC_CACHE_CHECK([for gcc >= 4.1], [gold_cv_prog_gcc41],
318 #if !defined __GNUC__
320 #elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
323 ], [gold_cv_prog_gcc41=yes], [gold_cv_prog_gcc41=no])])
325 save_CFLAGS="$CFLAGS"
326 CFLAGS="$CFLAGS -mcmodel=medium"
327 AC_COMPILE_IFELSE([int i;], [have_mcmodel_medium=yes], [have_mcmodel_medium=no])
328 CFLAGS="$save_CFLAGS"
329 dnl Whether we can test -mcmodel=medium.
330 AM_CONDITIONAL(MCMODEL_MEDIUM,
331 [test "$target_cpu" = "x86_64" -a "$have_mcmodel_medium" = "yes" -a "$gold_cv_prog_gcc41" = "yes"])
333 dnl Test for __thread support.
334 AC_CACHE_CHECK([for thread support], [gold_cv_c_thread],
335 [AC_COMPILE_IFELSE([__thread int i = 1;],
336 [gold_cv_c_thread=yes], [gold_cv_c_thread=no])])
338 AM_CONDITIONAL(TLS, test "$gold_cv_c_thread" = "yes")
340 dnl On GNU/Linux TLS in static programs only works when using glibc
342 AC_CACHE_CHECK([for glibc >= 2.4], [gold_cv_lib_glibc24],
344 #include <features.h>
345 #if !defined __GLIBC__
347 #elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4)
350 ], [gold_cv_lib_glibc24=yes], [gold_cv_lib_glibc24=no])])
352 AM_CONDITIONAL(STATIC_TLS, test "$gold_cv_lib_glibc24" = "yes")
354 dnl Test for #pragma omp threadprivate
355 AC_CACHE_CHECK([for omp support], [gold_cv_c_threadprivate],
356 [save_CFLAGS="$CFLAGS"
357 CFLAGS="$CFLAGS -fopenmp"
361 #pragma omp threadprivate (i)
362 ], [gold_cv_c_threadprivate=yes], [gold_cv_c_threadprivate=no])
363 CFLAGS="$save_CFLAGS"])
364 if test "$gold_cv_c_threadprivate" = "yes"; then
365 AC_DEFINE(HAVE_OMP_SUPPORT, 1,
366 [Define if compiler supports #pragma omp threadprivate])
368 AM_CONDITIONAL(OMP_SUPPORT, test "$gold_cv_c_threadprivate" = "yes")
370 dnl Test for the -ftls-dialect=gnu2 option.
371 save_CFLAGS="$CFLAGS"
372 CFLAGS="$CFLAGS -fpic -mtls-dialect=gnu2"
379 ], [have_tls_gnu2=yes], [have_tls_gnu2=no])
380 CFLAGS="$save_CFLAGS"
381 AM_CONDITIONAL(TLS_GNU2_DIALECT, test "$have_tls_gnu2" = "yes")
383 dnl On GNU/Linux TLS descriptors are supported by the dynamic loader
384 dnl only with glibc 2.9 or later.
385 AC_CACHE_CHECK([for glibc >= 2.9], [gold_cv_lib_glibc29],
387 #include <features.h>
388 #if !defined __GLIBC__
390 #elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 9)
393 ], [gold_cv_lib_glibc29=yes], [gold_cv_lib_glibc29=no])])
395 AM_CONDITIONAL(TLS_DESCRIPTORS, test "$gold_cv_lib_glibc29" = "yes")
397 dnl Test for the -frandom-seed option.
398 AC_CACHE_CHECK([for -frandom-seed support], [gold_cv_c_random_seed],
399 [save_CFLAGS="$CFLAGS"
400 CFLAGS="$CFLAGS -frandom-seed=foo"
401 AC_COMPILE_IFELSE([int i;], [gold_cv_c_random_seed=yes],
402 [gold_cv_c_random_seed=no])
403 CFLAGS="$save_CFLAGS"])
404 if test "$gold_cv_c_random_seed" = "yes"; then
405 # In Makefile, '$@' will be expanded to be the name of the file
406 # being built, providing a unique seed for each file.
407 RANDOM_SEED_CFLAGS=-frandom-seed=\$@
409 AC_SUBST(RANDOM_SEED_CFLAGS)
411 dnl On GNU/Linux ifunc is supported by the dynamic linker in glibc
412 dnl 2.11 or later, and by binutils 2.20.1 or later.
413 AC_CACHE_CHECK([for glibc ifunc support], [gold_cv_lib_glibc_ifunc],
414 [save_LDFLAGS="$LDFLAGS"
415 LDFLAGS="$LDFLAGS -static"
416 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
417 #include <features.h>
418 #if !defined __GLIBC__
420 #elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 11)
425 __asm__(".type invoke, %gnu_indirect_function");
426 typedef void (*funcptr) (void);
427 funcptr dispatch (void) __asm__ ("invoke");
428 funcptr dispatch (void) { return &func; }]],
431 if ${NM} conftest$EXEEXT | grep "__rela\?_iplt_start" >/dev/null 2>&1; then
432 gold_cv_lib_glibc_ifunc=both
434 gold_cv_lib_glibc_ifunc=dyn
435 fi], [gold_cv_lib_glibc_ifunc=no])
436 LDFLAGS="$save_LDFLAGS"])
438 AM_CONDITIONAL(IFUNC, test "$gold_cv_lib_glibc_ifunc" != "no")
439 AM_CONDITIONAL(IFUNC_STATIC, test "$gold_cv_lib_glibc_ifunc" = "both")
443 WARN_CXXFLAGS=`echo ${WARN_CFLAGS} | sed -e 's/-Wstrict-prototypes//' -e 's/-Wmissing-prototypes//' -e 's/-Wshadow//'`
444 AC_SUBST(WARN_CXXFLAGS)
446 AC_ARG_WITH(gold-ldflags,
447 [ --with-gold-ldflags=FLAGS additional link flags for gold],
448 [if test "$withval" = "no" -o "$withval" = "yes"; then
451 GOLD_LDFLAGS=$withval
454 AC_SUBST(GOLD_LDFLAGS)
456 AC_ARG_WITH(gold-ldadd,
457 [ --with-gold-ldadd=LIBS additional libraries for gold],
458 [if test "$withval" = "no" -o "$withval" = "yes"; then
466 dnl Force support for large files by default. This may need to be
467 dnl host dependent. If build == host, we can check getconf LFS_CFLAGS.
468 LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
471 AC_CHECK_HEADERS(sys/mman.h)
472 AC_CHECK_FUNCS(chsize mmap)
473 AC_REPLACE_FUNCS(pread ftruncate ffsll)
475 AC_CACHE_CHECK([mremap with MREMAP_MAYMOVE], [gold_cv_lib_mremap_maymove],
478 #include <sys/mman.h>
479 void f() { mremap (0, 0, 0, MREMAP_MAYMOVE); }
480 ]])], [gold_cv_lib_mremap_maymove=yes], [gold_cv_lib_mremap_maymove=no])])
481 if test "$gold_cv_lib_mremap_maymove" = "yes"; then
482 AC_DEFINE(HAVE_MREMAP, 1,
483 [Define to 1 if you have the mremap function with MREMAP_MAYMOVE support])
488 # Link in zlib if we can. This allows us to write compressed sections.
490 AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_header_zlib_h" = "yes")
492 dnl We have to check these in C, not C++, because autoconf generates
493 dnl tests which have no type information, and current glibc provides
494 dnl multiple declarations of functions like basename when compiling
496 AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp])
500 AC_CHECK_HEADERS(tr1/unordered_set tr1/unordered_map)
501 AC_CHECK_HEADERS(ext/hash_map ext/hash_set)
502 AC_CHECK_HEADERS(byteswap.h)
503 AC_CHECK_FUNCS(mallinfo posix_fallocate fallocate readv sysconf times)
504 AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem])
506 # Use of ::std::tr1::unordered_map::rehash causes undefined symbols
507 # at link time with some versions of GCC.
508 AC_CACHE_CHECK([whether ::std::tr1::unordered_map::rehash is usable.],
509 [gold_cv_unordered_map_rehash],
510 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
511 #include <tr1/unordered_map>
512 void bar() { ::std::tr1::unordered_map<int, int> x; x.rehash(10); }
513 ]])], [gold_cv_unordered_map_rehash=yes], [gold_cv_unordered_map_rehash=no])])
514 if test "$gold_cv_unordered_map_rehash" = "yes"; then
515 AC_DEFINE(HAVE_TR1_UNORDERED_MAP_REHASH, 1,
516 [Define if ::std::tr1::unordered_map::rehash is usable])
519 # Use of tr1/unordered_map with off_t as a key is not supported on GCC
520 # 4.1.xx when compiling in 32-bit mode with a 64-bit off_t type.
521 AC_CACHE_CHECK([whether std::tr1::hash<off_t> is defined],
522 [gold_cv_hash_off_t],
523 [CXXFLAGS_hold=$CXXFLAGS
524 CXXFLAGS="$CXXFLAGS $LFS_CFLAGS"
526 #include <sys/types.h>
527 #include <tr1/unordered_map>
528 std::tr1::hash<off_t> h;
530 [gold_cv_hash_off_t=yes],
531 [gold_cv_hash_off_t=no])
532 CXXFLAGS=$CFLAGS_hold])
533 if test "$gold_cv_hash_off_t" = "yes"; then
534 AC_DEFINE(HAVE_TR1_HASH_OFF_T, 1,
535 [Define if std::tr1::hash<off_t> is usable])
538 # gcc 4.3.0 doesn't recognize the printf attribute on a template
539 # function. Check for that. This is gcc bug 35546. This test can
540 # probably be removed after the bug has been fixed for a while.
541 AC_CACHE_CHECK([whether we can use attributes with template functions],
542 [gold_cv_template_attribute],
544 template<typename T> extern void foo(const char*, ...)
545 __attribute__ ((__format__ (__printf__, 1, 2)));
546 template<typename T> void foo(const char* format, ...) {}
547 void bar() { foo<int>("%s\n", "foo"); }
548 ], [gold_cv_template_attribute=yes], [gold_cv_template_attribute=no])])
549 if test "$gold_cv_template_attribute" = "yes"; then
550 AC_DEFINE(HAVE_TEMPLATE_ATTRIBUTES, 1,
551 [Define if attributes work on C++ templates])
554 dnl Check if the system has struct stat::st_mtim.
555 AC_CACHE_CHECK([for struct stat::st_mtim.],
556 [gold_cv_stat_st_mtim],
557 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
558 #include <sys/stat.h>
559 long bar() { struct stat s; return (long)(s.st_mtim.tv_sec + s.st_mtim.tv_sec);}
560 ]])], [gold_cv_stat_st_mtim=yes], [gold_cv_stat_st_mtim=no])])
561 if test "$gold_cv_stat_st_mtim" = "yes"; then
562 AC_DEFINE(HAVE_STAT_ST_MTIM, 1,
563 [Define if struct stat has a field st_mtim with timespec for mtime])
566 dnl Check if gcc supports the -gpubnames option.
567 save_CXXFLAGS="$CXXFLAGS"
568 CXXFLAGS="$CXXFLAGS -gpubnames"
569 AC_COMPILE_IFELSE([int i;], [have_pubnames=yes], [have_pubnames=no])
570 CXXFLAGS="$save_CXXFLAGS"
571 AM_CONDITIONAL(HAVE_PUBNAMES, test "$have_pubnames" = "yes")
575 AC_CHECK_HEADERS(locale.h)
576 AC_CHECK_FUNCS(setlocale)
581 AC_OUTPUT(Makefile testsuite/Makefile po/Makefile.in:po/Make-in)