Commit fda094d0 authored by Tamar Christina's avatar Tamar Christina

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
parent dc8e6861
...@@ -460,7 +460,7 @@ AC_DEFUN([GET_ARM_ISA], ...@@ -460,7 +460,7 @@ AC_DEFUN([GET_ARM_ISA],
# Set the variables used in the settings file # Set the variables used in the settings file
AC_DEFUN([FP_SETTINGS], AC_DEFUN([FP_SETTINGS],
[ [
if test "$windows" = YES if test "$windows" = YES -a "$EnableDistroToolchain" = "NO"
then then
mingw_bin_prefix=mingw/bin/ mingw_bin_prefix=mingw/bin/
SettingsCCompilerCommand="\$topdir/../${mingw_bin_prefix}gcc.exe" SettingsCCompilerCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
...@@ -472,6 +472,18 @@ AC_DEFUN([FP_SETTINGS], ...@@ -472,6 +472,18 @@ AC_DEFUN([FP_SETTINGS],
SettingsDllWrapCommand="\$topdir/../${mingw_bin_prefix}dllwrap.exe" SettingsDllWrapCommand="\$topdir/../${mingw_bin_prefix}dllwrap.exe"
SettingsWindresCommand="\$topdir/../${mingw_bin_prefix}windres.exe" SettingsWindresCommand="\$topdir/../${mingw_bin_prefix}windres.exe"
SettingsTouchCommand='$topdir/bin/touchy.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 else
SettingsCCompilerCommand="$CC" SettingsCCompilerCommand="$CC"
SettingsHaskellCPPCommand="$HaskellCPPCmd" SettingsHaskellCPPCommand="$HaskellCPPCmd"
...@@ -479,17 +491,17 @@ AC_DEFUN([FP_SETTINGS], ...@@ -479,17 +491,17 @@ AC_DEFUN([FP_SETTINGS],
SettingsLdCommand="$LdCmd" SettingsLdCommand="$LdCmd"
SettingsArCommand="$ArCmd" SettingsArCommand="$ArCmd"
SettingsPerlCommand="$PerlCmd" SettingsPerlCommand="$PerlCmd"
if test -z "$DllWrap" if test -z "$DllWrapCmd"
then then
SettingsDllWrapCommand="/bin/false" SettingsDllWrapCommand="/bin/false"
else else
SettingsDllWrapCommand="$DllWrap" SettingsDllWrapCommand="$DllWrapCmd"
fi fi
if test -z "$Windres" if test -z "$WindresCmd"
then then
SettingsWindresCommand="/bin/false" SettingsWindresCommand="/bin/false"
else else
SettingsWindresCommand="$Windres" SettingsWindresCommand="$WindresCmd"
fi fi
SettingsTouchCommand='touch' SettingsTouchCommand='touch'
fi fi
......
...@@ -113,6 +113,17 @@ AC_ARG_ENABLE(tarballs-autodownload, ...@@ -113,6 +113,17 @@ AC_ARG_ENABLE(tarballs-autodownload,
TarballsAutodownload=NO 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 CC_STAGE0 is like the "previous" variable CC (inherited by CC_STAGE[123])
dnl but instead used by stage0 for bootstrapping stage1 dnl but instead used by stage0 for bootstrapping stage1
AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)]) AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)])
...@@ -365,7 +376,7 @@ set_up_tarballs() { ...@@ -365,7 +376,7 @@ set_up_tarballs() {
fi fi
} }
if test "$HostOS" = "mingw32" if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"
then then
test -d inplace || mkdir inplace test -d inplace || mkdir inplace
...@@ -395,6 +406,29 @@ then ...@@ -395,6 +406,29 @@ then
fi fi
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_ICONV
FP_GMP FP_GMP
FP_CURSES FP_CURSES
...@@ -461,6 +495,7 @@ fi ...@@ -461,6 +495,7 @@ fi
AC_SUBST(CrossCompiling) AC_SUBST(CrossCompiling)
AC_SUBST(CrossCompilePrefix) AC_SUBST(CrossCompilePrefix)
AC_SUBST(TargetPlatformFull) AC_SUBST(TargetPlatformFull)
AC_SUBST(EnableDistroToolchain)
dnl ** Which gcc to use? dnl ** Which gcc to use?
dnl -------------------------------------------------------------- dnl --------------------------------------------------------------
...@@ -621,7 +656,11 @@ SplitObjsBroken=NO ...@@ -621,7 +656,11 @@ SplitObjsBroken=NO
dnl ** look for `perl' dnl ** look for `perl'
case $HostOS_CPP in case $HostOS_CPP in
cygwin32|mingw32) 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]) AC_PATH_PROG([PerlCmd],[perl])
...@@ -1258,8 +1297,8 @@ echo "\ ...@@ -1258,8 +1297,8 @@ echo "\
libtool : $LibtoolCmd libtool : $LibtoolCmd
objdump : $ObjdumpCmd objdump : $ObjdumpCmd
ranlib : $RanlibCmd ranlib : $RanlibCmd
windres : $Windres windres : $WindresCmd
dllwrap : $DllWrap dllwrap : $DllWrapCmd
Happy : $HappyCmd ($HappyVersion) Happy : $HappyCmd ($HappyVersion)
Alex : $AlexCmd ($AlexVersion) Alex : $AlexCmd ($AlexVersion)
Perl : $PerlCmd Perl : $PerlCmd
......
...@@ -76,6 +76,10 @@ Now we generate :: ...@@ -76,6 +76,10 @@ Now we generate ::
_ == _ = error ... _ == _ = 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>`_ - 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. for a complete list.
...@@ -84,7 +88,7 @@ Runtime system ...@@ -84,7 +88,7 @@ Runtime system
- Function ``hs_add_root()`` was removed. It was a no-op since GHC-7.2.1 - Function ``hs_add_root()`` was removed. It was a no-op since GHC-7.2.1
where module initialisation stopped requiring a call to ``hs_add_root()``. where module initialisation stopped requiring a call to ``hs_add_root()``.
- Proper import library support added to GHC which can handle all of the libraries produced - Proper import library support added to GHC which can handle all of the libraries produced
by dlltool. The limitation of them needing to be named with the suffix .dll.a is also removed. by dlltool. The limitation of them needing to be named with the suffix .dll.a is also removed.
See :ghc-ticket:`13606`, :ghc-ticket:`12499`, :ghc-ticket:`12498` See :ghc-ticket:`13606`, :ghc-ticket:`12499`, :ghc-ticket:`12498`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment