diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2021-11-24 11:06:00 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-25 05:03:51 -0500 |
commit | bd92c9b207143532827008ec2ea1be55f30843cb (patch) | |
tree | 165e26071e32fd554ab9c1074d5eead739e4ee4f | |
parent | cafb1f999401df00941193b004074f258d2af480 (diff) | |
download | haskell-bd92c9b207143532827008ec2ea1be55f30843cb.tar.gz |
hadrian: Add `collect_stats` flavour transformer
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.md | 5 | ||||
-rw-r--r-- | hadrian/src/Flavour.hs | 15 |
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 |