Ensure that GHC.Stack.callStack doesn't fail
[ghc.git] / configure.ac
index ba5836d..00fae0a 100644 (file)
@@ -13,7 +13,7 @@ dnl
 # see what flags are available. (Better yet, read the documentation!)
 #
 
-AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.1], [glasgow-haskell-bugs@haskell.org], [ghc-AC_PACKAGE_VERSION])
+AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.3], [glasgow-haskell-bugs@haskell.org], [ghc-AC_PACKAGE_VERSION])
 
 # Set this to YES for a released version, otherwise NO
 : ${RELEASE=NO}
@@ -113,6 +113,17 @@ AC_ARG_ENABLE(tarballs-autodownload,
         TarballsAutodownload=NO
 )
 
+AC_ARG_ENABLE(distro-toolchain,
+[AC_HELP_STRING([--enable-distro-toolchain],
+                [Do not use bundled Windows toolchain binaries.])],
+        EnableDistroToolchain=YES,
+        EnableDistroToolchain=NO
+)
+
+if test "$EnableDistroToolchain" = "YES"; then
+  TarballsAutodownload=NO
+fi
+
 dnl CC_STAGE0 is like the "previous" variable CC (inherited by CC_STAGE[123])
 dnl but instead used by stage0 for bootstrapping stage1
 AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)])
@@ -177,9 +188,13 @@ then
 
     if test "$ghc_host_os" = "mingw32"
     then
-        # Canonicalise to <drive>:/path/to/ghc
-        WithGhc=`cygpath -m "${WithGhc}"`
-
+        if test "${OSTYPE}" = "msys"
+        then
+            WithGhc=`echo "${WithGhc}" | sed "s#^/\([a-zA-Z]\)/#\1:/#"`
+        else
+            # Canonicalise to <drive>:/path/to/ghc
+            WithGhc=`cygpath -m "${WithGhc}"`
+        fi
         echo "GHC path canonicalised to: ${WithGhc}"
     fi
 fi
@@ -241,8 +256,8 @@ AC_SUBST(SOLARIS_BROKEN_SHLD)
 
 dnl ** Do an unregisterised build?
 dnl --------------------------------------------------------------
-case "$HostArch" in
-    i386|x86_64|powerpc|powerpc64|powerpc64le|arm)
+case "$TargetArch" in
+    i386|x86_64|powerpc|powerpc64|powerpc64le|arm|aarch64)
         UnregisterisedDefault=NO
         ;;
     *)
@@ -361,7 +376,7 @@ set_up_tarballs() {
     fi
 }
 
-if test "$HostOS" = "mingw32"
+if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"
 then
     test -d inplace || mkdir inplace
 
@@ -374,8 +389,6 @@ then
     NM="${mingwbin}nm.exe"
     RANLIB="${mingwbin}ranlib.exe"
     OBJDUMP="${mingwbin}objdump.exe"
-    Windres="${mingwbin}windres.exe"
-    DllWrap="${mingwbin}dllwrap.exe"
     fp_prog_ar="${mingwbin}ar.exe"
 
     # NB. Download the perl binaries if required
@@ -393,6 +406,28 @@ then
     fi
 fi
 
+# We don't want to bundle a MinGW-w64 toolchain
+# So we have to find these individual tools.
+if test "$EnableDistroToolchain" = "YES"
+then
+    # Ideally should use AC_CHECK_TARGET_TOOL but our triples
+    # are screwed up. Configure doesn't think they're ever equal and
+    # so never tried without the prefix.
+    AC_PATH_PROG([CC],[gcc], [clang])
+    AC_PATH_PROG([NM],[nm])
+    AC_PATH_PROG([AR],[ar])
+    AC_PATH_PROG([RANLIB],[ranlib])
+    AC_PATH_PROG([OBJDUMP],[objdump])
+    AC_PATH_PROG([DllWrap],[dllwrap])
+    AC_PATH_PROG([Windres],[windres])
+fi
+
+DllWrapCmd="$DllWrap"
+WindresCmd="$Windres"
+
+AC_SUBST([DllWrapCmd])
+AC_SUBST([WindresCmd])
+
 FP_ICONV
 FP_GMP
 FP_CURSES
@@ -425,12 +460,6 @@ with a cross-compiler.  To cross-compile GHC itself, set TARGET: stage
 GHC.
 ])
 fi
-if test "$CrossCompiling" = "YES"
-then
-  CrossCompilePrefix="${target}-"
-else
-  CrossCompilePrefix=""
-fi
 # Despite its similarity in name to TargetPlatform, TargetPlatformFull is used
 # in calls to subproject configure scripts and thus must be set to the autoconf
 # triple, not the normalized GHC triple that TargetPlatform is set to.
@@ -442,14 +471,30 @@ fi
 # name (this is a known problem in the case of the Android NDK, which has
 # slightly odd triples).
 #
