configure.ac 20 KB

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