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