-# It may be better to just do away with the GHC triples altogether. This would
+# It may be better to just do away with the GHC triples altogether. This would
 # all be taken care of for us if we configured the subprojects using
 # AC_CONFIG_DIR, but unfortunately Cabal needs to be the one to do the
 # configuration.
-TargetPlatformFull="${target_alias}"
+#
+# We also use non-canonicalized triple when install stage1 crosscompiler
+if test -z "${target_alias}"
+then
+  # --target wasn't given; use result from AC_CANONICAL_TARGET
+  TargetPlatformFull="${target}"
+else
+  TargetPlatformFull="${target_alias}"
+fi
+if test "$CrossCompiling" = "YES"
+then
+  # Use value passed by user from --target=
+  CrossCompilePrefix="${TargetPlatformFull}-"
+else
+  CrossCompilePrefix=""
+fi
 AC_SUBST(CrossCompiling)
 AC_SUBST(CrossCompilePrefix)
 AC_SUBST(TargetPlatformFull)
+AC_SUBST(EnableDistroToolchain)
 
 dnl ** Which gcc to use?
 dnl --------------------------------------------------------------
@@ -484,14 +529,25 @@ FP_SET_CFLAGS_C99([CC_STAGE0],[CONF_CC_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
 FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
 FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
 
-dnl ** Which ld to use?
+dnl ** Choose a linker
 dnl --------------------------------------------------------------
-FIND_LD([LdCmd])
+FIND_LD([$target],[GccUseLdOpt])
+CONF_GCC_LINKER_OPTS_STAGE1="$CONF_GCC_LINKER_OPTS_STAGE1 $GccUseLdOpt"
+CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2 $GccUseLdOpt"
+LdCmd="$LD"
+CFLAGS="$CFLAGS $GccUseLdOpt"
 AC_SUBST([LdCmd])
 
 dnl ** Which nm to use?
 dnl --------------------------------------------------------------
-FP_ARG_WITH_PATH_GNU_PROG([NM], [nm], [nm])
+if test "$HostOS" != "mingw32"; then
+    AC_CHECK_TARGET_TOOL([NM], [nm])
+    if test "$NM" = ":"; then
+        AC_MSG_ERROR([cannot find nm in your PATH])
+    fi
+fi
+NmCmd="$NM"
+AC_SUBST([NmCmd])
 
 if test "$TargetOS_CPP" = "darwin"
 then
@@ -508,7 +564,7 @@ then
             echo
             echo "Try re-running configure with:"
             echo
-            echo '   ./configure --with-nm=$(xcrun --find nm-classic)'
+            echo '   NM=$(xcrun --find nm-classic) ./configure'
             echo
             exit 1
             ;;
@@ -518,58 +574,64 @@ then
         esac
 fi
 
-NmCmd="$NM"
-AC_SUBST([NmCmd])
-
 dnl ** Which objdump to use?
 dnl --------------------------------------------------------------
-FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([OBJDUMP], [objdump], [objdump])
+dnl Note: we may not have objdump on OS X, and we only need it on
+dnl Windows (for DLL checks), OpenBSD, and AIX
+case $HostOS_CPP in
+  cygwin32|mingw32|openbsd|aix)
+    AC_CHECK_TARGET_TOOL([OBJDUMP], [objdump])
+    ;;
+esac
+
 ObjdumpCmd="$OBJDUMP"
 AC_SUBST([ObjdumpCmd])
 
 dnl ** Which ar to use?
 dnl --------------------------------------------------------------
-FP_ARG_WITH_PATH_GNU_PROG([AR], [ar], [ar])
+if test "$HostOS" != "mingw32"; then
+    AC_CHECK_TARGET_TOOL([AR], [ar])
+    if test "$AR" = ":"; then
+        AC_MSG_ERROR([cannot find ar in your PATH])
+    fi
+fi
 ArCmd="$AR"
 fp_prog_ar="$AR"
 AC_SUBST([ArCmd])
 
 dnl ** Which ranlib to use?
 dnl --------------------------------------------------------------
-FP_ARG_WITH_PATH_GNU_PROG([RANLIB], [ranlib], [ranlib])
+AC_PROG_RANLIB
+if test "$RANLIB" = ":"; then
+    AC_MSG_ERROR([cannot find ranlib in your PATH])
+fi
 RanlibCmd="$RANLIB"
 RANLIB="$RanlibCmd"
 
-
-# Note: we may not have objdump on OS X, and we only need it on Windows (for DLL checks)
-case $HostOS_CPP in
-cygwin32|mingw32)
-    dnl ** Which objdump to use?
-    dnl --------------------------------------------------------------
-    FP_ARG_WITH_PATH_GNU_PROG([OBJDUMP], [objdump], [objdump])
-    ObjdumpCmd="$OBJDUMP"
-    AC_SUBST([ObjdumpCmd])
-    ;;
-esac
+dnl ** which libtool to use?
+dnl --------------------------------------------------------------
+AC_CHECK_TARGET_TOOL([LIBTOOL], [libtool])
+LibtoolCmd="$LIBTOOL"
+LIBTOOL="$LibtoolCmd"
 
 # Here is where we re-target which specific version of the LLVM
 # tools we are looking for. In the past, GHC supported a number of
 # versions of LLVM simultaneously, but that stopped working around
 # 3.5/3.6 release of LLVM.
