summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-11-11 15:05:20 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-22 12:39:38 -0500
commitd4d95e51a463e539fceb1c6f191e84adaa337e3b (patch)
tree691cf2ebf8cbc3d7bf84633fa9117afa8127cca0 /hadrian
parent179d0becd2ddfa216f7b221df9fc520a352fdbe7 (diff)
downloadhaskell-d4d95e51a463e539fceb1c6f191e84adaa337e3b.tar.gz
hadrian: Add profiled_ghc and no_dynamic_ghc modifiers
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/doc/flavours.md13
-rw-r--r--hadrian/src/Flavour.hs14
2 files changed, 27 insertions, 0 deletions
diff --git a/hadrian/doc/flavours.md b/hadrian/doc/flavours.md
index 254f2e0666..f10b698b58 100644
--- a/hadrian/doc/flavours.md
+++ b/hadrian/doc/flavours.md
@@ -220,6 +220,19 @@ The supported transformers are listed below:
<td><code>llvm</code></td>
<td>Use GHC's LLVM backend (`-fllvm`) for all stage1+ compilation.</td>
</tr>
+ <tr>
+ <td><code>profiled_ghc</code></td>
+ <td>Build the GHC executable with cost-centre profiling support.
+ It is that you use this in conjunction with `no_dynamic_ghc` since
+ GHC does not It is support loading of profiled libraries with the
+ dynamically-linker.</td>
+ </tr>
+ <tr>
+ <td><code>no_dynamic_ghc</code></td>
+ <td>Linked GHC against the statically-linked RTS. This causes GHC to
+ default to loading static rather than dynamic library when,
+ e.g., loading libraries during TemplateHaskell evaluations.</td>
+ </tr>
</table>
## Ways
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index 6c68df21ff..a7a32ed634 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -9,6 +9,8 @@ module Flavour
, enableThreadSanitizer
, enableDebugInfo, enableTickyGhc
, viaLlvmBackend
+ , enableProfiledGhc
+ , disableDynamicGhcPrograms
) where
import Expression
@@ -86,6 +88,8 @@ flavourTransformers = M.fromList
, "split_sections" =: splitSections
, "thread_sanitizer" =: enableThreadSanitizer
, "llvm" =: viaLlvmBackend
+ , "profiled_ghc" =: enableProfiledGhc
+ , "no_dynamic_ghc" =: disableDynamicGhcPrograms
]
where (=:) = (,)
@@ -197,3 +201,13 @@ enableThreadSanitizer = addArgs $ mconcat
-- | Use the LLVM backend in stages 1 and later.
viaLlvmBackend :: Flavour -> Flavour
viaLlvmBackend = addArgs $ notStage0 ? builder Ghc ? arg "-fllvm"
+
+-- | Build the GHC executable with profiling enabled. It is also recommended
+-- that you use this with @'dynamicGhcPrograms' = False@ since GHC does not
+-- support loading of profiled libraries with the dynamically-linker.
+enableProfiledGhc :: Flavour -> Flavour
+enableProfiledGhc flavour = flavour { ghcProfiled = True }
+
+-- | Disable 'dynamicGhcPrograms'.
+disableDynamicGhcPrograms :: Flavour -> Flavour
+disableDynamicGhcPrograms flavour = flavour { dynamicGhcPrograms = pure False }