Skip to content

Commit

Permalink
Merge branch 'master' into mergify-actions-upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Aug 19, 2024
2 parents c7ac80c + 9c775f2 commit 00e962f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Cabal/src/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
, ghcOptFPic = toFlag True
, ghcOptHiSuffix = toFlag "dyn_hi"
, ghcOptObjSuffix = toFlag "dyn_o"
, ghcOptExtra = hcSharedOptions GHC libBi
, ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi
}
profArgs =
vanillaArgs
Expand All @@ -746,7 +746,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
(withProfLibDetail lbi)
, ghcOptHiSuffix = toFlag "p_hi"
, ghcOptObjSuffix = toFlag "p_o"
, ghcOptExtra = hcProfOptions GHC libBi
, ghcOptExtra = hcOptions GHC libBi ++ hcProfOptions GHC libBi
}
profDynArgs =
vanillaArgs
Expand All @@ -760,7 +760,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
, ghcOptFPic = toFlag True
, ghcOptHiSuffix = toFlag "p_dyn_hi"
, ghcOptObjSuffix = toFlag "p_dyn_o"
, ghcOptExtra = hcProfSharedOptions GHC libBi
, ghcOptExtra = hcOptions GHC libBi ++ hcProfSharedOptions GHC libBi
}
ghcArgs =
let (libWays, _, _) = buildWays lbi
Expand Down
8 changes: 4 additions & 4 deletions Cabal/src/Distribution/Simple/GHCJS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ buildOrReplLib mReplFlags verbosity numJobs _pkg_descr lbi lib clbi = do
, ghcOptFPic = toFlag True
, -- ghcOptHiSuffix = toFlag "dyn_hi",
-- ghcOptObjSuffix = toFlag "dyn_o",
ghcOptExtra = hcSharedOptions GHC libBi
ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi
, ghcOptHPCDir = hpcdir Hpc.Dyn
}

Expand Down Expand Up @@ -772,7 +772,7 @@ buildOrReplLib mReplFlags verbosity numJobs _pkg_descr lbi lib clbi = do
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
, ghcOptInputFiles = toNubListR dynamicObjectFiles
, ghcOptOutputFile = toFlag sharedLibFilePath
, ghcOptExtra = hcSharedOptions GHC libBi
, ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi
, -- For dynamic libs, Mac OS/X needs to know the install location
-- at build time. This only applies to GHC < 7.8 - see the
-- discussion in #1660.
Expand Down Expand Up @@ -1330,7 +1330,7 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
ghcOptFPic = toFlag True
, ghcOptHiSuffix = toFlag "dyn_hi"
, ghcOptObjSuffix = toFlag "dyn_o"
, ghcOptExtra = hcSharedOptions GHC bnfo
, ghcOptExtra = hcOptions GHC bnfo ++ hcSharedOptions GHC bnfo
, ghcOptHPCDir = hpcdir Hpc.Dyn
}
dynTooOpts =
Expand Down Expand Up @@ -1781,7 +1781,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
, ghcOptFPic = toFlag True
, ghcOptHiSuffix = toFlag "js_dyn_hi"
, ghcOptObjSuffix = toFlag "js_dyn_o"
, ghcOptExtra = hcSharedOptions GHC libBi
, ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi
}
profArgs =
vanillaArgs
Expand Down
25 changes: 25 additions & 0 deletions changelog.d/pr-8717
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
synopsis: Always pass `ghc-options` to GHC
packages: Cabal
prs: #8717
issues:

description: {

Previously, options set in the package field `ghc-options` would not be passed
to GHC during the link phase for shared objects (where multiple `.o` or
`.dyn_o` files are merged into a single object file). This made it impossible
to use `ghc-options` to use a different linker by setting (for example)
`ghc-options: -optl-fuse-ld=mold -optlm-fuse-ld=mold`; the options would be
dropped in the link phase, falling back to the default linker.

It was possible to work around this by duplicating the `ghc-options` to
`ghc-shared-options`, which _are_ passed in the shared link phase, but that had
the (undocumented and unfortunate) side-effect of disabling the GHC
`-dynamic-too` flag, effectively doubling compilation times when
`ghc-shared-options` are set.

Now, `ghc-options` are combined with `ghc-shared-options` (to accurately
reflect the documentation on this feature) and the fact that
`ghc-shared-options` disables `-dynamic-too` is documented.

}
5 changes: 5 additions & 0 deletions doc/cabal-package-description-file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,11 @@ system-dependent values for these fields.
ones specified via :pkg-field:`ghc-options`, and are passed to GHC during
both the compile and link phases.

Note that if any :pkg-field:`ghc-shared-options` are set, the
``-dynamic-too` option will never be passed to GHC, leading to all modules
being compiled twice (once to generate the ``.o`` files and another to
generate the ``.dyn_o`` files).

.. pkg-field:: ghcjs-options: token list

Like :pkg-field:`ghc-options` but applies to GHCJS
Expand Down

0 comments on commit 00e962f

Please sign in to comment.