]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgo/configure.ac
Fix boostrap failure in tree-ssa-loop-ch.cc
[thirdparty/gcc.git] / libgo / configure.ac
index 09add8d136bf61a8fef81c7d927108a665aa770f..a59aa091d1dce507ac9a08d9103dcd393b72614d 100644 (file)
@@ -6,12 +6,11 @@
 
 # Process this file with autoreconf to produce configure.
 
-AC_PREREQ(2.64)
 AC_INIT(package-unused, version-unused,, libgo)
 AC_CONFIG_SRCDIR(Makefile.am)
 AC_CONFIG_HEADER(config.h)
 
-libtool_VERSION=10:0:0
+libtool_VERSION=22:0:0
 AC_SUBST(libtool_VERSION)
 
 AM_ENABLE_MULTILIB(, ..)
@@ -19,7 +18,7 @@ AM_ENABLE_MULTILIB(, ..)
 AC_CANONICAL_SYSTEM
 target_alias=${target_alias-$host_alias}
 
-AM_INIT_AUTOMAKE([1.9.3 no-define foreign no-dist -Wall -Wno-portability])
+AM_INIT_AUTOMAKE([1.9.3 no-define foreign no-dist subdir-objects -Wall -Wno-portability -Wno-override])
 AH_TEMPLATE(PACKAGE, [Name of package])
 AH_TEMPLATE(VERSION, [Version number of package])
 
@@ -27,10 +26,23 @@ m4_rename([_AC_ARG_VAR_PRECIOUS],[glibgo_PRECIOUS])
 m4_define([_AC_ARG_VAR_PRECIOUS],[])
 AC_PROG_CC
 AC_PROG_GO
+AM_PROG_AS
 m4_rename_force([glibgo_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
 
 AC_SUBST(CFLAGS)
 
+case ${host} in
+  *-*-aix*)
+    # Check default architecture for FAT library creation
+    if test -z "`$CC -x c -E /dev/null -g3 -o - | grep 64BIT`" ; then
+        AIX_EXTRA_ARCH='64'
+    else
+        AIX_EXTRA_ARCH='32'
+    fi
+    AC_SUBST(AIX_EXTRA_ARCH)
+    ;;
+esac
+
 AM_MAINTAINER_MODE
 
 AC_PROG_LD
@@ -50,11 +62,10 @@ AC_PROG_AWK
 WARN_FLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual'
 AC_SUBST(WARN_FLAGS)
 
-AC_ARG_ENABLE(werror, [AS_HELP_STRING([--enable-werror],
-                                      [turns on -Werror @<:@default=yes@:>@])])
-if test "x$enable_werror" != "xno"; then
-  WERROR="-Werror"
-fi
+AC_ARG_ENABLE([werror],
+  [AS_HELP_STRING([--disable-werror], [disable building with -Werror])])
+AS_IF([test "x$enable_werror" != "xno" && test "x$GCC" = "xyes"],
+  [WERROR="-Werror"])
 AC_SUBST(WERROR)
 
 glibgo_toolexecdir=no
@@ -72,6 +83,8 @@ AC_ARG_ENABLE([version-specific-runtime-libs],
   [version_specific_libs=no])
 AC_MSG_RESULT($version_specific_libs)
 
+GCC_WITH_TOOLEXECLIBDIR
+
 # Version-specific runtime libs processing.
 if test $version_specific_libs = yes; then
   glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
@@ -83,7 +96,14 @@ fi
 if test -n "$with_cross_host" &&
    test x"$with_cross_host" != x"no"; then
   nover_glibgo_toolexecdir='${exec_prefix}/${host_alias}'
-  nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
+  case ${with_toolexeclibdir} in
+    no)
+      nover_glibgo_toolexeclibdir='${toolexecdir}/lib'
+      ;;
+    *)
+      nover_glibgo_toolexeclibdir=${with_toolexeclibdir}
+      ;;
+  esac
 else
   nover_glibgo_toolexecdir='${libdir}/gcc/${host_alias}'
   nover_glibgo_toolexeclibdir='${libdir}'
@@ -121,6 +141,7 @@ if test "$with_libffi" != no; then
 fi
 AC_SUBST(LIBFFI)
 AC_SUBST(LIBFFIINCS)
+AM_CONDITIONAL(USE_LIBFFI, test "$with_libffi" != "no")
 
 # See if the user wants to configure without libatomic. This is useful if we are
 # on an architecture for which libgo does not need an atomic support library and
@@ -145,7 +166,7 @@ AC_SUBST(go_include)
 # All known GOOS values.  This is the union of all operating systems
 # supported by the gofrontend and all operating systems supported by
 # the gc toolchain.
-ALLGOOS="android darwin dragonfly freebsd irix linux netbsd openbsd plan9 rtems solaris windows"
+ALLGOOS="aix android darwin dragonfly freebsd hurd illumos ios irix js linux netbsd openbsd plan9 rtems solaris windows zos"
 
 is_darwin=no
 is_freebsd=no
@@ -156,6 +177,8 @@ is_openbsd=no
 is_dragonfly=no
 is_rtems=no
 is_solaris=no
+is_aix=no
+is_hurd=no
 GOOS=unknown
 case ${host} in
   *-*-darwin*)   is_darwin=yes;  GOOS=darwin ;;
@@ -167,6 +190,8 @@ case ${host} in
   *-*-dragonfly*) is_dragonfly=yes; GOOS=dragonfly ;;
   *-*-rtems*)    is_rtems=yes;   GOOS=rtems ;;
   *-*-solaris2*) is_solaris=yes; GOOS=solaris ;;
+  *-*-aix*)      is_aix=yes;     GOOS=aix ;;
+  *-*-gnu*)      is_hurd=yes;    GOOS=hurd ;;
 esac
 AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes)
 AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes)
@@ -177,6 +202,8 @@ AM_CONDITIONAL(LIBGO_IS_OPENBSD, test $is_openbsd = yes)
 AM_CONDITIONAL(LIBGO_IS_DRAGONFLY, test $is_dragonfly = yes)
 AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes)
 AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes)
+AM_CONDITIONAL(LIBGO_IS_AIX, test $is_aix = yes)
+AM_CONDITIONAL(LIBGO_IS_HURD, test $is_hurd = yes)
 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)
 AC_SUBST(GOOS)
 AC_SUBST(ALLGOOS)
@@ -195,192 +222,175 @@ AC_SUBST(USE_DEJAGNU)
 # All known GOARCH values.  This is the union of all architectures
 # supported by the gofrontend and all architectures supported by the
 # gc toolchain.
-# N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch).
-ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mipso32 mipsn32 mipso64 mipsn64 mips mipsle mips64 mips64le mips64p32 mips64pe32le ppc ppc64 ppc64le s390 s390x sparc sparc64"
-
-# All known GOARCH_FAMILY values.
-ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 PPC PPC64 S390 S390X SPARC SPARC64"
+# To add a new architecture:
+# - add it to this list
+# - if appropriate, add an entry to ALLGOARCHFAMILY below
+# - add an entry to the case on ${host} below to set GOARCH
+# - update goarchList in libgo/go/go/build/syslist.go
+# - update goarch.sh to report the values for this architecture
+# - update go-set-goarch in gcc/testsuite/go.test/go-test.exp
+# - update ptrSizeMap and intSizeMap in libgo/go/cmd/cgo/main.go
+# - update arch lists in libgo/match.sh
+# - update arch lists in libgo/testsuite/gotest
+# - update +build lines in several places
+#   - libgo/go/runtime/lfstack_NNbit.go
+#   - libgo/go/runtime/hashNN.go
+#   - libgo/go/runtime/unalignedN.go
+#   - libgo/go/syscall/endian_XX.go
+#   - possibly others
+# - possibly update files in libgo/go/internal/syscall/unix
+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"
+
+# All known GOARCH family values.
+ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 NIOS2 PPC PPC64 RISCV RISCV64 S390 S390X SH SPARC SPARC64 WASM"
 
 GOARCH=unknown
-GOARCH_FAMILY=unknown
-GOARCH_BIGENDIAN=0
-GOARCH_CACHELINESIZE=64
-GOARCH_PHYSPAGESIZE=4096
-GOARCH_PCQUANTUM=1
-GOARCH_INT64ALIGN=8
-GOARCH_HUGEPAGESIZE=0
-GOARCH_MINFRAMESIZE=0
 case ${host} in
   alpha*-*-*)
     GOARCH=alpha
-    GOARCH_FAMILY=ALPHA
-    GOARCH_PHYSPAGESIZE=8192
-    GOARCH_PCQUANTUM=4
     ;;
   aarch64-*-*)
     GOARCH=arm64
