configure.ac 22 KB

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