-prof GHC flag should not to be used with --ghc-options cabal flag
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
When a user wants to run with cost modelling profiling enabled, they need to use `+RTS -p`. For this to work and when invoking GHC directly, the user types:
```
$ ghc -prof -fprof-auto -rtsopts Main.hs
```
However, if they are using cabal, they should type:
```
$ cabal install --enable-executable-profiling --enable-library-profiling --ghc-options="-fprof-auto -rtsopts"
```
It might not be clear that when cabal is used to invoke GHC, `-prof` should **not** be used in `--ghc-options`. If it is included, then they are likely to see compiler error messages relating to p_dyn, e.g.
```
Failed to load interface for ‘GHC.Integer.Type’
Perhaps you haven't installed the "p_dyn" libraries for package ‘integer-gmp-1.0.0.0’?
Use -v to see a list of the files searched for.
```
I initially raised this as a GHC documentation bug, but there it has been suggested that instead, cabal should throw an error or at least print a warning that `-prof` should not appear in the string passed to `--ghc-options`.
This is the GHC ticket, that I'd like to close once the corresponding stack and cabal tickets are discussed: https://ghc.haskell.org/trac/ghc/ticket/10894
This is the mirrored stack ticket: https://github.com/commercialhaskell/stack/issues/1015
Contributor guide
Research direction
Start by reviewing Cabal's handling of the --ghc-options argument and the linked GHC and Stack tickets. The work is done when Cabal warns or errors when -prof is included in --ghc-options, without requiring users to diagnose the p_dyn compiler errors themselves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100