-    GOARCH_FAMILY=ARM64
-    GOARCH_CACHELINESIZE=32
-    GOARCH_PHYSPAGESIZE=65536
-    GOARCH_PCQUANTUM=4
-    GOARCH_MINFRAMESIZE=8
+    ;;
+  aarch64_be-*-*)
+    GOARCH=arm64be
     ;;
   arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*)
     GOARCH=arm
-    GOARCH_FAMILY=ARM
-    GOARCH_CACHELINESIZE=32
-    GOARCH_PCQUANTUM=4
-    GOARCH_MINFRAMESIZE=4
+    case ${host} in
+      arm*b*-*-*)
+       GOARCH=armbe
+       ;;
+    esac
     ;;
 changequote(,)dnl
   i[34567]86-*-* | x86_64-*-*)
 changequote([,])dnl
-    AC_COMPILE_IFELSE([
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
 #ifdef __x86_64__
 #error 64-bit
-#endif],
-[GOARCH=386
-GOARCH_FAMILY=I386
-GOARCH_INT64ALIGN=4
-GOARCH_HUGEPAGESIZE="1 << 21"
-],
-[GOARCH=amd64
-GOARCH_FAMILY=AMD64
-GOARCH_HUGEPAGESIZE="1 << 21"
-])
+#endif
+])],
+       [GOARCH=386],
+       AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#ifdef __ILP32__
+#error x32
+#endif
+])],
+       [GOARCH=amd64],
+       [GOARCH=amd64p32]))
     ;;
   ia64-*-*)
     GOARCH=ia64
-    GOARCH_FAMILY=IA64
-    GOARCH_CACHELINESIZE=16384
-    GOARCH_PHYSPAGESIZE=65536
     ;;
   m68k*-*-*)
     GOARCH=m68k
-    GOARCH_FAMILY=M68K
-    GOARCH_BIGENDIAN=1
-    GOARCH_CACHELINESIZE=16
-    GOARCH_PCQUANTUM=4
-    GOARCH_INT64ALIGN=2
     ;;
   mips*-*-*)
-    AC_COMPILE_IFELSE([
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
 #if _MIPS_SIM != _ABIO32
 #error not o32
-#endif],
+#endif
+])],
 [mips_abi="o32"],
-       [AC_COMPILE_IFELSE([
+       [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
 #if _MIPS_SIM != _ABIN32
 #error not n32
-#endif],
+#endif
+])],
 [mips_abi="n32"],
-       [AC_COMPILE_IFELSE([
+       [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
 #if _MIPS_SIM != _ABI64
 #error not n64
-#endif],
+#endif
+])],
 [mips_abi="n64"],
-       [AC_COMPILE_IFELSE([
-#if _MIPS_SIM != _ABIO64
-#error not o64
-#endif],
-[mips_abi="o64"],
        [AC_MSG_ERROR([unknown MIPS ABI])
-[mips_abi="n32"]])])])])
-    case "$mips_abi" in
-    "o32") GOARCH=mipso32 ;;
-    "n32") GOARCH=mipsn32 ;;
-    "n64") GOARCH=mipsn64 ;;
-    "o64") GOARCH=mipso64 ;;
-    esac
+[mips_abi="n32"]])])])
     case "$mips_abi" in
-    "o32" | "n32")
-        GOARCH_FAMILY=MIPS
-       GOARCH_MINFRAMESIZE=4
-        ;;
-    "n64" | "o64")
-        GOARCH_FAMILY=MIPS64
-       GOARCH_MINFRAMESIZE=8
-        ;;
+    "o32") GOARCH=mips ;;
+    "n32") GOARCH=mips64p32 ;;
+    "n64") GOARCH=mips64 ;;
     esac
     case "${host}" in
-    mips*el)
-        ;;
-    *)
-       GOARCH_BIGENDIAN=1
+    mips*el-*-*)
+        GOARCH="${GOARCH}le"
         ;;
     esac
-    GOARCH_CACHELINESIZE=32
-    GOARCH_PHYSPAGESIZE=16384
-    GOARCH_PCQUANTUM=4
+    ;;
+  nios2-*-*)
+    GOARCH=nios2
     ;;
   rs6000*-*-* | powerpc*-*-*)
