v2-build does not pass ghc-options in `.cabal/config` to ghc when building custom Setup.hs
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
In case that cabal's new-build and new-install compile the package's custom Setup.hs, ghc-options in `~/.cabal/config` is not passed to ghc.
**To Reproduce**
Steps to reproduce the behavior:
1. Put `ghc-options: -dynamic` in `program-default-options` section in `~/.cabal/config`
2. Untar cabal-install source tarball
3. In that directory, cabal v2-build -v
4. Find the `/usr/bin/ghc` command-line for cabal-install's `setup.hs` does not have `-dynamic option`
```
$ cabal v2-build -v
...
creating
/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0
creating
/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5
creating
/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux
creating
/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5
creating
/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0
creating
/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/cache
creating
/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/setup
copy /home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/./Setup.hs to
/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/setup/setup.hs
/usr/bin/ghc --make -fbuilding-cabal-package -odir /home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/setup -hidir /home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/setup -i -i/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/. -optP-include -optP/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/setup/setup_macros.h -hide-all-packages -no-user-package-db -package-db /home/esrevinu/.cabal/store/ghc-8.6.5/package.db -package-db /home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/packagedb/ghc-8.6.5 -package-id Cabal-3.0.0.0-46bddd9dcdb0614f6b3d4b9186e1471e15bdb76d345f3381c71918ee64d5fd9d -package-id base-4.12.0.0 -package-id filepath-1.4.2.1 -package-id process-1.6.5.0 /home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/setup/setup.hs -o /home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/setup/setup -threaded
[1 of 1] Compiling Main ( /home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/setup/setup.hs, /home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/setup/Main.o )
/home/esrevinu/tmp/cabal-install/cabal-install-3.0.0.0/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cabal-install-3.0.0.0/setup/setup.hs:1:1: error:
Could not find module ‘Prelude’
There are files missing in the ‘base-4.12.0.0’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
|
1 | import Distribution.PackageDescription ( PackageDescription )
| ^
```
**Expected behavior**
`-dynamic` option should be passed to ghc so that ghc can compile that `setup.hs` on Arch Linux without static library.
**System information**
- Operating system: Arch Linux
- `cabal`, `ghc` versions: cabal-install version 3.0.0.0
compiled using version 3.0.0.0 of the Cabal library, ghc 8.6.5; also cabal-install 2.4.0.0 and Cabal 2.4.0.1
**Additional context**
With cabal-install 3.0.0.0, `--ghc-options=-dynamic` command-line option passes the option to ghc.
Building library package Cabal-3.0.0.0 does not fail. I think that it is because Cabal package is built `Using self-exec internal setup method with build-type Simple and args`.
Contributor guide
Assessment
This issue has not been assessed yet.