]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gold/configure.ac
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gold / configure.ac
CommitLineData
bae7f79e 1dnl Process this file with autoconf to produce a configure script.
5bf135a7 2dnl
a2c58332 3dnl Copyright (C) 2006-2022 Free Software Foundation, Inc.
5bf135a7
NC
4dnl
5dnl This file is free software; you can redistribute it and/or modify
6dnl it under the terms of the GNU General Public License as published by
7dnl the Free Software Foundation; either version 3 of the License, or
8dnl (at your option) any later version.
2b64b551 9dnl
5bf135a7
NC
10dnl This program is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13dnl GNU General Public License for more details.
2b64b551 14dnl
5bf135a7
NC
15dnl You should have received a copy of the GNU General Public License
16dnl along with this program; see the file COPYING3. If not see
17dnl <http://www.gnu.org/licenses/>.
18dnl
bae7f79e 19
8486ee48
ILT
20AC_INIT(gold, 0.1)
21AC_CONFIG_SRCDIR(gold.cc)
bae7f79e
ILT
22
23AC_CANONICAL_TARGET
24
6ea55b82 25AM_INIT_AUTOMAKE([no-dist parallel-tests])
360ef3b9 26AM_SILENT_RULES([yes])
bae7f79e
ILT
27
28AM_CONFIG_HEADER(config.h:config.in)
29
24538276
CC
30AC_USE_SYSTEM_EXTENSIONS
31
df7b86aa
NC
32# PR 14072
33AH_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). */
0a6f1bf2 36#if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
df7b86aa
NC
37# error config.h must be #included before system headers
38#endif
39#define __CONFIG_H__ 1])
40
ad2d6943
ILT
41AC_ARG_WITH(sysroot,
42[ --with-sysroot[=DIR] search for usr/lib et al within DIR],
43[sysroot=$withval], [sysroot=no])
44
45if test "$sysroot" = "yes"; then
46 sysroot='${exec_prefix}/${target_alias}/sys-root'
47elif test "$sysroot" = "no"; then
48 sysroot=
49fi
50
51sysroot_relocatable=0
52if test -n "$sysroot"; then
7a34932b 53 case "$sysroot" in
ad2d6943
ILT
54 "${prefix}" | "${prefix}/"* | \
55 "${exec_prefix}" | "${exec_prefix}/"* | \
56 '${prefix}' | '${prefix}/'*| \
57 '${exec_prefix}' | '${exec_prefix}/'*)
58 sysroot_relocatable=1
59 ;;
60 esac
61fi
62
63AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT, "$sysroot",
64 [System root for target files])
65AC_DEFINE_UNQUOTED(TARGET_SYSTEM_ROOT_RELOCATABLE, $sysroot_relocatable,
66 [Whether the system root can be relocated])
67
4fda8867
NC
68dnl "install_as_default" is true if the linker to be installed as the
69dnl default linker, ld.
70dnl "installed_linker" is the installed gold linker name.
c7791212 71
f2a6224b 72installed_linker=ld.gold
c7791212
NC
73AC_ARG_ENABLE(gold,
74[[ --enable-gold[=ARG] build gold [ARG={default,yes,no}]]],
75[case "${enableval}" in
f2a6224b
L
76 default)
77 install_as_default=yes
78 ;;
79 yes)
80 if test x${enable_ld} = xno; then
c7791212
NC
81 install_as_default=yes
82 fi
4fda8867
NC
83 ;;
84 esac],
f2a6224b 85[install_as_default=no])
4fda8867
NC
86AC_SUBST(install_as_default)
87AC_SUBST(installed_linker)
88
24538276 89AC_PLUGINS
89fc3421
CC
90if test "$plugins" = "yes"; then
91 AC_DEFINE(ENABLE_PLUGINS, 1,
92 [Define to enable linker plugins])
93fi
94AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
fe9a4c12 95
6b1edb94
L
96# Decide if -z relro should be enabled in ELF linker by default.
97ac_default_ld_z_relro=unset
98# Provide a configure time option to override our default.
99AC_ARG_ENABLE(relro,
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 ;;
105esac])dnl
106if test "${ac_default_ld_z_relro}" = unset; then
107 ac_default_ld_z_relro=1
108fi
109AC_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.])
112
193a53d9
ILT
113AC_ARG_ENABLE([targets],
114[ --enable-targets alternative target configurations],
115[case "${enableval}" in
116 yes | "")
117 AC_MSG_ERROR([--enable-targets option must specify target names or 'all'])
118 ;;
119 no)
120 enable_targets=
121 ;;
122 *)
123 enable_targets=$enableval
124 ;;
125esac],
126[# For now, enable all targets by default
127 enable_targets=all
128])
129
130# Canonicalize the enabled targets.
131if 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"
136 else
137 # Permit unrecognized target names, like "all".
138 canon_targets="$canon_targets $targ"
139 fi
140 done
141fi
142
2760f24c
RG
143# Decide which "--hash-style" to use by default
144# Provide a configure time option to override our default.
145AC_ARG_ENABLE([default-hash-style],
146AS_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]) ;;
151esac],
152[case "${target}" in
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 ;;
157esac])
158
159AC_DEFINE_UNQUOTED([DEFAULT_HASH_STYLE],
160 ["${enable_default_hash_style}"],
161 [Set the default --hash-style value])
162
193a53d9 163# See which specific instantiations we need.
6df6da4a
ILT
164targetobjs=
165all_targets=
fbfba508
ILT
166default_machine=
167default_size=
168default_big_endian=
36959681 169default_osabi=ELFOSABI_NONE
fbfba508
ILT
170targ_32_little=
171targ_32_big=
172targ_64_little=
173targ_64_big=
193a53d9 174for targ in $target $canon_targets; do
193a53d9
ILT
175 if test "$targ" = "all"; then
176 targ_32_little=yes
177 targ_32_big=yes
178 targ_64_little=yes
179 targ_64_big=yes
6df6da4a 180 all_targets=yes
193a53d9 181 else
fbfba508
ILT
182 . ${srcdir}/configure.tgt
183
184 if test "$targ_obj" = "UNKNOWN"; then
6df6da4a 185 AC_MSG_ERROR("unsupported target $targ")
fbfba508
ILT
186 else
187 targetobjs="$targetobjs ${targ_obj}.\$(OBJEXT)"
60b2b4e7
ILT
188 if test "$targ_extra_obj" != ""; then
189 targetobjs="$targetobjs ${targ_extra_obj}.\$(OBJEXT)"
190 fi
f5314dd5
DM
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
194 targ_32_big=yes
195 fi
196 if test "$targ_big_endian" = "false" \
197 -o "$targ_extra_big_endian" = "false"; then
198 targ_32_little=yes
199 fi
200 fi
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
204 targ_64_big=yes
205 fi
206 if test "$targ_big_endian" = "false" \
207 -o "$targ_extra_big_endian" = "false"; then
208 targ_64_little=yes
209 fi
fbfba508
ILT
210 fi
211
212 if test "$target" = "$targ"; then
213 default_machine=$targ_machine
214 default_size=$targ_size
215 default_big_endian=$targ_big_endian
36959681 216 default_osabi=$targ_osabi
364c7fa5 217
053a4d68 218 AM_CONDITIONAL(DEFAULT_TARGET_AARCH64, test "$targ_obj" = "aarch64")
364c7fa5
ILT
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")
e79a4bad 223 AM_CONDITIONAL(DEFAULT_TARGET_S390, test "$targ_obj" = "s390")
4fc1b9d4
L
224 target_x86_64=no
225 target_x32=no
226 if test "$targ_obj" = "x86_64"; then
227 case "$target" in
228 x86_64*-linux-gnux32)
229 target_x32=yes
be66981e 230 default_size=32
4fc1b9d4
L
231 ;;
232 *)
233 target_x86_64=yes
234 ;;
235 esac
236 fi
237 AM_CONDITIONAL(DEFAULT_TARGET_X86_64, test "$target_x86_64" = "yes")
238 AM_CONDITIONAL(DEFAULT_TARGET_X32, test "$target_x32" = "yes")
ad961eab
L
239 AM_CONDITIONAL(DEFAULT_TARGET_X86_64_OR_X32,
240 test "$target_x86_64" = "yes" -o "$target_x32" = "yes")
5c0b3823 241 AM_CONDITIONAL(DEFAULT_TARGET_TILEGX, test "$targ_obj" = "tilegx")
9810d34d 242 AM_CONDITIONAL(DEFAULT_TARGET_MIPS, test "$targ_obj" = "mips")
9df9de2c
CC
243 DEFAULT_TARGET=${targ_obj}
244 AC_SUBST(DEFAULT_TARGET)
fbfba508
ILT
245 fi
246 fi
193a53d9
ILT
247 fi
248done
249
6cfaf60b 250# Remove any duplicates.
9109c078
ILT
251to=""
252for t in $targetobjs; do
253 case " $to " in
254 *" $t "*) ;;
255 *) to="$to $t" ;;
256 esac
257done
258targetobjs=$to
6cfaf60b 259
193a53d9
ILT
260if test -n "$targ_32_little"; then
261 AC_DEFINE(HAVE_TARGET_32_LITTLE, 1,
262 [Define to support 32-bit little-endian targets])
263fi
264if test -n "$targ_32_big"; then
265 AC_DEFINE(HAVE_TARGET_32_BIG, 1,
266 [Define to support 32-bit big-endian targets])
267fi
268if test -n "$targ_64_little"; then
269 AC_DEFINE(HAVE_TARGET_64_LITTLE, 1,
270 [Define to support 64-bit little-endian targets])
271fi
272if test -n "$targ_64_big"; then
273 AC_DEFINE(HAVE_TARGET_64_BIG, 1,
274 [Define to support 64-bit big-endian targets])
275fi
276
6df6da4a
ILT
277if test -n "$all_targets"; then
278 TARGETOBJS='$(ALL_TARGETOBJS)'
279else
280 TARGETOBJS="$targetobjs"
281fi
282AC_SUBST(TARGETOBJS)
283
fbfba508
ILT
284AC_DEFINE_UNQUOTED(GOLD_DEFAULT_MACHINE, $default_machine,
285 [Default machine code])
286AC_DEFINE_UNQUOTED(GOLD_DEFAULT_SIZE, $default_size,
287 [Default size (32 or 64)])
288AC_DEFINE_UNQUOTED(GOLD_DEFAULT_BIG_ENDIAN, $default_big_endian,
289 [Default big endian (true or false)])
36959681
ILT
290AC_DEFINE_UNQUOTED(GOLD_DEFAULT_OSABI, $default_osabi,
291 [Default OSABI code])
fbfba508 292
3f3cddf1
ILT
293AC_ARG_WITH(lib-path,
294[ --with-lib-path=dir1:dir2... set default LIB_PATH],
295[case "$withval" in
296 yes) LIB_PATH='"/lib:/usr/lib"' ;;
297 no) LIB_PATH='""' ;;
298 *) LIB_PATH='"'"$withval"'"' ;;
299 esac],
300[LIB_PATH='"::DEFAULT::"'])
301AC_DEFINE_UNQUOTED(LIB_PATH, $LIB_PATH,
302 [Default library search path])
303if 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])
305fi
306
ebb300b2
CC
307AC_CHECK_TOOL(NM, nm)
308
bae7f79e
ILT
309AC_PROG_CC
310AC_PROG_CXX
dbe717ef 311AC_PROG_YACC
5a6f7e2d 312AC_PROG_RANLIB
bae7f79e 313AC_PROG_INSTALL
537b5f51 314AC_PROG_LN_S
fa99aa09
ILT
315
316AC_GNU_SOURCE
317
bae7f79e
ILT
318ZW_GNU_GETTEXT_SISTER_DIR
319AM_PO_SUBDIRS
320
92e059d8
ILT
321AC_C_BIGENDIAN
322
bae7f79e
ILT
323AC_EXEEXT
324
537b5f51
ILT
325AM_CONDITIONAL(NATIVE_LINKER,
326 test "x$target_alias" = "x" -o "x$host_alias" = "x$target_alias")
327AM_CONDITIONAL(GCC, test "$GCC" = yes)
328
eb373049
ILT
329AM_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")
331
328c7c2f
ILT
332dnl Test for whether static linking is supported. Some systems do not
333dnl install static libraries. This only affects the set of tests that
334dnl we run.
335AC_CACHE_CHECK([whether static linking works], [gold_cv_lib_static],
dd7af074 336[LDFLAGS_hold=$LDFLAGS
328c7c2f 337LDFLAGS="$LDFLAGS -static"
dd7af074 338AC_LINK_IFELSE([
328c7c2f 339AC_LANG_PROGRAM([[void f() { }]])],
dd7af074
ILT
340[gold_cv_lib_static=yes], [gold_cv_lib_static=no])
341LDFLAGS=$LDFLAGS_hold])
328c7c2f
ILT
342AM_CONDITIONAL(HAVE_STATIC, test "$gold_cv_lib_static" = "yes")
343
63402fe4
ILT
344dnl Some architectures do not support taking pointers of functions
345dnl defined in shared libraries except in -fPIC mode. We need to
346dnl tell the unittest framework if we're compiling for one of those
347dnl targets, so it doesn't try to run the tests that do that.
348AM_CONDITIONAL(FN_PTRS_IN_SO_WITHOUT_PIC, [
349 case $target_cpu in
864a1b56 350 powerpc*) false;;
63402fe4 351 x86_64) false;;
11936fb1 352 sparc64) false;;
e79a4bad 353 s390x) false;;
63402fe4
ILT
354 *) true;;
355 esac])
356
084e2665
ILT
357dnl Test for gcc 4.1 or later. Full support for -mcmodel=medium is
358dnl only available in gcc 4.1.
359AC_CACHE_CHECK([for gcc >= 4.1], [gold_cv_prog_gcc41],
d0ac1c44 360[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
084e2665
ILT
361#if !defined __GNUC__
362error
363#elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
364error
365#endif
d0ac1c44 366])], [gold_cv_prog_gcc41=yes], [gold_cv_prog_gcc41=no])])
084e2665 367
24482ca0
L
368save_CFLAGS="$CFLAGS"
369CFLAGS="$CFLAGS -mcmodel=medium"
d0ac1c44 370AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [have_mcmodel_medium=yes], [have_mcmodel_medium=no])
24482ca0 371CFLAGS="$save_CFLAGS"
8a5e3e08 372dnl Whether we can test -mcmodel=medium.
084e2665 373AM_CONDITIONAL(MCMODEL_MEDIUM,
24482ca0 374[test "$target_cpu" = "x86_64" -a "$have_mcmodel_medium" = "yes" -a "$gold_cv_prog_gcc41" = "yes"])
8a5e3e08 375
6c0005b8
L
376dnl Test for gcc 9 or later. Some incremental tests fail with GCC 9 or
377dnl later.
378AC_CACHE_CHECK([for gcc >= 9], [gold_cv_prog_gcc9],
379[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
380#if !defined __GNUC__ || __GNUC__ < 9
381error
382#endif
383])], [gold_cv_prog_gcc9=yes], [gold_cv_prog_gcc9=no])])
384AM_CONDITIONAL(GCC9, [test "$gold_cv_prog_gcc9" = "yes"])
385
386dnl Test for -fcf-protection on x86-64. Some incremental tests fail with
387dnl -fcf-protection.
388AC_CACHE_CHECK([for -fcf-protection], [gold_cv_cflags_cf_protection],
389[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
390#if !defined __x86_64__ || !defined __CET__
391error
392#endif
393])], [gold_cv_cflags_cf_protection=yes], [gold_cv_cflags_cf_protection=no])])
394AM_CONDITIONAL(CFLAGS_CF_PROTECTION, [test "$gold_cv_cflags_cf_protection" = "yes"])
395
2b64b551
RM
396AC_CACHE_CHECK([whether $CC supports -fmerge-constants],
397 [gold_cv_merge_constants], [
398save_CFLAGS="$CFLAGS"
399CFLAGS="$CFLAGS -fmerge-constants"
d0ac1c44 400AC_COMPILE_IFELSE([AC_LANG_SOURCE([const char *s = "foo";])],
2500c017
CC
401 [gold_cv_merge_constants=yes],
402 [gold_cv_merge_constants=no])
2b64b551
RM
403CFLAGS="$save_CFLAGS"])
404AC_SUBST([MERGE_CONSTANTS_FLAG])
405AS_IF([test "$gold_cv_merge_constants" = yes],
406 [MERGE_CONSTANTS_FLAG=-fmerge-constants],
407 [MERGE_CONSTANTS_FLAG=])
408
6eee141f 409dnl Test for __thread support.
097ec620 410AC_CACHE_CHECK([for thread support], [gold_cv_c_thread],
d0ac1c44 411[AC_COMPILE_IFELSE([AC_LANG_SOURCE([__thread int i = 1;])],
097ec620
ILT
412[gold_cv_c_thread=yes], [gold_cv_c_thread=no])])
413
414AM_CONDITIONAL(TLS, test "$gold_cv_c_thread" = "yes")
415
416dnl On GNU/Linux TLS in static programs only works when using glibc
417dnl 2.4 or later.
418AC_CACHE_CHECK([for glibc >= 2.4], [gold_cv_lib_glibc24],
d0ac1c44 419[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
097ec620
ILT
420#include <features.h>
421#if !defined __GLIBC__
422error
423#elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4)
424error
425#endif
d0ac1c44 426])], [gold_cv_lib_glibc24=yes], [gold_cv_lib_glibc24=no])])
097ec620
ILT
427
428AM_CONDITIONAL(STATIC_TLS, test "$gold_cv_lib_glibc24" = "yes")
6eee141f 429
155a0dd7
ILT
430dnl Test for #pragma omp threadprivate
431AC_CACHE_CHECK([for omp support], [gold_cv_c_threadprivate],
432[save_CFLAGS="$CFLAGS"
433CFLAGS="$CFLAGS -fopenmp"
d0ac1c44 434AC_COMPILE_IFELSE([AC_LANG_SOURCE([
155a0dd7
ILT
435#include <omp.h>
436int i;
437#pragma omp threadprivate (i)
d0ac1c44 438])], [gold_cv_c_threadprivate=yes], [gold_cv_c_threadprivate=no])
155a0dd7
ILT
439CFLAGS="$save_CFLAGS"])
440if test "$gold_cv_c_threadprivate" = "yes"; then
441 AC_DEFINE(HAVE_OMP_SUPPORT, 1,
442 [Define if compiler supports #pragma omp threadprivate])
443fi
444AM_CONDITIONAL(OMP_SUPPORT, test "$gold_cv_c_threadprivate" = "yes")
445
c2b45e22 446dnl Test for the -ftls-dialect=gnu2 option.
13323c49
RM
447dnl Use -Werror in case of compilers that make unknown -m options warnings.
448dnl They would pass the test here, but fail in actual use when $WARN_CFLAGS
449dnl gets set later by default Autoconf magic to include -Werror. (We are
450dnl assuming here that there is no compiler that groks -mtls-dialect=gnu2
451dnl but does not grok -Werror.)
c2b45e22 452save_CFLAGS="$CFLAGS"
13323c49 453CFLAGS="$CFLAGS -Werror -fpic -mtls-dialect=gnu2"
d0ac1c44 454AC_COMPILE_IFELSE([AC_LANG_SOURCE([
63887f3d
L
455__thread int i;
456void foo (void)
457{
458 i = 10;
459}
d0ac1c44 460])], [have_tls_gnu2=yes], [have_tls_gnu2=no])
c2b45e22
CC
461CFLAGS="$save_CFLAGS"
462AM_CONDITIONAL(TLS_GNU2_DIALECT, test "$have_tls_gnu2" = "yes")
463
464dnl On GNU/Linux TLS descriptors are supported by the dynamic loader
b0074644
ILT
465dnl only with glibc 2.9 or later.
466AC_CACHE_CHECK([for glibc >= 2.9], [gold_cv_lib_glibc29],
d0ac1c44 467[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
c2b45e22
CC
468#include <features.h>
469#if !defined __GLIBC__
470error
b0074644 471#elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 9)
c2b45e22
CC
472error
473#endif
d0ac1c44 474])], [gold_cv_lib_glibc29=yes], [gold_cv_lib_glibc29=no])])
c2b45e22 475
b0074644 476AM_CONDITIONAL(TLS_DESCRIPTORS, test "$gold_cv_lib_glibc29" = "yes")
c2b45e22 477
1d1f116d
CD
478dnl Test for the -frandom-seed option.
479AC_CACHE_CHECK([for -frandom-seed support], [gold_cv_c_random_seed],
480[save_CFLAGS="$CFLAGS"
481CFLAGS="$CFLAGS -frandom-seed=foo"
d0ac1c44 482AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [gold_cv_c_random_seed=yes],
1d1f116d
CD
483[gold_cv_c_random_seed=no])
484CFLAGS="$save_CFLAGS"])
485if 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=\$@
489fi
490AC_SUBST(RANDOM_SEED_CFLAGS)
491
7223e9ca 492dnl On GNU/Linux ifunc is supported by the dynamic linker in glibc
d0773f31 493dnl 2.11 or later, and by binutils 2.20.1 or later.
ebb300b2
CC
494AC_CACHE_CHECK([for glibc ifunc support], [gold_cv_lib_glibc_ifunc],
495[save_LDFLAGS="$LDFLAGS"
496LDFLAGS="$LDFLAGS -static"
497AC_LINK_IFELSE([AC_LANG_PROGRAM([[
7223e9ca
ILT
498#include <features.h>
499#if !defined __GLIBC__
500error
501#elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 11)
502error
503#endif
ebb300b2
CC
504void func (void) { }
505void invoke (void);
506__asm__(".type invoke, %gnu_indirect_function");
507typedef void (*funcptr) (void);
508funcptr dispatch (void) __asm__ ("invoke");
509funcptr dispatch (void) { return &func; }]],
510[[invoke();]])
511], [
512if ${NM} conftest$EXEEXT | grep "__rela\?_iplt_start" >/dev/null 2>&1; then
513 gold_cv_lib_glibc_ifunc=both
514else
515 gold_cv_lib_glibc_ifunc=dyn
516fi], [gold_cv_lib_glibc_ifunc=no])
517LDFLAGS="$save_LDFLAGS"])
7223e9ca 518
ebb300b2
CC
519AM_CONDITIONAL(IFUNC, test "$gold_cv_lib_glibc_ifunc" != "no")
520AM_CONDITIONAL(IFUNC_STATIC, test "$gold_cv_lib_glibc_ifunc" = "both")
7223e9ca 521
bae7f79e
ILT
522AM_BINUTILS_WARNINGS
523
2ea97941 524WARN_CXXFLAGS=`echo ${WARN_CFLAGS} | sed -e 's/-Wstrict-prototypes//' -e 's/-Wmissing-prototypes//' -e 's/-Wshadow//'`
bae7f79e
ILT
525AC_SUBST(WARN_CXXFLAGS)
526
dc87f620
ILT
527AC_ARG_WITH(gold-ldflags,
528[ --with-gold-ldflags=FLAGS additional link flags for gold],
529[if test "$withval" = "no" -o "$withval" = "yes"; then
530 GOLD_LDFLAGS=
531 else
532 GOLD_LDFLAGS=$withval
533 fi],
534[GOLD_LDFLAGS=])
535AC_SUBST(GOLD_LDFLAGS)
536
537AC_ARG_WITH(gold-ldadd,
538[ --with-gold-ldadd=LIBS additional libraries for gold],
539[if test "$withval" = "no" -o "$withval" = "yes"; then
540 GOLD_LDADD=
541 else
542 GOLD_LDADD=$withval
543 fi],
544[GOLD_LDADD=])
545AC_SUBST(GOLD_LDADD)
546
bae7f79e
ILT
547dnl Force support for large files by default. This may need to be
548dnl host dependent. If build == host, we can check getconf LFS_CFLAGS.
494e05f4
ILT
549LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
550AC_SUBST(LFS_CFLAGS)
bae7f79e 551
88597d34 552AC_CHECK_HEADERS(sys/mman.h)
f4238194 553AC_CHECK_FUNCS(chsize mmap link)
88597d34
ILT
554AC_REPLACE_FUNCS(pread ftruncate ffsll)
555
556AC_CACHE_CHECK([mremap with MREMAP_MAYMOVE], [gold_cv_lib_mremap_maymove],
557[AC_LINK_IFELSE([
558AC_LANG_PROGRAM([[
559#include <sys/mman.h>
560void f() { mremap (0, 0, 0, MREMAP_MAYMOVE); }
561]])], [gold_cv_lib_mremap_maymove=yes], [gold_cv_lib_mremap_maymove=no])])
562if 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])
565else
566 AC_LIBOBJ(mremap)
567fi
82dcae9d 568
9a0910c3 569# Link in zlib if we can. This allows us to write compressed sections.
ae2eea65 570AM_ZLIB
9a0910c3 571
c8dc28bc
CC
572AC_ARG_ENABLE([threads],
573[[ --enable-threads[=ARG] multi-threaded linking [ARG={auto,yes,no}]]],
574[case "${enableval}" in
575 yes | "") threads=yes ;;
576 no) threads=no ;;
577 auto) threads=auto ;;
578 *) threads=yes ;;
579 esac],
580[threads=auto])
581
582if test "$threads" = "yes"; then
583 AX_PTHREAD([threads=yes], AC_MSG_ERROR([pthread not found]))
584elif test "$threads" = "auto"; then
585 AX_PTHREAD([threads=yes], [threads=no])
586fi
587
588if test "$threads" = "yes"; then
589 AC_DEFINE(ENABLE_THREADS, 1,
590 [Define to do multi-threaded linking])
591fi
592AM_CONDITIONAL(THREADS, test "$threads" = "yes")
593
0639a6f6
ILT
594dnl We have to check these in C, not C++, because autoconf generates
595dnl tests which have no type information, and current glibc provides
596dnl multiple declarations of functions like basename when compiling
597dnl with C++.
598AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp])
599
ae447ddd
CC
600dnl Check if gcc supports the -gpubnames option.
601dnl Use -Werror in case of compilers that make unknown -g options warnings.
602dnl They would pass the test here, but fail in actual use when $WARN_CFLAGS
603dnl gets set later by default Autoconf magic to include -Werror. (We are
604dnl assuming here that there is no compiler that groks -gpubnames
605dnl but does not grok -Werror.)
606save_CFLAGS="$CFLAGS"
607CFLAGS="$CFLAGS -Werror -gpubnames"
d0ac1c44 608AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [have_pubnames=yes], [have_pubnames=no])
ae447ddd
CC
609CFLAGS="$save_CFLAGS"
610AM_CONDITIONAL(HAVE_PUBNAMES, test "$have_pubnames" = "yes")
611
612dnl Check if gcc supports the -fno-use-linker-plugin option.
613save_CFLAGS="$CFLAGS"
614CFLAGS="$CFLAGS -Werror -fno-use-linker-plugin"
d0ac1c44 615AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [have_no_use_linker_plugin=yes], [have_no_use_linker_plugin=no])
ae447ddd
CC
616CFLAGS="$save_CFLAGS"
617AM_CONDITIONAL(HAVE_NO_USE_LINKER_PLUGIN, test "$have_no_use_linker_plugin" = "yes")
618
54dc6425 619AC_LANG_PUSH(C++)
d288e464 620
8356f2d0 621AC_CHECK_HEADERS(unordered_set unordered_map)
54dc6425
ILT
622AC_CHECK_HEADERS(tr1/unordered_set tr1/unordered_map)
623AC_CHECK_HEADERS(ext/hash_map ext/hash_set)
15d5fa16 624AC_CHECK_HEADERS(byteswap.h)
0bf402d5 625
e755667f
NA
626dnl Check for bswap_{16,32,64}
627AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]])
628
0bf402d5 629dnl When plugins enabled dynamic loader interface is required. Check headers
6632e8cc 630dnl which may provide this interface. Add the necessary library to link.
0bf402d5 631AC_CHECK_HEADERS(windows.h)
6632e8cc
CC
632AC_CHECK_HEADERS(dlfcn.h)
633AC_SEARCH_LIBS(dlopen, [dl dld])
634case "$ac_cv_search_dlopen" in
635 no*) DLOPEN_LIBS="";;
636 *) DLOPEN_LIBS="$ac_cv_search_dlopen";;
637esac
0bf402d5
ILT
638AC_SUBST(DLOPEN_LIBS)
639
4ee60495 640AC_CHECK_FUNCS(mallinfo mallinfo2 posix_fallocate fallocate readv sysconf times mkdtemp)
3d857b98 641AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem])
d288e464 642
40fde488
CD
643# Use of ::std::tr1::unordered_map::rehash causes undefined symbols
644# at link time with some versions of GCC.
645AC_CACHE_CHECK([whether ::std::tr1::unordered_map::rehash is usable.],
646[gold_cv_unordered_map_rehash],
647[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
648#include <tr1/unordered_map>
649void bar() { ::std::tr1::unordered_map<int, int> x; x.rehash(10); }
650]])], [gold_cv_unordered_map_rehash=yes], [gold_cv_unordered_map_rehash=no])])
651if test "$gold_cv_unordered_map_rehash" = "yes"; then
652 AC_DEFINE(HAVE_TR1_UNORDERED_MAP_REHASH, 1,
653 [Define if ::std::tr1::unordered_map::rehash is usable])
654fi
655
81c82a68
ILT
656# Use of tr1/unordered_map with off_t as a key is not supported on GCC
657# 4.1.xx when compiling in 32-bit mode with a 64-bit off_t type.
658AC_CACHE_CHECK([whether std::tr1::hash<off_t> is defined],
659[gold_cv_hash_off_t],
660[CXXFLAGS_hold=$CXXFLAGS
661CXXFLAGS="$CXXFLAGS $LFS_CFLAGS"
d0ac1c44 662AC_COMPILE_IFELSE([AC_LANG_SOURCE([
81c82a68
ILT
663#include <sys/types.h>
664#include <tr1/unordered_map>
665std::tr1::hash<off_t> h;
d0ac1c44 666])],
81c82a68
ILT
667[gold_cv_hash_off_t=yes],
668[gold_cv_hash_off_t=no])
26e4ef59 669CXXFLAGS=$CXXFLAGS_hold])
81c82a68
ILT
670if test "$gold_cv_hash_off_t" = "yes"; then
671 AC_DEFINE(HAVE_TR1_HASH_OFF_T, 1,
672 [Define if std::tr1::hash<off_t> is usable])
673fi
674
04bf7072
ILT
675# gcc 4.3.0 doesn't recognize the printf attribute on a template
676# function. Check for that. This is gcc bug 35546. This test can
677# probably be removed after the bug has been fixed for a while.
678AC_CACHE_CHECK([whether we can use attributes with template functions],
679[gold_cv_template_attribute],
d0ac1c44 680[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
04bf7072
ILT
681template<typename T> extern void foo(const char*, ...)
682 __attribute__ ((__format__ (__printf__, 1, 2)));
683template<typename T> void foo(const char* format, ...) {}
684void bar() { foo<int>("%s\n", "foo"); }
d0ac1c44 685])], [gold_cv_template_attribute=yes], [gold_cv_template_attribute=no])])
04bf7072
ILT
686if test "$gold_cv_template_attribute" = "yes"; then
687 AC_DEFINE(HAVE_TEMPLATE_ATTRIBUTES, 1,
688 [Define if attributes work on C++ templates])
689fi
690
5d329b7d
ILT
691dnl Check if the system has struct stat::st_mtim.
692AC_CACHE_CHECK([for struct stat::st_mtim.],
693[gold_cv_stat_st_mtim],
694[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
695#include <sys/stat.h>
696long bar() { struct stat s; return (long)(s.st_mtim.tv_sec + s.st_mtim.tv_sec);}
697]])], [gold_cv_stat_st_mtim=yes], [gold_cv_stat_st_mtim=no])])
698if test "$gold_cv_stat_st_mtim" = "yes"; then
699 AC_DEFINE(HAVE_STAT_ST_MTIM, 1,
700 [Define if struct stat has a field st_mtim with timespec for mtime])
701fi
702
54dc6425
ILT
703AC_LANG_POP(C++)
704
58797674 705AC_CHECK_HEADERS(locale.h)
44350750
NC
706AC_CHECK_FUNCS(setlocale)
707AM_LC_MESSAGES
708
bae7f79e
ILT
709AM_MAINTAINER_MODE
710
5a6f7e2d 711AC_OUTPUT(Makefile testsuite/Makefile po/Makefile.in:po/Make-in)