cabal passes incorrect --host= when cross-compiling
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
Noticed today that ghc-HEAD now fails cross-compilation from linux to windows.
The cause is non-canonical for of the `--host=` passed by Cabal, likely caused by https://github.com/haskell/cabal/commit/5ef34786d051d5fd2ec6cd04b1226e86e57236b8
Here is the reproducer:
```
cd ghc-HEAD
$ ./configure --target=x86_64-w64-mingw32
$ make
...
checking Haskell type for useconds_t... Word32
checking Haskell type for suseconds_t... configure: error: type not found
```
**libraries/base/dist-install/build/config.log** shows extra argument:
```
$ //home/slyfox/dev/git/ghc-mingw32/libraries/base/configure --with-compiler=ghc CFLAGS=-Wall -Werror=unused-but-set-variable -Wno-error=inline LDFLAGS= CPPFLAGS= --host=x86_64-w64-mingw32 CC=/usr/lib/ccache/bin/x86_64-w64-mingw32-gcc --host=x86_64-windows
```
Note how --host is passed twice:
- **--host=x86_64-w64-mingw32** (ok, the tools are expected to have this name)
- **--host=x86_64-windows** (bad, overrides tool names, directories and breaks $host match in https://github.com/ghc/ghc/blob/master/libraries/base/configure.ac#L19 ):
```
case $host in
*mingw32*|*mingw64*|*cygwin*|*msys*)
WINDOWS=YES;;
*)
WINDOWS=NO;;
esac
```
Cabal should pass `--host=` unmangled. Otherwise `${host}-` toolchain tools would not detect correctly.
Contributor guide
Assessment
This issue has not been assessed yet.