From fda094d000cf2c2874a8205c8212cb83b52259ef Mon Sep 17 00:00:00 2001 From: Tamar Christina Date: Sun, 11 Jun 2017 11:40:11 +0100 Subject: 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 --- configure.ac | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index a32e6b408c..721f0e7b8b 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 -- cgit v1.2.1