configure.ac 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. # configure.ac -- Go library configure script.
  2. # Copyright 2009 The Go Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style
  4. # license that can be found in the LICENSE file.
  5. # Process this file with autoreconf to produce configure.
  6. AC_INIT(package-unused, version-unused,, libgo)
  7. AC_CONFIG_SRCDIR(Makefile.am)
  8. AC_CONFIG_HEADER(config.h)
  9. libtool_VERSION=21:0:0
  10. AC_SUBST(libtool_VERSION)
  11. AM_ENABLE_MULTILIB(, ..)
  12. AC_CANONICAL_SYSTEM
  13. target_alias=${target_alias-$host_alias}
  14. AM_INIT_AUTOMAKE([1.9.3 no-define foreign no-dist subdir-objects -Wall -Wno-portability -Wno-override])
  15. AH_TEMPLATE(PACKAGE, [Name of package])
  16. AH_TEMPLATE(VERSION, [Version number of package])
  17. m4_rename([_AC_ARG_VAR_PRECIOUS],[glibgo_PRECIOUS])
  18. m4_define([_AC_ARG_VAR_PRECIOUS],[])
  19. AC_PROG_CC
  20. AC_PROG_GO
  21. AM_PROG_AS
  22. m4_rename_force([glibgo_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
  23. AC_SUBST(CFLAGS)
  24. case ${host} in
  25. *-*-aix*)
  26. # Check default architecture for FAT library creation
  27. if test -z "`$CC -x c -E /dev/null -g3 -o - | grep 64BIT`" ; then
  28. AIX_EXTRA_ARCH='64'
  29. else
  30. AIX_EXTRA_ARCH='32'
  31. fi
  32. AC_SUBST(AIX_EXTRA_ARCH)
  33. ;;
  34. esac
  35. AM_MAINTAINER_MODE
  36. AC_PROG_LD
  37. AC_PROG_RANLIB
  38. AC_CHECK_TOOL(OBJCOPY, objcopy, missing-objcopy)
  39. AC_LIBTOOL_DLOPEN
  40. AM_PROG_LIBTOOL
  41. AC_SUBST(enable_shared)
  42. AC_SUBST(enable_static)
  43. CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
  44. AC_SUBST(CC_FOR_BUILD)
  45. AC_PROG_AWK
  46. WARN_FLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual'
  47. AC_SUBST(WARN_FLAGS)
  48. AC_ARG_ENABLE([werror],
  49. [AS_HELP_STRING([--disable-werror], [disable building with -Werror])])
  50. AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = "xyes"],
  51. [WERROR="-Werror"])
  52. AC_SUBST(WERROR)
  53. glibgo_toolexecdir=no
  54. glibgo_toolexeclibdir=no
  55. AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
  56. AC_ARG_ENABLE([version-specific-runtime-libs],
  57. AC_HELP_STRING([--enable-version-specific-runtime-libs],
  58. [Specify that runtime libraries should be installed in a compiler-specific directory]),
  59. [case "$enableval" in
  60. yes) version_specific_libs=yes ;;
  61. no) version_specific_libs=no ;;
  62. *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
  63. esac],
  64. [version_specific_libs=no])
  65. AC_MSG_RESULT($version_specific_libs)
  66. GCC_WITH_TOOLEXECLIBDIR
  67. # Version-specific runtime libs processing.
  68. if test $version_specific_libs = yes; then
  69. glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
  70. glibgo_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
  71. fi
  72. # Calculate glibgo_toolexecdir, glibgo_toolexeclibdir
  73. # Install a library built with a cross compiler in tooldir, not libdir.
  74. if test -n "$with_cross_host" &&
  75. test x"$with_cross_host" != x"no"; then
  76. nover_glibgo_toolexecdir='${exec_prefix}/${host_alias}'
  77. case ${with_toolexeclibdir} in
  78. no)
  79. nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
  80. ;;
  81. *)
  82. nover_glibgo_toolexeclibdir=${with_toolexeclibdir}
  83. ;;
  84. esac
  85. else
  86. nover_glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
  87. nover_glibgo_toolexeclibdir='${libdir}'
  88. fi
  89. multi_os_directory=`$GOC -print-multi-os-directory`
  90. case $multi_os_directory in
  91. .) ;; # Avoid trailing /.
  92. *) nover_glibgo_toolexeclibdir=${nover_glibgo_toolexeclibdir}/${multi_os_directory} ;;
  93. esac
  94. if test x"$glibgo_toolexecdir" = x"no"; then
  95. glibgo_toolexecdir="${nover_glibgo_toolexecdir}"
  96. glibgo_toolexeclibdir="${nover_glibgo_toolexeclibdir}"
  97. fi
  98. AC_SUBST(glibgo_toolexecdir)
  99. AC_SUBST(glibgo_toolexeclibdir)
  100. AC_SUBST(nover_glibgo_toolexeclibdir)
  101. # See if the user wants to configure without libffi. Some
  102. # architectures don't support it. FIXME: We should set a default
  103. # based on the host.
  104. AC_ARG_WITH(libffi,
  105. AS_HELP_STRING([--without-libffi],
  106. [don't use libffi]),
  107. [:],
  108. [with_libffi=${with_libffi_default-yes}])
  109. LIBFFI=
  110. LIBFFIINCS=
  111. if test "$with_libffi" != no; then
  112. AC_DEFINE(USE_LIBFFI, 1, [Define if we're to use libffi.])
  113. LIBFFI=../libffi/libffi_convenience.la
  114. LIBFFIINCS='-I$(top_srcdir)/../libffi/include -I../libffi/include'
  115. fi
  116. AC_SUBST(LIBFFI)
  117. AC_SUBST(LIBFFIINCS)
  118. AM_CONDITIONAL(USE_LIBFFI, test "$with_libffi" != "no")
  119. # See if the user wants to configure without libatomic. This is useful if we are
  120. # on an architecture for which libgo does not need an atomic support library and
  121. # libatomic does not support our C compiler.
  122. AC_ARG_WITH(libatomic,
  123. AS_HELP_STRING([--without-libatomic],
  124. [don't use libatomic]),
  125. [:],
  126. [with_libatomic=${with_libatomic_default-yes}])
  127. LIBATOMIC=
  128. if test "$with_libatomic" != no; then
  129. LIBATOMIC=../libatomic/libatomic_convenience.la
  130. fi
  131. AC_SUBST(LIBATOMIC)
  132. # Used to tell GNU make to include a file without telling automake to
  133. # include it.
  134. go_include="-include"
  135. AC_SUBST(go_include)
  136. # All known GOOS values. This is the union of all operating systems
  137. # supported by the gofrontend and all operating systems supported by
  138. # the gc toolchain.
  139. ALLGOOS="aix android darwin dragonfly freebsd hurd illumos ios irix js linux netbsd openbsd plan9 rtems solaris windows zos"
  140. is_darwin=no
  141. is_freebsd=no
  142. is_irix=no
  143. is_linux=no
  144. is_netbsd=no
  145. is_openbsd=no
  146. is_dragonfly=no
  147. is_rtems=no
  148. is_solaris=no
  149. is_aix=no
  150. is_hurd=no
  151. GOOS=unknown
  152. case ${host} in
  153. *-*-darwin*) is_darwin=yes; GOOS=darwin ;;
  154. *-*-freebsd*) is_freebsd=yes; GOOS=freebsd ;;
  155. *-*-irix6*) is_irix=yes; GOOS=irix ;;
  156. *-*-linux*) is_linux=yes; GOOS=linux ;;
  157. *-*-netbsd*) is_netbsd=yes; GOOS=netbsd ;;
  158. *-*-openbsd*) is_openbsd=yes; GOOS=openbsd ;;
  159. *-*-dragonfly*) is_dragonfly=yes; GOOS=dragonfly ;;
  160. *-*-rtems*) is_rtems=yes; GOOS=rtems ;;
  161. *-*-solaris2*) is_solaris=yes; GOOS=solaris ;;
  162. *-*-aix*) is_aix=yes; GOOS=aix ;;
  163. *-*-gnu*) is_hurd=yes; GOOS=hurd ;;
  164. esac
  165. AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes)
  166. AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes)
  167. AM_CONDITIONAL(LIBGO_IS_IRIX, test $is_irix = yes)
  168. AM_CONDITIONAL(LIBGO_IS_LINUX, test $is_linux = yes)
  169. AM_CONDITIONAL(LIBGO_IS_NETBSD, test $is_netbsd = yes)
  170. AM_CONDITIONAL(LIBGO_IS_OPENBSD, test $is_openbsd = yes)
  171. AM_CONDITIONAL(LIBGO_IS_DRAGONFLY, test $is_dragonfly = yes)
  172. AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes)
  173. AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes)
  174. AM_CONDITIONAL(LIBGO_IS_AIX, test $is_aix = yes)
  175. AM_CONDITIONAL(LIBGO_IS_HURD, test $is_hurd = yes)
  176. AM_CONDITIONAL(LIBGO_IS_BSD, test $is_darwin = yes -o $is_dragonfly = yes -o $is_freebsd = yes -o $is_netbsd = yes -o $is_openbsd = yes)
  177. AC_SUBST(GOOS)
  178. AC_SUBST(ALLGOOS)
  179. dnl Test whether we need to use DejaGNU or whether we can use the
  180. dnl simpler gotest approach. We can only use gotest for a native
  181. dnl build.
  182. USE_DEJAGNU=no
  183. case ${host} in
  184. *-*-rtems*) USE_DEJAGNU=yes ;;
  185. ${build}) ;;
  186. *) USE_DEJAGNU=yes ;;
  187. esac
  188. AC_SUBST(USE_DEJAGNU)
  189. # All known GOARCH values. This is the union of all architectures
  190. # supported by the gofrontend and all architectures supported by the
  191. # gc toolchain.
  192. # To add a new architecture:
  193. # - add it to this list
  194. # - if appropriate, add an entry to ALLGOARCHFAMILY below
  195. # - add an entry to the case on ${host} below to set GOARCH
  196. # - update goarchList in libgo/go/go/build/syslist.go
  197. # - update goarch.sh to report the values for this architecture
  198. # - update go-set-goarch in gcc/testsuite/go.test/go-test.exp
  199. # - update ptrSizeMap and intSizeMap in libgo/go/cmd/cgo/main.go
  200. # - update arch lists in libgo/match.sh
  201. # - update arch lists in libgo/testsuite/gotest
  202. # - update +build lines in several places
  203. # - libgo/go/runtime/lfstack_NNbit.go
  204. # - libgo/go/runtime/hashNN.go
  205. # - libgo/go/runtime/unalignedN.go
  206. # - libgo/go/syscall/endian_XX.go
  207. # - possibly others
  208. # - possibly update files in libgo/go/internal/syscall/unix
  209. ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mips mipsle mips64 mips64le mips64p32 mips64p32le nios2 ppc ppc64 ppc64le riscv riscv64 s390 s390x sh shbe sparc sparc64 wasm"
  210. # All known GOARCH family values.
  211. ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 NIOS2 PPC PPC64 RISCV RISCV64 S390 S390X SH SPARC SPARC64 WASM"
  212. GOARCH=unknown
  213. case ${host} in
  214. alpha*-*-*)
  215. GOARCH=alpha
  216. ;;
  217. aarch64-*-*)
  218. GOARCH=arm64
  219. ;;
  220. aarch64_be-*-*)
  221. GOARCH=arm64be
  222. ;;
  223. arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*)
  224. GOARCH=arm
  225. case ${host} in
  226. arm*b*-*-*)
  227. GOARCH=armbe
  228. ;;
  229. esac
  230. ;;
  231. changequote(,)dnl
  232. i[34567]86-*-* | x86_64-*-*)
  233. changequote([,])dnl
  234. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  235. #ifdef __x86_64__
  236. #error 64-bit
  237. #endif
  238. ])],
  239. [GOARCH=386],
  240. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  241. #ifdef __ILP32__
  242. #error x32
  243. #endif
  244. ])],
  245. [GOARCH=amd64],
  246. [GOARCH=amd64p32]))
  247. ;;
  248. ia64-*-*)
  249. GOARCH=ia64
  250. ;;
  251. m68k*-*-*)
  252. GOARCH=m68k
  253. ;;
  254. mips*-*-*)
  255. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  256. #if _MIPS_SIM != _ABIO32
  257. #error not o32
  258. #endif
  259. ])],
  260. [mips_abi="o32"],
  261. [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  262. #if _MIPS_SIM != _ABIN32
  263. #error not n32
  264. #endif
  265. ])],
  266. [mips_abi="n32"],
  267. [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  268. #if _MIPS_SIM != _ABI64
  269. #error not n64
  270. #endif
  271. ])],
  272. [mips_abi="n64"],
  273. [AC_MSG_ERROR([unknown MIPS ABI])
  274. [mips_abi="n32"]])])])
  275. case "$mips_abi" in
  276. "o32") GOARCH=mips ;;
  277. "n32") GOARCH=mips64p32 ;;
  278. "n64") GOARCH=mips64 ;;
  279. esac
  280. case "${host}" in
  281. mips*el-*-*)
  282. GOARCH="${GOARCH}le"
  283. ;;
  284. esac
  285. ;;
  286. nios2-*-*)
  287. GOARCH=nios2
  288. ;;
  289. rs6000*-*-* | powerpc*-*-*)
  290. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  291. #ifdef _ARCH_PPC64
  292. #error 64-bit
  293. #endif
  294. ])],
  295. [GOARCH=ppc],
  296. [
  297. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  298. #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
  299. #error 64be
  300. #endif
  301. ])],
  302. [GOARCH=ppc64le],
  303. [GOARCH=ppc64])])
  304. ;;
  305. riscv*-*-*)
  306. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  307. #if __riscv_xlen == 64
  308. #error 64-bit
  309. #endif
  310. ])],
  311. [GOARCH=riscv],
  312. [GOARCH=riscv64])
  313. ;;
  314. s390*-*-*)
  315. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  316. #if defined(__s390x__)
  317. #error 64-bit
  318. #endif
  319. ])],
  320. [GOARCH=s390],
  321. [GOARCH=s390x])
  322. ;;
  323. sh3eb*-*-* | sh4eb*-*-*)
  324. GOARCH=shbe
  325. ;;
  326. sh3*-*-* | sh4*-*-*)
  327. GOARCH=sh
  328. ;;
  329. sparc*-*-*)
  330. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  331. #if defined(__sparcv9) || defined(__arch64__)
  332. #error 64-bit
  333. #endif
  334. ])],
  335. [GOARCH=sparc],
  336. [GOARCH=sparc64])
  337. ;;
  338. esac
  339. AC_SUBST(GOARCH)
  340. AC_SUBST(ALLGOARCH)
  341. AC_SUBST(ALLGOARCHFAMILY)
  342. AM_CONDITIONAL(LIBGO_IS_X86, test "$GOARCH" = "386" -o "$GOARCH" = "amd64" -o "$GOARCH" = "amd64p32")
  343. FUNCTION_DESCRIPTORS=false
  344. case ${host} in
  345. rs6000*-*-* | powerpc*-*-*)
  346. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  347. #if _CALL_ELF == 1
  348. #error descriptors
  349. #endif
  350. ])],
  351. [FUNCTION_DESCRIPTORS=false],
  352. [FUNCTION_DESCRIPTORS=true])
  353. ;;
  354. esac
  355. AC_SUBST(FUNCTION_DESCRIPTORS)
  356. dnl Some files are only present when needed for specific architectures.
  357. GO_LIBCALL_OS_FILE=
  358. GO_LIBCALL_OS_ARCH_FILE=
  359. GO_SYSCALL_OS_FILE=
  360. GO_SYSCALL_OS_ARCH_FILE=
  361. if test -f "${srcdir}/go/syscall/libcall_${GOOS}.go"; then
  362. GO_LIBCALL_OS_FILE="go/syscall/libcall_${GOOS}.go"
  363. fi
  364. if test -f "${srcdir}/go/syscall/libcall_${GOOS}_${GOARCH}.go"; then
  365. GO_LIBCALL_OS_ARCH_FILE="go/syscall/libcall_${GOOS}_${GOARCH}.go"
  366. fi
  367. if test -f "${srcdir}/go/syscall/syscall_${GOOS}.go"; then
  368. GO_SYSCALL_OS_FILE="go/syscall/syscall_${GOOS}.go"
  369. fi
  370. if test -f "${srcdir}/go/syscall/syscall_${GOOS}_${GOARCH}.go"; then
  371. GO_SYSCALL_OS_ARCH_FILE="go/syscall/syscall_${GOOS}_${GOARCH}.go"
  372. fi
  373. AC_SUBST(GO_LIBCALL_OS_FILE)
  374. AC_SUBST(GO_LIBCALL_OS_ARCH_FILE)
  375. AC_SUBST(GO_SYSCALL_OS_FILE)
  376. AC_SUBST(GO_SYSCALL_OS_ARCH_FILE)
  377. dnl Special flags used to generate sysinfo.go.
  378. OSCFLAGS="-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
  379. case "$target" in
  380. mips-sgi-irix6.5*)
  381. # IRIX 6 needs _XOPEN_SOURCE=500 for the XPG5 version of struct
  382. # msghdr in <sys/socket.h>.
  383. OSCFLAGS="$OSCFLAGS -D_XOPEN_SOURCE=500"
  384. ;;
  385. *-*-solaris2.*)
  386. # Solaris 10+ needs this so struct msghdr gets the msg_control
  387. # etc. fields in <sys/socket.h> (_XPG4_2). _XOPEN_SOURCE=600 as
  388. # above doesn't work with C99.
  389. OSCFLAGS="$OSCFLAGS -std=gnu99 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__"
  390. ;;
  391. esac
  392. AC_SUBST(OSCFLAGS)
  393. dnl Check if assembler supports disabling hardware capability support.
  394. GCC_CHECK_ASSEMBLER_HWCAP
  395. dnl Use -fsplit-stack when compiling C code if available.
  396. AC_CACHE_CHECK([whether -fsplit-stack is supported],
  397. [libgo_cv_c_split_stack_supported],
  398. [CFLAGS_hold=$CFLAGS
  399. CFLAGS="$CFLAGS -fsplit-stack"
  400. AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
  401. [libgo_cv_c_split_stack_supported=yes],
  402. [libgo_cv_c_split_stack_supported=no])
  403. CFLAGS=$CFLAGS_hold])
  404. dnl Make sure the linker permits -fsplit-stack. Old versions of gold will
  405. dnl reject split-stack code calling non-split-stack code on targets
  406. dnl they don't support.
  407. AC_CACHE_CHECK([whether linker supports split/non-split linked together],
  408. [libgo_cv_c_linker_split_non_split],
  409. [cat > conftest1.c << EOF
  410. extern void f();
  411. int main() { f(); return 0; }
  412. EOF
  413. cat > conftest2.c << EOF
  414. void f() {}
  415. EOF
  416. $CC -c -fsplit-stack $CFLAGS $CPPFLAGS conftest1.c >/dev/null 2>&1
  417. $CC -c $CFLAGS $CPPFLAGS conftest2.c > /dev/null 2>&1
  418. if $CC -o conftest conftest1.$ac_objext conftest2.$ac_objext > /dev/null 2>&1; then
  419. libgo_cv_c_linker_split_non_split=yes
  420. else
  421. libgo_cv_c_linker_split_non_split=no
  422. fi
  423. rm -f conftest1.* conftest2.* conftest])
  424. if test "$libgo_cv_c_split_stack_supported" = yes -a "$libgo_cv_c_linker_split_non_split" = yes; then
  425. SPLIT_STACK=-fsplit-stack
  426. AC_DEFINE(USING_SPLIT_STACK, 1,
  427. [Define if the compiler supports -fsplit-stack])
  428. else
  429. SPLIT_STACK=
  430. fi
  431. AC_SUBST(SPLIT_STACK)
  432. AM_CONDITIONAL(USING_SPLIT_STACK,
  433. test "$libgo_cv_c_split_stack_supported" = yes -a "$libgo_cv_c_linker_split_non_split" = yes)
  434. dnl If the compiler supports split-stack but the linker does not, then
  435. dnl we need to explicitly disable split-stack for Go.
  436. if test "$libgo_cv_c_split_stack_supported" = yes -a "$libgo_cv_c_linker_split_non_split" = no; then
  437. GO_SPLIT_STACK=-fno-split-stack
  438. else
  439. GO_SPLIT_STACK=
  440. fi
  441. AC_SUBST(GO_SPLIT_STACK)
  442. dnl Check whether the linker does stack munging when calling from
  443. dnl split-stack into non-split-stack code. We check this by looking
  444. dnl at the --help output. FIXME: This is only half right: it's
  445. dnl possible for the linker to support this for some targets but not
  446. dnl others.
  447. dnl This is slightly different from the above check, which is whether
  448. dnl the linker permits the call at all.
  449. AC_CACHE_CHECK([whether linker supports split stack],
  450. [libgo_cv_c_linker_supports_split_stack],
  451. [libgo_cv_c_linker_supports_split_stack=no
  452. if $GOC -Wl,--help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then
  453. libgo_cv_c_linker_supports_split_stack=yes
  454. fi])
  455. if test "$libgo_cv_c_linker_supports_split_stack" = yes; then
  456. AC_DEFINE(LINKER_SUPPORTS_SPLIT_STACK, 1,
  457. [Define if the linker support split stack adjustments])
  458. fi
  459. AC_CACHE_CHECK([whether compiler is llgo],
  460. [libgo_cv_c_goc_is_llgo],
  461. [libgo_cv_c_goc_is_llgo=no
  462. if $GOC -dumpversion 2>/dev/null | grep llgo >/dev/null 2>&1; then
  463. libgo_cv_c_goc_is_llgo=yes
  464. fi])
  465. AM_CONDITIONAL(GOC_IS_LLGO, test "$libgo_cv_c_goc_is_llgo" = yes)
  466. dnl Test for the -lm library.
  467. MATH_LIBS=
  468. AC_CHECK_LIB([m], [sqrt], MATH_LIBS=-lm)
  469. AC_SUBST(MATH_LIBS)
  470. dnl Test for -lsocket and -lnsl. Copied from libjava/configure.ac.
  471. AC_CACHE_CHECK([for socket libraries], libgo_cv_lib_sockets,
  472. [libgo_cv_lib_sockets=
  473. libgo_check_both=no
  474. AC_CHECK_FUNC(connect, libgo_check_socket=no, libgo_check_socket=yes)
  475. if test "$libgo_check_socket" = "yes"; then
  476. unset ac_cv_func_connect
  477. AC_CHECK_LIB(socket, main, libgo_cv_lib_sockets="-lsocket",
  478. libgo_check_both=yes)
  479. fi
  480. if test "$libgo_check_both" = "yes"; then
  481. libgo_old_libs=$LIBS
  482. LIBS="$LIBS -lsocket -lnsl"
  483. unset ac_cv_func_accept
  484. AC_CHECK_FUNC(accept,
  485. [libgo_check_nsl=no
  486. libgo_cv_lib_sockets="-lsocket -lnsl"])
  487. unset ac_cv_func_accept
  488. LIBS=$libgo_old_libs
  489. fi
  490. unset ac_cv_func_gethostbyname
  491. libgo_old_libs="$LIBS"
  492. AC_CHECK_FUNC(gethostbyname, ,
  493. [AC_CHECK_LIB(nsl, main,
  494. [libgo_cv_lib_sockets="$libgo_cv_lib_sockets -lnsl"])])
  495. unset ac_cv_func_gethostbyname
  496. AC_CHECK_FUNC(sendfile, ,
  497. [AC_CHECK_LIB(sendfile, main,
  498. [libgo_cv_lib_sockets="$libgo_cv_lib_sockets -lsendfile"])])
  499. LIBS=$libgo_old_libs
  500. ])
  501. NET_LIBS="$libgo_cv_lib_sockets"
  502. AC_SUBST(NET_LIBS)
  503. dnl Test whether the compiler supports the -pthread option.
  504. AC_CACHE_CHECK([whether -pthread is supported],
  505. [libgo_cv_lib_pthread],
  506. [CFLAGS_hold=$CFLAGS
  507. CFLAGS="$CFLAGS -pthread -L../libatomic/.libs"
  508. AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
  509. [libgo_cv_lib_pthread=yes],
  510. [libgo_cv_lib_pthread=no])
  511. CFLAGS=$CFLAGS_hold])
  512. PTHREAD_CFLAGS=
  513. if test "$libgo_cv_lib_pthread" = yes; then
  514. # RISC-V apparently adds -latomic when using -pthread.
  515. PTHREAD_CFLAGS="-pthread -L../libatomic/.libs"
  516. fi
  517. AC_SUBST(PTHREAD_CFLAGS)
  518. dnl Test for the -lpthread library.
  519. PTHREAD_LIBS=
  520. AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS=-lpthread)
  521. AC_SUBST(PTHREAD_LIBS)
  522. dnl Test if -lrt is required for sched_yield or nanosleep or clock_gettime.
  523. AC_SEARCH_LIBS([sched_yield], [rt])
  524. AC_SEARCH_LIBS([nanosleep], [rt])
  525. AC_SEARCH_LIBS([clock_gettime], [rt])
  526. AC_C_BIGENDIAN
  527. GCC_CHECK_UNWIND_GETIPINFO
  528. AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h)
  529. AC_CHECK_HEADERS([netinet/icmp6.h], [], [],
  530. [#include <netinet/in.h>
  531. ])
  532. AC_CHECK_HEADERS([linux/filter.h linux/if_addr.h linux/if_ether.h linux/if_tun.h linux/netlink.h linux/rtnetlink.h], [], [],
  533. [#ifdef HAVE_SYS_SOCKET_H
  534. #include <sys/socket.h>
  535. #endif
  536. ])
  537. AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
  538. AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr memmem)
  539. AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
  540. AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
  541. AC_STRUCT_DIRENT_D_TYPE
  542. AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat)
  543. AC_TYPE_OFF_T
  544. AC_CHECK_TYPES([loff_t])
  545. LIBS_hold="$LIBS"
  546. LIBS="$LIBS -lm"
  547. AC_CHECK_FUNCS(cosl expl logl sinl tanl acosl asinl atanl atan2l expm1l ldexpl log10l log1pl)
  548. LIBS="$LIBS_hold"
  549. CFLAGS_hold="$CFLAGS"
  550. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  551. LIBS_hold="$LIBS"
  552. LIBS="$LIBS $PTHREAD_LIBS"
  553. AC_CHECK_FUNCS(sem_timedwait)
  554. CFLAGS="$CFLAGS_hold"
  555. LIBS="$LIBS_hold"
  556. LIBS_hold="$LIBS"
  557. LIBS="$LIBS $MATH_LIBS"
  558. AC_CHECK_FUNCS(matherr)
  559. LIBS="$LIBS_hold"
  560. dnl For x86 we want to use the -minline-all-stringops option to avoid
  561. dnl forcing a stack split when calling memcpy and friends.
  562. AC_CACHE_CHECK([whether compiler supports -minline-all-stringops],
  563. [libgo_cv_c_stringops],
  564. [CFLAGS_hold=$CFLAGS
  565. CFLAGS="$CFLAGS -minline-all-stringops"
  566. AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
  567. [libgo_cv_c_stringops=yes],
  568. [libgo_cv_c_stringops=no])
  569. CFLAGS=$CFLAGS_hold])
  570. STRINGOPS_FLAG=
  571. if test "$libgo_cv_c_stringops" = yes; then
  572. STRINGOPS_FLAG=-minline-all-stringops
  573. fi
  574. AC_SUBST(STRINGOPS_FLAG)
  575. dnl For x86 we want to compile the math library with -mfancy-math-387
  576. dnl so that we can use the builtin instructions directly.
  577. AC_CACHE_CHECK([whether compiler supports -mfancy-math-387],
  578. [libgo_cv_c_fancymath],
  579. [CFLAGS_hold=$CFLAGS
  580. CFLAGS="$CFLAGS -mfancy-math-387"
  581. AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
  582. [libgo_cv_c_fancymath=yes],
  583. [libgo_cv_c_fancymath=no])
  584. CFLAGS=$CFLAGS_hold])
  585. MATH_FLAG=
  586. if test "$libgo_cv_c_fancymath" = yes; then
  587. MATH_FLAG="-mfancy-math-387"
  588. fi
  589. MATH_FLAG="${MATH_FLAG} -ffp-contract=off -fno-math-errno -fno-trapping-math"
  590. AC_SUBST(MATH_FLAG)
  591. CFLAGS_hold=$CFLAGS
  592. CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
  593. AC_CHECK_TYPES([off64_t])
  594. CFLAGS=$CFLAGS_hold
  595. dnl Work out the size of the epoll_events struct on GNU/Linux.
  596. AC_CACHE_CHECK([epoll_event size],
  597. [libgo_cv_c_epoll_event_size],
  598. [AC_COMPUTE_INT(libgo_cv_c_epoll_event_size,
  599. [sizeof (struct epoll_event)],
  600. [#include <sys/epoll.h>],
  601. [libgo_cv_c_epoll_event_size=0])])
  602. SIZEOF_STRUCT_EPOLL_EVENT=${libgo_cv_c_epoll_event_size}
  603. AC_SUBST(SIZEOF_STRUCT_EPOLL_EVENT)
  604. dnl Work out the offset of the fd field in the epoll_events struct on
  605. dnl GNU/Linux.
  606. AC_CACHE_CHECK([epoll_event data.fd offset],
  607. [libgo_cv_c_epoll_event_fd_offset],
  608. [AC_COMPUTE_INT(libgo_cv_c_epoll_event_fd_offset,
  609. [offsetof (struct epoll_event, data.fd)],
  610. [#include <stddef.h>
  611. #include <sys/epoll.h>],
  612. [libgo_cv_c_epoll_event_fd_offset=0])])
  613. STRUCT_EPOLL_EVENT_FD_OFFSET=${libgo_cv_c_epoll_event_fd_offset}
  614. AC_SUBST(STRUCT_EPOLL_EVENT_FD_OFFSET)
  615. dnl Check if <sys/stat.h> uses timespec_t for st_?tim members. Introduced
  616. dnl in Solaris 11.4 for XPG7 compatibility.
  617. AC_EGREP_HEADER([timespec_t.*st_atim], [sys/stat.h],
  618. [have_stat_timespec=yes], [have_stat_timespec=no])
  619. AM_CONDITIONAL(HAVE_STAT_TIMESPEC, test $have_stat_timespec = yes)
  620. dnl See if struct exception is defined in <math.h>.
  621. AC_CHECK_TYPE([struct exception],
  622. [libgo_has_struct_exception=yes],
  623. [libgo_has_struct_exception=no],
  624. [#include <math.h>])
  625. if test "$libgo_has_struct_exception" = "yes"; then
  626. AC_DEFINE(HAVE_STRUCT_EXCEPTION, 1,
  627. [Define to 1 if <math.h> defines struct exception])
  628. fi
  629. dnl See whether setcontext changes the value of TLS variables.
  630. AC_CACHE_CHECK([whether setcontext clobbers TLS variables],
  631. [libgo_cv_lib_setcontext_clobbers_tls],
  632. [CFLAGS_hold="$CFLAGS"
  633. CFLAGS="$PTHREAD_CFLAGS"
  634. LIBS_hold="$LIBS"
  635. LIBS="$LIBS $PTHREAD_LIBS"
  636. AC_CHECK_SIZEOF([void *])
  637. AS_VAR_ARITH([ptr_type_size], [$ac_cv_sizeof_void_p \* 8])
  638. AC_RUN_IFELSE(
  639. [AC_LANG_SOURCE([
  640. #include <pthread.h>
  641. #include <stdlib.h>
  642. #include <ucontext.h>
  643. #include <unistd.h>
  644. __thread int tls;
  645. static char stack[[10 * 1024 * 1024]];
  646. static ucontext_t c;
  647. /* Called via makecontext/setcontext. */
  648. static void
  649. cfn (void)
  650. {
  651. exit (tls);
  652. }
  653. /* Called via pthread_create. */
  654. static void *
  655. tfn (void *dummy)
  656. {
  657. /* The thread should still see this value after calling
  658. setcontext. */
  659. tls = 0;
  660. setcontext (&c);
  661. /* The call to setcontext should not return. */
  662. abort ();
  663. }
  664. int
  665. main ()
  666. {
  667. pthread_t tid;
  668. /* The thread should not see this value. */
  669. tls = 1;
  670. if (getcontext (&c) < 0)
  671. abort ();
  672. c.uc_stack.ss_sp = stack;
  673. #ifdef MAKECONTEXT_STACK_TOP
  674. c.uc_stack.ss_sp += sizeof stack;
  675. #endif
  676. c.uc_stack.ss_flags = 0;
  677. c.uc_stack.ss_size = sizeof stack;
  678. c.uc_link = NULL;
  679. makecontext (&c, cfn, 0);
  680. if (pthread_create (&tid, NULL, tfn, NULL) != 0)
  681. abort ();
  682. if (pthread_join (tid, NULL) != 0)
  683. abort ();
  684. /* The thread should have called exit. */
  685. abort ();
  686. }
  687. ])],
  688. [libgo_cv_lib_setcontext_clobbers_tls=no],
  689. [libgo_cv_lib_setcontext_clobbers_tls=yes],
  690. [case "$target:$ptr_type_size" in
  691. i?86-*-solaris2.1[[01]]:64 | x86_64*-*-solaris2.1[[01]]:64)
  692. libgo_cv_lib_setcontext_clobbers_tls=yes ;;
  693. *)
  694. libgo_cv_lib_setcontext_clobbers_tls=no ;;
  695. esac
  696. ])
  697. CFLAGS="$CFLAGS_hold"
  698. LIBS="$LIBS_hold"
  699. ])
  700. if test "$libgo_cv_lib_setcontext_clobbers_tls" = "yes"; then
  701. AC_DEFINE(SETCONTEXT_CLOBBERS_TLS, 1,
  702. [Define if setcontext clobbers TLS variables])
  703. fi
  704. AC_CACHE_CHECK([whether .eh_frame section should be read-only],
  705. libgo_cv_ro_eh_frame, [
  706. libgo_cv_ro_eh_frame=no
  707. echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
  708. if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then
  709. if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then
  710. libgo_cv_ro_eh_frame=yes
  711. elif grep '.section.*eh_frame.*#alloc' conftest.c \
  712. | grep -v '#write' > /dev/null; then
  713. libgo_cv_ro_eh_frame=yes
  714. fi
  715. fi
  716. rm -f conftest.*
  717. ])
  718. if test "x$libgo_cv_ro_eh_frame" = xyes; then
  719. AC_DEFINE(EH_FRAME_FLAGS, "a",
  720. [Define to the flags needed for the .section .eh_frame directive.])
  721. else
  722. AC_DEFINE(EH_FRAME_FLAGS, "aw",
  723. [Define to the flags needed for the .section .eh_frame directive.])
  724. fi
  725. AC_CACHE_CHECK([if compiler supports -Qunused-arguments],
  726. [libgo_cv_c_unused_arguments],
  727. [CFLAGS_hold=$CFLAGS
  728. CFLAGS="$CFLAGS -Qunused-arguments"
  729. AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
  730. [libgo_cv_c_unused_arguments=yes],
  731. [libgo_cv_c_unused_arguments=no])
  732. CFLAGS=$CFLAGS_hold])
  733. AC_CACHE_CHECK([if assembler supports GNU comdat group syntax],
  734. libgo_cv_as_comdat_gnu, [
  735. echo '.section .text,"axG",@progbits,.foo,comdat' > conftest.s
  736. CFLAGS_hold=$CFLAGS
  737. if test "$libgo_cv_c_unused_arguments" = yes; then
  738. CFLAGS="$CFLAGS -Qunused-arguments"
  739. fi
  740. if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
  741. libgo_cv_as_comdat_gnu=yes
  742. else
  743. libgo_cv_as_comdat_gnu=no
  744. fi
  745. CFLAGS=$CFLAGS_hold
  746. ])
  747. if test "x$libgo_cv_as_comdat_gnu" = xyes; then
  748. AC_DEFINE(HAVE_AS_COMDAT_GAS, 1,
  749. [Define if your assembler supports GNU comdat group syntax.])
  750. fi
  751. AC_CACHE_CHECK([assembler supports pc related relocs],
  752. libgo_cv_as_x86_pcrel, [
  753. libgo_cv_as_x86_pcrel=yes
  754. echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
  755. CFLAGS_hold=$CFLAGS
  756. if test "$libgo_cv_c_unused_arguments" = yes; then
  757. CFLAGS="$CFLAGS -Qunused-arguments"
  758. fi
  759. if $CC $CFLAGS -c conftest.s 2>&1 | $EGREP -i 'illegal|warning' > /dev/null; then
  760. libgo_cv_as_x86_pcrel=no
  761. fi
  762. CFLAGS=$CFLAGS_hold
  763. ])
  764. if test "x$libgo_cv_as_x86_pcrel" = xyes; then
  765. AC_DEFINE(HAVE_AS_X86_PCREL, 1,
  766. [Define if your assembler supports PC relative relocs.])
  767. fi
  768. AC_CACHE_CHECK([assembler supports unwind section type],
  769. libgo_cv_as_x86_64_unwind_section_type, [
  770. libgo_cv_as_x86_64_unwind_section_type=yes
  771. echo '.section .eh_frame,"a",@unwind' > conftest.s
  772. CFLAGS_hold=$CFLAGS
  773. if test "$libgo_cv_c_unused_arguments" = yes; then
  774. CFLAGS="$CFLAGS -Qunused-arguments"
  775. fi
  776. if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
  777. libgo_cv_as_x86_64_unwind_section_type=no
  778. fi
  779. CFLAGS=$CFLAGS_hold
  780. ])
  781. if test "x$libgo_cv_as_x86_64_unwind_section_type" = xyes; then
  782. AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
  783. [Define if your assembler supports unwind section type.])
  784. fi
  785. AC_CACHE_CHECK([assembler supports AES instructions],
  786. libgo_cv_as_x86_aes, [
  787. libgo_cv_as_x86_aes=yes
  788. echo 'aesenc %xmm0, %xmm1' > conftest.s
  789. CFLAGS_hold=$CFLAGS
  790. if test "$libgo_cv_c_unused_arguments" = yes; then
  791. CFLAGS="$CFLAGS -Qunused-arguments"
  792. fi
  793. if $CC $CFLAGS -c conftest.s 2>&1 | grep -i error > /dev/null; then
  794. libgo_cv_as_x86_aes=no
  795. fi
  796. CFLAGS=$CFLAGS_hold
  797. ])
  798. if test "x$libgo_cv_as_x86_aes" = xyes; then
  799. AC_DEFINE(HAVE_AS_X86_AES, 1,
  800. [Define if your assembler supports AES instructions.])
  801. fi
  802. dnl Test whether the linker supports the -static option.
  803. AC_CACHE_CHECK([whether -static is supported],
  804. [libgo_cv_ld_static],
  805. [LDFLAGS_hold=$LDFLAGS
  806. LDFLAGS="$LDFLAGS -static"
  807. AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
  808. [libgo_cv_ld_static=yes],
  809. [libgo_cv_ld_static=no])
  810. LDFLAGS=$LDFLAGS_hold])
  811. AM_CONDITIONAL(HAVE_STATIC_LINK, test "$libgo_cv_ld_static" = yes)
  812. AC_CACHE_SAVE
  813. if test ${multilib} = yes; then
  814. multilib_arg="--enable-multilib"
  815. else
  816. multilib_arg=
  817. fi
  818. AC_CONFIG_FILES(Makefile testsuite/Makefile testsuite/libgo-test-support.exp)
  819. AC_CONFIG_COMMANDS([default],
  820. [if test -n "$CONFIG_FILES"; then
  821. # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
  822. # that multilib installs will end up installed in the correct place.
  823. # The testsuite needs it for multilib-aware ABI baseline files.
  824. # To work around this not being passed down from config-ml.in ->
  825. # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
  826. # append it here. Only modify Makefiles that have just been created.
  827. #
  828. # Also, get rid of this simulated-VPATH thing that automake does.
  829. cat > vpsed << \_EOF
  830. s!`test -f '$<' || echo '$(srcdir)/'`!!
  831. _EOF
  832. for i in $SUBDIRS; do
  833. case $CONFIG_FILES in
  834. *${i}/Makefile*)
  835. #echo "Adding MULTISUBDIR to $i/Makefile"
  836. sed -f vpsed $i/Makefile > tmp
  837. grep '^MULTISUBDIR =' Makefile >> tmp
  838. mv tmp $i/Makefile
  839. ;;
  840. esac
  841. done
  842. rm vpsed
  843. fi
  844. ],
  845. [
  846. # Variables needed in config.status (file generation) which aren't already
  847. # passed by autoconf.
  848. SUBDIRS="$SUBDIRS"
  849. ])
  850. AC_OUTPUT