Always pass `ghc-options` (#8717)
commit9c775f2f6dd9ce03f62573f40e2738487cbe0c2b
authorRebecca Turner <rbt@sent.as>
Mon, 19 Aug 2024 12:17:37 +0000 (19 08:17 -0400)
committerGitHub <noreply@github.com>
Mon, 19 Aug 2024 12:17:37 +0000 (19 12:17 +0000)
treec6744fa6a91ef6f939f8d3d9520c52cbeb40e7fe
parent969343a7dda6a2128f92670b4d33948f2f526b3c
Always pass `ghc-options` (#8717)

* Always pass `ghc-options`

The [documentation for `ghc-shared-options`][1] states that they are
combined with `ghc-options`:

> Additional options for GHC when the package is built as shared
> library. The options specified via this field are combined with the
> ones specified via `ghc-options`, and are passed to GHC during both
> the compile and link phases.

However, _only_ `ghc-shared-options` and not `ghc-options` are passed in
many cases.

This is an issue because it requires setting `ghc-shared-options` even
if the shared (dynamic) parts of the build don't actually need different
options; this has the unpleasant side-effect of causing modules to be
compiled twice, effectively doubling compile time! See here, where any
non-empty `ghc-shared-options` causes Cabal to not set `-dynamic-too`:

https://github.com/haskell/cabal/blob/acbc0f3a5cc9faf0913ff3e270196693816cec41/Cabal/src/Distribution/Simple/GHC.hs#L1466-L1469

This issue was discovered while integrating the `mold` linker with a
Haskell project.

[1]: https://cabal.readthedocs.io/en/latest/cabal-package.html#pkg-field-ghc-shared-options

* Add documentation

* Also enhance profArgs and profDynArgs

---------

Co-authored-by: Hécate Moonlight <hecate+github@glitchbra.in>
Co-authored-by: Hécate <Kleidukos@users.noreply.github.com>
Cabal/src/Distribution/Simple/GHC.hs
Cabal/src/Distribution/Simple/GHCJS.hs
changelog.d/pr-8717 [new file with mode: 0644]
doc/cabal-package-description-file.rst