haskell / haskell/cabal

Feature Request: Allow to configure "default" GHC flags on the command-line

Open
#6,962 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

This is a feature request for Cabal the library, specifically for `Setup.hs`. Please expose [`ghcOptExtraDefault`](https://hackage.haskell.org/package/Cabal-3.2.0.0/docs/Distribution-Simple-Program-GHC.html#v:ghcOptExtraDefault) (or something to that effect) on the command-line.

I would like to be able to specify "default" GHC flags on the command-line to `Setup.hs configure` that can be overriden by flags specified in the Cabal file. An example use-case might look like this
```
runghc Setup.hs configure --default-ghc-option=-optc=-std=c99
```

These flags should appear on GHC's command-line before flags due to the Cabal file. In particular
```
runghc Setup.hs configure --default-ghc-option=-XNoOverloadedStrings
```
with a Cabal file containing `extensions: OverloadedStrings` should cause `OverloadedStrings` to be enabled during compilation.

The motivating use-case is rules_haskell, see https://github.com/tweag/rules_haskell/pull/1374. In that case we would like to forward GHC toolchain flags to Cabal builds as well, but in such a way that Cabal files can override these flags.

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.