Hadrian on Windows fails to configure libffi for lack of C compiler
When building GHC through hadrian/build.stack.bat -j5 --flavour=devel2
, it ultimately fails with the following error:
...
| Run Tar Extract: libffi-tarballs/libffi-3.99999+git20171002+77e130c.tar.gz => _build/stage1
| Move directory: _build/stage1/libffi-3.99999 => _build/stage1/libffi/build
| Fix _build/stage1/libffi/build/Makefile.in
| Copy file: config.guess => _build/stage1/libffi/build/config.guess
| Copy file: config.sub => _build/stage1/libffi/build/config.sub
| Run Configure "_build/stage1/libffi/build": _build/stage1/libffi/build/Makefile.in => _build/stage1/libffi/build/Makefile
configure: error: in `/mnt/c/Users/Sebas/Documents/Code/Haskell/ghc/pmcheck/_build/stage1/libffi/build/x86_64-unknown-mingw32':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
Error when running Shake build system:
at action, called at src\Rules.hs:69:19 in main:Rules
at need, called at src\Rules.hs:91:5 in main:Rules
* Depends on: _build/stage1/bin/hp2ps.exe
at need, called at src\Utilities.hs:71:18 in main:Utilities
* Depends on: _build/stage1/rts/build/libHSrts-1.0_thr.a
at need, called at src\Rules\Library.hs:121:5 in main:Rules.Library
* Depends on: _build/stage1/rts/build/c/sm/Storage.thr_o
at need, called at src\Rules\Compile.hs:238:13 in main:Rules.Compile
* Depends on: _build/stage1/rts/build/ffi.h
at &%>, called at src\Rules\Libffi.hs:104:20 in main:Rules.Libffi
* Depends on: _build/stage1/libffi/build/inst/lib/libffi.a _build/stage1/rts/build/ffi.h _build/stage1/rts/build/ffitarget.h
at need, called at src\Hadrian\Builder.hs:70:5 in main:Hadrian.Builder
* Depends on: _build/stage1/libffi/build/Makefile
at &%>, called at src\Rules\Libffi.hs:198:5 in main:Rules.Libffi
* Depends on: _build/stage1/libffi/build/Makefile _build/stage1/libffi/build/config.guess _build/stage1/libffi/build/config.sub
* Raised the exception:
user error (Development.Shake.cmd, system command failed
Command: sh configure --prefix=C:/Users/Sebas/Documents/Code/Haskell/ghc/pmcheck/_build/stage1/libffi/build/inst --libdir=C:/Users/Sebas/Documents/Code/Haskell/ghc/pmcheck/_build/stage1/libffi/build/inst/lib --enable-static=yes --enable-shared=no --host=x86_64-unknown-mingw32
Current directory: C:\Users\Sebas\Documents\Code\Haskell\ghc\pmcheck\_build\stage1\libffi\build
Exit code: 1
Stderr:
configure: error: in `/mnt/c/Users/Sebas/Documents/Code/Haskell/ghc/pmcheck/_build/stage1/libffi/build/x86_64-unknown-mingw32':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
)
Where config.log contains entries of $PATH that are completely irrelevant, there isn't even mention of any MinGW related path. Looking at hadrian/src/Rules/Libffi.configureEnvironment
, this isn't really the culprit, as we set the C compiler explicitly through $CC. But the configure script doesn't seem to pick that up. Manually running the configure invocation from a MinGW shell works flawlessly.
I did some digging and identified that this old Windows-related hack seems to be the culprit: https://gitlab.haskell.org/ghc/ghc/blob/0040af598865733e6565530f4b036e11563976fc/hadrian/src/Builder.hs#L247-250 If I remove that, it configures just fine. I think that whatever magic that does, the resulting bash shell will not pick up the right environment and thus fail to configure correctly.
Anyone else having similar problems lately? I'm not confident that this hack should stay there, given that there is no reason why it is there in the first place.