From 7c4bf090c275c032a9805a1be03dc2fd5c6a06c5 Mon Sep 17 00:00:00 2001 From: Sebastian Graf Date: Wed, 24 Nov 2021 11:06:00 +0100 Subject: 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 --- hadrian/doc/flavours.md | 5 +++++ hadrian/src/Flavour.hs | 15 +++++++++++++++ 2 files changed, 20 insertions(+) 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: ipe Build the stage2 libraries with IPE debugging information for use with -hi profiling. + + collect_timings + Collects timings while building the stage2+ compiler by adding the + flags -ddump-to-file -ddump-timings. + ### 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 /hadrian.settings options -- cgit v1.2.1