-LlvmVersion=3.9
+LlvmVersion=4.0
 AC_SUBST([LlvmVersion])
 sUPPORTED_LLVM_VERSION=$(echo \($LlvmVersion\) | sed 's/\./,/')
 AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION], ${sUPPORTED_LLVM_VERSION}, [The supported LLVM version number])
 
 dnl ** Which LLVM llc to use?
 dnl --------------------------------------------------------------
-FIND_LLVM_PROG([LLC], [llc], [llc], [$LlvmVersion])
+FIND_LLVM_PROG([LLC], [llc], [$LlvmVersion])
 LlcCmd="$LLC"
 AC_SUBST([LlcCmd])
 
 dnl ** Which LLVM opt to use?
 dnl --------------------------------------------------------------
-FIND_LLVM_PROG([OPT], [opt], [opt], [$LlvmVersion])
+FIND_LLVM_PROG([OPT], [opt], [$LlvmVersion])
 OptCmd="$OPT"
 AC_SUBST([OptCmd])
 
@@ -598,7 +660,11 @@ SplitObjsBroken=NO
 dnl ** look for `perl'
 case $HostOS_CPP in
 cygwin32|mingw32)
-  PerlCmd=$hardtop/inplace/perl/perl
+  if test "$EnableDistroToolchain" = "NO"; then
+    PerlCmd=$hardtop/inplace/perl/perl
+  else
+    AC_PATH_PROG([PerlCmd],[perl])
+  fi
   ;;
 *)
     AC_PATH_PROG([PerlCmd],[perl])
@@ -631,7 +697,6 @@ FP_PROG_LD_BUILD_ID
 FP_PROG_LD_NO_COMPACT_UNWIND
 FP_PROG_LD_FILELIST
 
-
 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
@@ -696,6 +761,11 @@ dnl ** check for tar
 dnl   if GNU tar is named gtar, look for it first.
 AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar)
 
+dnl ** check for compressors
+AC_PATH_PROGS(Bzip2Cmd,bzip2, bzip2)
+AC_PATH_PROGS(GzipCmd,gzip, gzip)
+AC_PATH_PROGS(XzCmd,pxz xz, xz)
+
 dnl ** check for patch
 dnl if GNU patch is named gpatch, look for it first
 AC_PATH_PROGS(PatchCmd,gpatch patch, patch)
@@ -713,6 +783,7 @@ AC_SUBST(HaveDtrace)
 AC_PATH_PROG(HSCOLOUR,HsColour)
 # HsColour is passed to Cabal, so we need a native path
 if test "$HostOS"      = "mingw32" && \
+   test "${OSTYPE}"   != "msys"    && \
    test "${HSCOLOUR}" != ""
 then
     # Canonicalise to <drive>:/path/to/gcc
@@ -804,8 +875,8 @@ FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
 
 
 dnl for use in settings.in
-WordSize=$ac_cv_sizeof_void_p
-AC_SUBST(WordSize)
+TargetWordSize=$ac_cv_sizeof_void_p
+AC_SUBST(TargetWordSize)
 FP_CHECK_FUNC([WinExec],
   [@%:@include <windows.h>], [WinExec("",0)])
 
@@ -1070,10 +1141,10 @@ dnl ** Use MMAP in the runtime linker?
 dnl --------------------------------------------------------------
 
 case ${TargetOS} in
-    linux|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2)
+    linux|linux-android|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2)
         RtsLinkerUseMmap=1
         ;;
-    darwin)
+    darwin|ios)
         # Don't use mmap on powerpc/darwin as the mmap there doesn't support
         # reallocating. Reallocating is needed to allocate jump islands just
         # after each object image. Jumps to these jump islands use relative
@@ -1223,9 +1294,14 @@ echo "\
    Unregisterised            : $Unregisterised
    hs-cpp       : $HaskellCPPCmd
    hs-cpp-flags : $HaskellCPPArgs
+   ar           : $ArCmd
    ld           : $LdCmd
    nm           : $NmCmd
+   libtool      : $LibtoolCmd
    objdump      : $ObjdumpCmd
+   ranlib       : $RanlibCmd
+   windres      : $WindresCmd
+   dllwrap      : $DllWrapCmd
    Happy        : $HappyCmd ($HappyVersion)
    Alex         : $AlexCmd ($AlexVersion)
    Perl         : $PerlCmd