haskell / haskell/cabal

Using Setup.hs build --with-ghc looses configure --ghc-option

Open
#10,069 1 comment 0 reactions 0 assignees View on GitHub
needs triage type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**

When using `Setup.hs`'s `configure` + `build` steps a GHC option passed in the configure is not applied in the build step, when the build step uses the `--with-ghc` option.

**To Reproduce**

Using the [hello world package from hackage](https://hackage.haskell.org/package/hello).

```
$ runhaskell Setup.hs configure --ghc-options=-j2
$ runhaskell Setup.hs build -v --with-ghc=ghc
[...]
Running: [...]/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir dist/build/hello/hello-tmp
-odir dist/build/hello/hello-tmp -hidir dist/build/hello/hello-tmp -hiedir dist/build/hello/hello-tmp/extra-compilation-artifacts/hie
-stubdir dist/build/hello/hello-tmp -i -isrc -idist/build/hello/hello-tmp -idist/build/hello/autogen -idist/build/global-autogen
-Idist/build/hello/autogen -Idist/build/global-autogen -Idist/build/hello/hello-tmp -optP-include
-optPdist/build/hello/autogen/cabal_macros.h -this-unit-id hello-1.0.0.2-9svDvC3HZPN7tI0quUyWXf-hello
-hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db dist/package.conf.inplace
-package-id base-4.20.0.0-18ae -XHaskell98 src/hello.hs
[...]
```

The `-j2` is not passed.

**Expected behavior**

`-j2` should be passed to `ghc`. The same output when running build without `--with-ghc`:

```
Running: [...]/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir dist/build/hello/hello-tmp
-odir dist/build/hello/hello-tmp -hidir dist/build/hello/hello-tmp -hiedir dist/build/hello/hello-tmp/extra-compilation-artifacts/hie
-stubdir dist/build/hello/hello-tmp -i -isrc -idist/build/hello/hello-tmp -idist/build/hello/autogen -idist/build/global-autogen
-Idist/build/hello/autogen -Idist/build/global-autogen -Idist/build/hello/hello-tmp -optP-include
-optPdist/build/hello/autogen/cabal_macros.h -this-unit-id hello-1.0.0.2-9svDvC3HZPN7tI0quUyWXf-hello
-hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db dist/package.conf.inplace
-package-id base-4.20.0.0-18ae -XHaskell98 src/hello.hs -j2
```

Note the additional `-j2` at the end.

**System information**

Tested with various cabal and GHC versions. Still present in cabal 3.10.3.0, but was also there in 3.8.x.

**Additional context**

First noticed in [nixpkgs when cross-compiling](https://github.com/NixOS/nixpkgs/issues/286285).

Workaround: Remove `--with-ghc` from `build` step - it's added in `configure` anyway.

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.