-    AC_COMPILE_IFELSE([
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
 #ifdef _ARCH_PPC64
 #error 64-bit
-#endif],
-[GOARCH=ppc
-GOARCH_FAMILY=PPC
-GOARCH_BIGENDIAN=1
-],
+#endif
+])],
+[GOARCH=ppc],
     [
-GOARCH_FAMILY=PPC64
-AC_COMPILE_IFELSE([
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
 #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
 #error 64be
-#endif],
-[GOARCH=ppc64le
-],
-[GOARCH=ppc64
-GOARCH_BIGENDIAN=1
-])])
-    GOARCH_PHYSPAGESIZE=65536
-    GOARCH_PCQUANTUM=4
-    GOARCH_MINFRAMESIZE=32
+#endif
+])],
+[GOARCH=ppc64le],
+[GOARCH=ppc64])])
+    ;;
+  riscv*-*-*)
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#if __riscv_xlen == 64
+#error 64-bit
+#endif
+])],
+[GOARCH=riscv],
+[GOARCH=riscv64])
     ;;
   s390*-*-*)
-    AC_COMPILE_IFELSE([
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
 #if defined(__s390x__)
 #error 64-bit
-#endif],
-[GOARCH=s390
-GOARCH_FAMILY=S390
-GOARCH_MINFRAMESIZE=4
-], [GOARCH=s390x
-GOARCH_FAMILY=S390X
-GOARCH_MINFRAMESIZE=8
-])
-    GOARCH_BIGENDIAN=1
-    GOARCH_CACHELINESIZE=256
-    GOARCH_PCQUANTUM=2
+#endif
+])],
+[GOARCH=s390],
+[GOARCH=s390x])
+    ;;
+  sh3eb*-*-* | sh4eb*-*-*)
+    GOARCH=shbe
+    ;;
+  sh3*-*-* | sh4*-*-*)
+    GOARCH=sh
     ;;
   sparc*-*-*)
-    AC_COMPILE_IFELSE([
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
 #if defined(__sparcv9) || defined(__arch64__)
 #error 64-bit
-#endif],
-[GOARCH=sparc
-GOARCH_FAMILY=SPARC
-],
-[GOARCH=sparc64
-GOARCH_FAMILY=SPARC64
-])
-    GOARCH_BIGENDIAN=1
-    GOARCH_PHYSPAGESIZE=8192
-    GOARCH_PCQUANTUM=4
+#endif
+])],
+[GOARCH=sparc],
+[GOARCH=sparc64])
     ;;
 esac
 AC_SUBST(GOARCH)
-AC_SUBST(GOARCH_FAMILY)
-AC_SUBST(GOARCH_BIGENDIAN)
-AC_SUBST(GOARCH_CACHELINESIZE)
-AC_SUBST(GOARCH_PHYSPAGESIZE)
-AC_SUBST(GOARCH_PCQUANTUM)
-AC_SUBST(GOARCH_INT64ALIGN)
-AC_SUBST(GOARCH_HUGEPAGESIZE)
-AC_SUBST(GOARCH_MINFRAMESIZE)
 AC_SUBST(ALLGOARCH)
 AC_SUBST(ALLGOARCHFAMILY)
 
+AM_CONDITIONAL(LIBGO_IS_X86, test "$GOARCH" = "386" -o "$GOARCH" = "amd64" -o "$GOARCH" = "amd64p32")
+
+FUNCTION_DESCRIPTORS=false
+case ${host} in
+  rs6000*-*-* | powerpc*-*-*)
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#if _CALL_ELF == 1
+#error descriptors
+#endif
+])],
+       [FUNCTION_DESCRIPTORS=false],
+       [FUNCTION_DESCRIPTORS=true])
+    ;;
+esac
+AC_SUBST(FUNCTION_DESCRIPTORS)
+
 dnl Some files are only present when needed for specific architectures.
 GO_LIBCALL_OS_FILE=
 GO_LIBCALL_OS_ARCH_FILE=
@@ -411,7 +421,7 @@ case "$target" in
        # msghdr in <sys/socket.h>.
        OSCFLAGS="$OSCFLAGS -D_XOPEN_SOURCE=500"
        ;;
-    *-*-solaris2.1[[01]])
+    *-*-solaris2.*)
        # Solaris 10+ needs this so struct msghdr gets the msg_control
        # etc. fields in <sys/socket.h> (_XPG4_2).  _XOPEN_SOURCE=600 as
        # above doesn't work with C99.
@@ -420,12 +430,15 @@ case "$target" in
 esac
 AC_SUBST(OSCFLAGS)
 
+dnl Check if assembler supports disabling hardware capability support.
+GCC_CHECK_ASSEMBLER_HWCAP
+
 dnl Use -fsplit-stack when compiling C code if available.
 AC_CACHE_CHECK([whether -fsplit-stack is supported],
 [libgo_cv_c_split_stack_supported],
 [CFLAGS_hold=$CFLAGS
 CFLAGS="$CFLAGS -fsplit-stack"
-AC_COMPILE_IFELSE([[int i;]],
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
 [libgo_cv_c_split_stack_supported=yes],
 [libgo_cv_c_split_stack_supported=no])
 CFLAGS=$CFLAGS_hold])
@@ -540,14 +553,15 @@ dnl Test whether the compiler supports the -pthread option.
 AC_CACHE_CHECK([whether -pthread is supported],
 [libgo_cv_lib_pthread],
 [CFLAGS_hold=$CFLAGS
-CFLAGS="$CFLAGS -pthread"
-AC_COMPILE_IFELSE([[int i;]],
+CFLAGS="$CFLAGS -pthread -L../libatomic/.libs"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
 [libgo_cv_lib_pthread=yes],
 [libgo_cv_lib_pthread=no])
 CFLAGS=$CFLAGS_hold])
 PTHREAD_CFLAGS=
 if test "$libgo_cv_lib_pthread" = yes; then
-  PTHREAD_CFLAGS=-pthread
+  # RISC-V apparently adds -latomic when using -pthread.
+  PTHREAD_CFLAGS="-pthread -L../libatomic/.libs"
 fi
 AC_SUBST(PTHREAD_CFLAGS)
 
@@ -556,6 +570,9 @@ PTHREAD_LIBS=
 AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS=-lpthread)
 AC_SUBST(PTHREAD_LIBS)
 
+dnl Test if -lucontext is required for makecontext.
+AC_SEARCH_LIBS([makecontext], [ucontext])
+
 dnl Test if -lrt is required for sched_yield or nanosleep or clock_gettime.
 AC_SEARCH_LIBS([sched_yield], [rt])
 AC_SEARCH_LIBS([nanosleep], [rt])
@@ -565,7 +582,11 @@ AC_C_BIGENDIAN
 
 GCC_CHECK_UNWIND_GETIPINFO
 
-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/user.h sys/utsname.h sys/select.h sys/socket.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/reboot.h netinet/icmp6.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h)
+AC_CHECK_HEADERS(fcntl.h 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)
+
+AC_CHECK_HEADERS([netinet/icmp6.h], [], [],
+[#include <netinet/in.h>
+])
 
 AC_CHECK_HEADERS([linux/filter.h linux/if_addr.h linux/if_ether.h linux/if_tun.h linux/netlink.h linux/rtnetlink.h], [], [],
 [#ifdef HAVE_SYS_SOCKET_H
@@ -573,33 +594,24 @@ AC_CHECK_HEADERS([linux/filter.h linux/if_addr.h linux/if_ether.h linux/if_tun.h
 #endif
 ])
 
-AC_CACHE_CHECK([whether <ustat.h> can be used],
-[libgo_cv_c_ustat_h],
-[CFLAGS_hold=$CFLAGS
-CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE $OSCFLAGS"
-AC_COMPILE_IFELSE(
-[AC_LANG_SOURCE([
-#include <sys/types.h>
-#ifdef HAVE_LINUX_FILTER_H
-#include <linux/filter.h>
-#endif
-#include <ustat.h>
-])], [libgo_cv_c_ustat_h=yes], [libgo_cv_c_ustat_h=no])
-CFLAGS=$CFLAGS_hold])
-if test $libgo_cv_c_ustat_h = yes; then
-  AC_DEFINE(HAVE_USTAT_H, 1,
-    [Define to 1 if you have the <ustat.h> header file and it works.])
-fi
-
 AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
 
-AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr)
+AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr memmem)
 AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
 AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
 
-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 tee unlinkat unshare utimensat)
+AC_STRUCT_DIRENT_D_TYPE
+
+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)
 AC_TYPE_OFF_T
