haskell / haskell/cabal

cabal passes incorrect --host= when cross-compiling

Open
#5,887 3 comments 0 reactions 0 assignees View on GitHub
cross-compilation type: bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.