Provide way to build using existing C compiler on Windows.
ClosedPublic

Authored by Phyx on Jun 11 2017, 5:48 AM.

Details

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

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
Phyx created this revision.Jun 11 2017, 5:48 AM
bgamari accepted this revision.Jun 11 2017, 9:54 PM

Sounds good to me.

This revision is now accepted and ready to land.Jun 11 2017, 9:54 PM
This revision was automatically updated to reflect the committed changes.
trofi added a subscriber: trofi.Jul 22 2017, 5:15 AM
trofi added inline comments.
configure.ac
416

What is wrong with prefixed toolchain?

This change breaks crosscompilation to windows (and any other target)
because instead of target toolchain host toolchain is picked:

./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=i686-w64-mingw32 --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=
/etc --localstatedir=/var/lib --libdir=/usr/lib64 AR=i686-w64-mingw32-ar CC=i686-w64-mingw32-gcc --enable-distro-toolchain --disable-ld-override LD=i686-w64-mingw32-ld --enable-bootstrap-with
-devel-snapshot

   hs-cpp       : /usr/bin/gcc
   hs-cpp-flags : -E -undef -traditional
   ar           : /usr/bin/ar
   ld           : i686-w64-mingw32-ld
   nm           : /usr/bin/nm
   libtool      : 
   objdump      : /usr/bin/objdump
   ranlib       : /usr/bin/ranlib
   windres      : /usr/bin/windres
   dllwrap      : /usr/bin/dllwrap

These cpp, ar, nm, objdump are not related to target toolchain at all. Build fails as a result:

inplace/bin/deriveConstants --gen-header -o includes/dist-derivedconstants/header/DerivedConstants.h --tmpdir includes/dist-derivedconstants/header/ --gcc-program "/usr/bin/gcc" --gcc-flag -O2 --gcc-flag -pipe --gcc-flag -Wall --gcc-flag -Werror=unused-but-set-variable --gcc-flag -Wno-error=inline --gcc-flag -fno-stack-protector --gcc-flag -Iincludes --gcc-flag -Iincludes/dist --gcc-flag -Iincludes/dist-derivedconstants/header --gcc-flag -Iincludes/dist-ghcconstants/header --gcc-flag -Irts --gcc-flag -fcommon --nm-program "/usr/bin/nm" --objdump-program "/usr/bin/objdump" --target-os "mingw32"
In file included from includes/Rts.h:168:0,
                 from includes/dist-derivedconstants/header/tmp.c:13:
includes/rts/OSThreads.h:157:4: error: #error "Threads not supported"
 #  error "Threads not supported"
    ^~~~~
Phyx added inline comments.Jul 22 2017, 6:53 AM
configure.ac
416

I don't understand, how can this change break anything when it's off by default?
It's one and specific purpose was to support msys2 deployment and easier testing of newer GCC bindist on Windows.

Not to support Cross compilation, which is why I don't use a the prefixed toolchains. Cross compilation was never the goal.
The comment specifically says "Do not use bundled Windows toolchain binaries", what other targets are you trying to use this Windows only flag for?