-AC_CHECK_TYPES([loff_t])
+
+CFLAGS_hold="$CFLAGS"
+CFLAGS="$OSCFLAGS $CFLAGS"
+AC_CHECK_TYPES([loff_t], [], [], [[
+#include <sys/types.h>
+#include <fcntl.h>
+]])
+CFLAGS="$CFLAGS_hold"
 
 LIBS_hold="$LIBS"
 LIBS="$LIBS -lm"
@@ -619,69 +631,13 @@ LIBS="$LIBS $MATH_LIBS"
 AC_CHECK_FUNCS(matherr)
 LIBS="$LIBS_hold"
 
-AC_CACHE_CHECK([for __sync_bool_compare_and_swap_4],
-[libgo_cv_func___sync_bool_compare_and_swap_4],
-[AC_LINK_IFELSE([
-typedef unsigned int uint32  __attribute__ ((mode (SI)));
-uint32 i;
-int main() { return __sync_bool_compare_and_swap (&i, 0, 1); }
-],
-[libgo_cv_func___sync_bool_compare_and_swap_4=yes],
-[libgo_cv_func___sync_bool_compare_and_swap_4=no])])
-if test "$libgo_cv_func___sync_bool_compare_and_swap_4" = "yes"; then
-  AC_DEFINE(HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4, 1,
-    [Define to 1 if the compiler provides the __sync_bool_compare_and_swap function for uint32])
-fi
-
-AC_CACHE_CHECK([for __sync_bool_compare_and_swap_8],
-[libgo_cv_func___sync_bool_compare_and_swap_8],
-[AC_LINK_IFELSE([
-typedef unsigned int uint64  __attribute__ ((mode (DI)));
-uint64 i;
-int main() { return __sync_bool_compare_and_swap (&i, 0, 1); }
-],
-[libgo_cv_func___sync_bool_compare_and_swap_8=yes],
-[libgo_cv_func___sync_bool_compare_and_swap_8=no])])
-if test "$libgo_cv_func___sync_bool_compare_and_swap_8" = "yes"; then
-  AC_DEFINE(HAVE_SYNC_BOOL_COMPARE_AND_SWAP_8, 1,
-    [Define to 1 if the compiler provides the __sync_bool_compare_and_swap function for uint64])
-fi
-
-AC_CACHE_CHECK([for __sync_fetch_and_add_4],
-[libgo_cv_func___sync_fetch_and_add_4],
-[AC_LINK_IFELSE([
-typedef unsigned int uint32  __attribute__ ((mode (SI)));
-uint32 i;
-int main() { return __sync_fetch_and_add (&i, 1); }
-],
-[libgo_cv_func___sync_fetch_and_add_4=yes],
-[libgo_cv_func___sync_fetch_and_add_4=no])])
-if test "$libgo_cv_func___sync_fetch_and_add_4" = "yes"; then
-  AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD_4, 1,
-    [Define to 1 if the compiler provides the __sync_fetch_and_add function for uint32])
-fi
-
-AC_CACHE_CHECK([for __sync_add_and_fetch_8],
-[libgo_cv_func___sync_add_and_fetch_8],
-[AC_LINK_IFELSE([
-typedef unsigned int uint64  __attribute__ ((mode (DI)));
-uint64 i;
-int main() { return __sync_add_and_fetch (&i, 1); }
-],
-[libgo_cv_func___sync_add_and_fetch_8=yes],
-[libgo_cv_func___sync_add_and_fetch_8=no])])
-if test "$libgo_cv_func___sync_add_and_fetch_8" = "yes"; then
-  AC_DEFINE(HAVE_SYNC_ADD_AND_FETCH_8, 1,
-    [Define to 1 if the compiler provides the __sync_add_and_fetch function for uint64])
-fi
-
 dnl For x86 we want to use the -minline-all-stringops option to avoid
 dnl forcing a stack split when calling memcpy and friends.
 AC_CACHE_CHECK([whether compiler supports -minline-all-stringops],
 [libgo_cv_c_stringops],
 [CFLAGS_hold=$CFLAGS
 CFLAGS="$CFLAGS -minline-all-stringops"
-AC_COMPILE_IFELSE([int i;],
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
 [libgo_cv_c_stringops=yes],
 [libgo_cv_c_stringops=no])
 CFLAGS=$CFLAGS_hold])
@@ -692,22 +648,20 @@ fi
 AC_SUBST(STRINGOPS_FLAG)
 
 dnl For x86 we want to compile the math library with -mfancy-math-387
-dnl -funsafe-math-optimizations so that we can use the builtin
-dnl instructions directly.
+dnl so that we can use the builtin instructions directly.
 AC_CACHE_CHECK([whether compiler supports -mfancy-math-387],
 [libgo_cv_c_fancymath],
 [CFLAGS_hold=$CFLAGS
 CFLAGS="$CFLAGS -mfancy-math-387"
-AC_COMPILE_IFELSE([int i;],
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
 [libgo_cv_c_fancymath=yes],
 [libgo_cv_c_fancymath=no])
 CFLAGS=$CFLAGS_hold])
 MATH_FLAG=
 if test "$libgo_cv_c_fancymath" = yes; then
-  MATH_FLAG="-mfancy-math-387 -funsafe-math-optimizations"
-else
-  MATH_FLAG="-ffp-contract=off"
+  MATH_FLAG="-mfancy-math-387"
 fi
+MATH_FLAG="${MATH_FLAG} -ffp-contract=off -fno-math-errno -fno-trapping-math"
 AC_SUBST(MATH_FLAG)
 
 CFLAGS_hold=$CFLAGS
@@ -738,7 +692,7 @@ STRUCT_EPOLL_EVENT_FD_OFFSET=${libgo_cv_c_epoll_event_fd_offset}
 AC_SUBST(STRUCT_EPOLL_EVENT_FD_OFFSET)
 
 dnl Check if <sys/stat.h> uses timespec_t for st_?tim members.  Introduced
-dnl in Solaris 12 for XPG7 compatibility.
+dnl in Solaris 11.4 for XPG7 compatibility.
 AC_EGREP_HEADER([timespec_t.*st_atim], [sys/stat.h],
                [have_stat_timespec=yes], [have_stat_timespec=no])
 AM_CONDITIONAL(HAVE_STAT_TIMESPEC, test $have_stat_timespec = yes)
@@ -870,7 +824,7 @@ AC_CACHE_CHECK([if compiler supports -Qunused-arguments],
 [libgo_cv_c_unused_arguments],
 [CFLAGS_hold=$CFLAGS
 CFLAGS="$CFLAGS -Qunused-arguments"
-AC_COMPILE_IFELSE([[int i;]],
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
 [libgo_cv_c_unused_arguments=yes],
 [libgo_cv_c_unused_arguments=no])
 CFLAGS=$CFLAGS_hold])
@@ -930,6 +884,35 @@ if test "x$libgo_cv_as_x86_64_unwind_section_type" = xyes; then
            [Define if your assembler supports unwind section type.])
 fi
 
+AC_CACHE_CHECK([assembler supports AES instructions],
+libgo_cv_as_x86_aes, [
+libgo_cv_as_x86_aes=yes
+echo 'aesenc %xmm0, %xmm1' > conftest.s
+CFLAGS_hold=$CFLAGS
+if test "$libgo_cv_c_unused_arguments" = yes; then
+  CFLAGS="$CFLAGS -Qunused-arguments"
+fi
+if $CC $CFLAGS -c conftest.s 2>&1 | grep -i error > /dev/null; then
+    libgo_cv_as_x86_aes=no
+fi
+CFLAGS=$CFLAGS_hold
+])
+if test "x$libgo_cv_as_x86_aes" = xyes; then
+  AC_DEFINE(HAVE_AS_X86_AES, 1,
+           [Define if your assembler supports AES instructions.])
+fi
+
+dnl Test whether the linker supports the -static option.
+AC_CACHE_CHECK([whether -static is supported],
+[libgo_cv_ld_static],
+[LDFLAGS_hold=$LDFLAGS
+LDFLAGS="$LDFLAGS -static"
+AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
+[libgo_cv_ld_static=yes],
+[libgo_cv_ld_static=no])
+LDFLAGS=$LDFLAGS_hold])
+AM_CONDITIONAL(HAVE_STATIC_LINK, test "$libgo_cv_ld_static" = yes)
+
 AC_CACHE_SAVE
 
 if test ${multilib} = yes; then
@@ -938,7 +921,7 @@ else
   multilib_arg=
 fi
 
-AC_CONFIG_FILES(Makefile testsuite/Makefile)
+AC_CONFIG_FILES(Makefile testsuite/Makefile testsuite/libgo-test-support.exp)
 
 AC_CONFIG_COMMANDS([default],
 [if test -n "$CONFIG_FILES"; then