summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-11-24 11:06:00 +0100
committerSebastian Graf <sebastian.graf@kit.edu>2021-11-24 19:12:15 +0100
commit7c4bf090c275c032a9805a1be03dc2fd5c6a06c5 (patch)
tree57cd1f1f9cd0ad63d202f82898712072438b79b4
parentc60652929ebd2510e52c05a2f61d52e2bf1846ad (diff)
downloadhaskell-wip/hadrian-collect_stats.tar.gz
hadrian: Add `collect_stats` flavour transformerwip/hadrian-collect_stats
This is useful for later consumption with https://gitlab.haskell.org/bgamari/ghc-utils/-/blob/master/ghc_timings.py
-rw-r--r--hadrian/doc/flavours.md5
-rw-r--r--hadrian/src/Flavour.hs15
2 files changed, 20 insertions, 0 deletions
diff --git a/hadrian/doc/flavours.md b/hadrian/doc/flavours.md
index b088b8ab92..b49ef5ddeb 100644
--- a/hadrian/doc/flavours.md
+++ b/hadrian/doc/flavours.md
@@ -240,6 +240,11 @@ The supported transformers are listed below:
<td><code>ipe</code></td>
<td>Build the stage2 libraries with IPE debugging information for use with -hi profiling.</td>
</tr>
+ <tr>
+ <td><code>collect_timings</code></td>
+ <td>Collects timings while building the stage2+ compiler by adding the
+ flags <code>-ddump-to-file -ddump-timings</code>.</td>
+ </tr>
</table>
### Static
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index 40cce02e51..f31e7667e1 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -46,6 +46,7 @@ flavourTransformers = M.fromList
, "omit_pragmas" =: omitPragmas
, "ipe" =: enableIPE
, "fully_static" =: fullyStatic
+ , "collect_timings" =: collectTimings
]
where (=:) = (,)
@@ -246,6 +247,20 @@ fullyStatic flavour =
, builder (Ghc LinkHs) ? pure [ "-optl", "-static" ]
]
+-- | Build stage2 dependencies with options to enable collection of compiler
+-- stats.
+collectTimings :: Flavour -> Flavour
+collectTimings =
+ -- Why both -ddump-timings *and* -v?
+ -- In contrast to -ddump-timings, -v will seq the whole CoreProgram and
+ -- produce less missleading information; otherwise, due to laziness some
+ -- allocations might be attributed to a subsequent pass instead of the pass
+ -- that has been causing the allocation. So we want -v.
+ -- On the other hand, -v doesn't work with -ddump-to-file, so we need
+ -- -ddump-timings.
+ addArgs $ notStage0 ? builder (Ghc CompileHs) ?
+ pure ["-ddump-to-file", "-ddump-timings", "-v"]
+
-- * CLI and <root>/hadrian.settings options