Skip to content

Commit 8b037e7

Browse files
authored
Merge pull request #10350 from haskell/mergify/bp/3.12/pr-8717
Always pass `ghc-options` (backport #8717)
2 parents a3988a2 + a58f014 commit 8b037e7

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

Cabal/src/Distribution/Simple/GHC.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
689689
, ghcOptFPic = toFlag True
690690
, ghcOptHiSuffix = toFlag "dyn_hi"
691691
, ghcOptObjSuffix = toFlag "dyn_o"
692-
, ghcOptExtra = hcSharedOptions GHC libBi
692+
, ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi
693693
}
694694
profArgs =
695695
vanillaArgs
@@ -701,7 +701,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
701701
(withProfLibDetail lbi)
702702
, ghcOptHiSuffix = toFlag "p_hi"
703703
, ghcOptObjSuffix = toFlag "p_o"
704-
, ghcOptExtra = hcProfOptions GHC libBi
704+
, ghcOptExtra = hcOptions GHC libBi ++ hcProfOptions GHC libBi
705705
}
706706
ghcArgs
707707
| withVanillaLib lbi = vanillaArgs

Cabal/src/Distribution/Simple/GHCJS.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ buildOrReplLib mReplFlags verbosity numJobs _pkg_descr lbi lib clbi = do
569569
, ghcOptFPic = toFlag True
570570
, -- ghcOptHiSuffix = toFlag "dyn_hi",
571571
-- ghcOptObjSuffix = toFlag "dyn_o",
572-
ghcOptExtra = hcSharedOptions GHC libBi
572+
ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi
573573
, ghcOptHPCDir = hpcdir Hpc.Dyn
574574
}
575575

@@ -758,7 +758,7 @@ buildOrReplLib mReplFlags verbosity numJobs _pkg_descr lbi lib clbi = do
758758
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
759759
, ghcOptInputFiles = toNubListR dynamicObjectFiles
760760
, ghcOptOutputFile = toFlag sharedLibFilePath
761-
, ghcOptExtra = hcSharedOptions GHC libBi
761+
, ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi
762762
, -- For dynamic libs, Mac OS/X needs to know the install location
763763
-- at build time. This only applies to GHC < 7.8 - see the
764764
-- discussion in #1660.
@@ -1309,7 +1309,7 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
13091309
ghcOptFPic = toFlag True
13101310
, ghcOptHiSuffix = toFlag "dyn_hi"
13111311
, ghcOptObjSuffix = toFlag "dyn_o"
1312-
, ghcOptExtra = hcSharedOptions GHC bnfo
1312+
, ghcOptExtra = hcOptions GHC bnfo ++ hcSharedOptions GHC bnfo
13131313
, ghcOptHPCDir = hpcdir Hpc.Dyn
13141314
}
13151315
dynTooOpts =
@@ -1743,7 +1743,7 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do
17431743
, ghcOptFPic = toFlag True
17441744
, ghcOptHiSuffix = toFlag "js_dyn_hi"
17451745
, ghcOptObjSuffix = toFlag "js_dyn_o"
1746-
, ghcOptExtra = hcSharedOptions GHC libBi
1746+
, ghcOptExtra = hcOptions GHC libBi ++ hcSharedOptions GHC libBi
17471747
}
17481748
profArgs =
17491749
vanillaArgs

changelog.d/pr-8717

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
synopsis: Always pass `ghc-options` to GHC
2+
packages: Cabal
3+
prs: #8717
4+
issues:
5+
6+
description: {
7+
8+
Previously, options set in the package field `ghc-options` would not be passed
9+
to GHC during the link phase for shared objects (where multiple `.o` or
10+
`.dyn_o` files are merged into a single object file). This made it impossible
11+
to use `ghc-options` to use a different linker by setting (for example)
12+
`ghc-options: -optl-fuse-ld=mold -optlm-fuse-ld=mold`; the options would be
13+
dropped in the link phase, falling back to the default linker.
14+
15+
It was possible to work around this by duplicating the `ghc-options` to
16+
`ghc-shared-options`, which _are_ passed in the shared link phase, but that had
17+
the (undocumented and unfortunate) side-effect of disabling the GHC
18+
`-dynamic-too` flag, effectively doubling compilation times when
19+
`ghc-shared-options` are set.
20+
21+
Now, `ghc-options` are combined with `ghc-shared-options` (to accurately
22+
reflect the documentation on this feature) and the fact that
23+
`ghc-shared-options` disables `-dynamic-too` is documented.
24+
25+
}

0 commit comments

Comments
 (0)