[commit: ghc] master: Provide way to build using existing C compiler on Windows. (fda094d)

git at git.haskell.org git at git.haskell.org
Fri Jun 16 23:49:29 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/fda094d000cf2c2874a8205c8212cb83b52259ef/ghc

>---------------------------------------------------------------

commit fda094d000cf2c2874a8205c8212cb83b52259ef
Author: Tamar Christina <tamar at zhox.com>
Date:   Sun Jun 11 11:40:11 2017 +0100

    Provide way to build using existing C compiler on Windows.
    
    Summary:
    There are various distros that build GHC using their own C compilers
    such as MSYS2. Currently they have to patch the build scripts everytime.
    
    This patch provides the configure argument `--enable-distro-toolchain`
    which allows one to build using any C compiler on the path.
    
    This is also useful for testing new versions of GCC.
    
    Test Plan:
    ./configure --enable-distro-toolchain && make - && make THREADS=9 test
    ./validate
    
    Reviewers: austin, hvr, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, erikd, #ghc_windows_task_force
    
    GHC Trac Issues: #13792
    
    Differential Revision: https://phabricator.haskell.org/D3637


>---------------------------------------------------------------

fda094d000cf2c2874a8205c8212cb83b52259ef
 aclocal.m4                       | 22 ++++++++++++++-----
 configure.ac                     | 47 ++++++++++++++++++++++++++++++++++++----
 docs/users_guide/8.4.1-notes.rst |  4 ++++
 3 files changed, 64 insertions(+), 9 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index d566f83..db394f3 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -460,7 +460,7 @@ AC_DEFUN([GET_ARM_ISA],
 # Set the variables used in the settings file
 AC_DEFUN([FP_SETTINGS],
 [
-    if test "$windows" = YES
+    if test "$windows" = YES -a "$EnableDistroToolchain" = "NO"
     then
         mingw_bin_prefix=mingw/bin/
         SettingsCCompilerCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
@@ -472,6 +472,18 @@ AC_DEFUN([FP_SETTINGS],
         SettingsDllWrapCommand="\$topdir/../${mingw_bin_prefix}dllwrap.exe"
         SettingsWindresCommand="\$topdir/../${mingw_bin_prefix}windres.exe"
         SettingsTouchCommand='$topdir/bin/touchy.exe'
+    elif test "$EnableDistroToolchain" = "YES"
+    then
+        SettingsCCompilerCommand="$(basename $CC)"
+        SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
+        SettingsHaskellCPPCommand="$(basename $HaskellCPPCmd)"
+        SettingsHaskellCPPFlags="$HaskellCPPArgs"
+        SettingsLdCommand="$(basename $LdCmd)"
+        SettingsArCommand="$(basename $ArCmd)"
+        SettingsPerlCommand="$(basename $PerlCmd)"
+        SettingsDllWrapCommand="$(basename $DllWrapCmd)"
+        SettingsWindresCommand="$(basename $WindresCmd)"
+        SettingsTouchCommand='$topdir/bin/touchy.exe'
     else
         SettingsCCompilerCommand="$CC"
         SettingsHaskellCPPCommand="$HaskellCPPCmd"
@@ -479,17 +491,17 @@ AC_DEFUN([FP_SETTINGS],
         SettingsLdCommand="$LdCmd"
         SettingsArCommand="$ArCmd"
         SettingsPerlCommand="$PerlCmd"
-        if test -z "$DllWrap"
+        if test -z "$DllWrapCmd"
         then
             SettingsDllWrapCommand="/bin/false"
         else
-            SettingsDllWrapCommand="$DllWrap"
+            SettingsDllWrapCommand="$DllWrapCmd"
         fi
-        if test -z "$Windres"
+        if test -z "$WindresCmd"
         then
             SettingsWindresCommand="/bin/false"
         else
-            SettingsWindresCommand="$Windres"
+            SettingsWindresCommand="$WindresCmd"
         fi
        SettingsTouchCommand='touch'
     fi
diff --git a/configure.ac b/configure.ac
index a32e6b4..721f0e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)])
@@ -365,7 +376,7 @@ set_up_tarballs() {
     fi
 }
 
-if test "$HostOS" = "mingw32"
+if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"
 then
     test -d inplace || mkdir inplace
 
@@ -395,6 +406,29 @@ 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([LD],[ld], [lld])
+    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])
+
+    DllWrapCmd="$DllWrap"
+    WindresCmd="$Windres"
+
+    AC_SUBST([DllWrapCmd])
+    AC_SUBST([WindresCmd])
+fi
+
 FP_ICONV
 FP_GMP
 FP_CURSES
@@ -461,6 +495,7 @@ fi
 AC_SUBST(CrossCompiling)
 AC_SUBST(CrossCompilePrefix)
 AC_SUBST(TargetPlatformFull)
+AC_SUBST(EnableDistroToolchain)
 
 dnl ** Which gcc to use?
 dnl --------------------------------------------------------------
@@ -621,7 +656,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])
@@ -1258,8 +1297,8 @@ echo "\
    libtool      : $LibtoolCmd
    objdump      : $ObjdumpCmd
    ranlib       : $RanlibCmd
-   windres      : $Windres
-   dllwrap      : $DllWrap
+   windres      : $WindresCmd
+   dllwrap      : $DllWrapCmd
    Happy        : $HappyCmd ($HappyVersion)
    Alex         : $AlexCmd ($AlexVersion)
    Perl         : $PerlCmd
diff --git a/docs/users_guide/8.4.1-notes.rst b/docs/users_guide/8.4.1-notes.rst
index 5929998..f23cb36 100644
--- a/docs/users_guide/8.4.1-notes.rst
+++ b/docs/users_guide/8.4.1-notes.rst
@@ -76,6 +76,10 @@ Now we generate ::
 
       _ == _ = error ...
 
+- Configure on Windows now supports ``--enable-distro-toolchain`` which can be
+  used to build a GHC using compilers on your ``PATH`` instead of using the
+  bundled bindist. See :ghc-ticket:`13792`
+
 - Lots of other bugs. See `Trac <https://ghc.haskell.org/trac/ghc/query?status=closed&milestone=8.4.1&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component&order=priority>`_
   for a complete list.
 



More information about the ghc-commits mailing list