I try to cross-compile GHC 8.0.1 with x86_64-mingw toolchain (gcc 6.2.1) and native GHC 8.0.1. Sources are from http://downloads.haskell.org/~ghc/8.0.1/ghc-8.0.1-src.tar.xz
cp mk/build.mk.example mk/build.mk
sed -i '1iBuildFlavour = perf' mk/build.mk
sed -i '1iStage1Only = YES' mk/build.mk
sed -i '1iHADDOCK_DOCS = NO' mk/build.mk
./configure --prefix=~/x86_64-mingw \
--target=x86_64-unknown-mingw32 \
--with-gcc=/usr/bin/x86_64-w64-mingw32-gcc \
--with-ld=/usr/bin/x86_64-w64-mingw32-ld \
--with-nm=/usr/bin/x86_64-w64-mingw32-nm \
--with-ar=/usr/bin/x86_64-w64-mingw32-ar \
--with-ranlib=/usr/bin/x86_64-w64-mingw32-ranlib
make -j8 install
First encountered error is in Types.hsc:
Types.hsc: In function ‘_hsc2hs_test44’:
Types.hsc:219:20: error: storage size of ‘test_array’ isn’t constant
There are testing scripts in utils/hsc2hs/CrossCodegen.hs that create such code:
void _hsc2hs_test44() {
static int test_array[value];
...
where 'value' is const int, that is forbidden by C standard. GCC older then 4.4 reject this code, but Clang doesn't (does with -pedantic-errors). But with-gcc=/usr/bin/x86_64-w64-mingw32-clang fails sooner, so it cannot help.
So I compiled Types.hsc (and three others) with clang and go further.
Second error:
rts/posix/GetTime.c:25:2: error: #error No implementation for getProcessCPUTime() available.
#error No implementation for getProcessCPUTime() available.
In file there are such strings:
#if ! ((defined(HAVE_GETRUSAGE) && !irix_HOST_OS) || defined(HAVE_TIMES))
#error No implementation for getProcessCPUTime() available.
#endif
Linux definitely hasn't such function, it's a part of Windows API.