Version 4 (modified by ezyang, 7 years ago) (diff)

mention BuildFlavour

Profiling GHC itself

If GHC itself is running too slowly, you can profile the compiler itself. The way to do this is to add


to your file. This is more robust than trying things like GhcStage2HcOpts += -prof because there are several things to do: first we build the ghc library, then we build the ghc program, linked against the library.

You can also use the prof BuildFlavor:

# Profile the stage2 compiler:
BuildFlavour = prof

Once you've done this, you should be able to run GHC (stage 2) to generate time and space profiles. For example:

$(TOP)/inplace/bin/ghc-stage2 +RTS -p -RTS

Note that this builds a profiled stage-2 compiler. In principle it's possible to build a profiled stage-1 compiler, but the build system isn't set up to do that right now. Notably, various libraries (eg Cabal) are built and installed by the bootstrap compiler before building GHC; these would need to be built and installed in a profiled way too.