Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always pass ghc-options (backport #8717) #10350

Merged
merged 1 commit into from
Sep 14, 2024
Merged

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 14, 2024

The documentation for ghc-shared-options 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:

-- Should we use -dynamic-too instead of compiling twice?
useDynToo = dynamicTooSupported && isGhcDynamic
&& doingTH && withStaticExe
&& null (hcSharedOptions GHC bnfo)

This issue was discovered while integrating the mold linker with a Haskell project; when ghc-shared-options wasn't set to the same value as ghc-options, the gold linker would be used instead of mold for various links during the build.


Please include the following checklist in your PR:

Please also shortly describe how you tested your change. Bonus points for added tests!

I've tested this by using Cabal with this patch applied to build a large commercial Haskell project (the mercury.com backend) and saw that the ghc-options were correctly applied (in this case, that meant observing that no links were performed with gold and all links were correctly performed with mold, as the options requested, with the exception of the single link described in #4439).

Possibly related issues:


This is an automatic backport of pull request #8717 done by [Mergify](https://mergify.com).

@mergify mergify bot added the conflicts label Sep 14, 2024
Copy link
Contributor Author

mergify bot commented Sep 14, 2024

Cherry-pick of 9c775f2 has failed:

On branch mergify/bp/3.12/pr-8717
Your branch is up to date with 'origin/3.12'.

You are currently cherry-picking commit 9c775f2f6.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   Cabal/src/Distribution/Simple/GHCJS.hs
	new file:   changelog.d/pr-8717

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   Cabal/src/Distribution/Simple/GHC.hs
	both modified:   doc/cabal-package-description-file.rst

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot mentioned this pull request Sep 14, 2024
3 tasks
@mergify mergify bot added the backport label Sep 14, 2024
@geekosaur geekosaur force-pushed the mergify/bp/3.12/pr-8717 branch from f87b166 to 125d592 Compare September 14, 2024 00:38
@geekosaur geekosaur force-pushed the mergify/bp/3.12/pr-8717 branch 2 times, most recently from 727a26c to ddbf40d Compare September 14, 2024 01:02
@geekosaur geekosaur added the merge me Tell Mergify Bot to merge label Sep 14, 2024
* 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 <[email protected]>
Co-authored-by: Hécate <[email protected]>
(cherry picked from commit 9c775f2)
@Mikolaj Mikolaj force-pushed the mergify/bp/3.12/pr-8717 branch from ddbf40d to a58f014 Compare September 14, 2024 05:25
@mergify mergify bot merged commit 8b037e7 into 3.12 Sep 14, 2024
52 checks passed
@mergify mergify bot deleted the mergify/bp/3.12/pr-8717 branch September 14, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport merge me Tell Mergify Bot to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants