How to build profiled stage1?

Ömer Sinan Ağacan omeragacan at
Mon Jan 18 20:10:49 UTC 2016

I'm trying to debug my stage1 compiler and as a last resort I'm trying to build
stage1 compiler using `-prof -fprof-auto` to be able to do `+RTS -xc -RTS`
during the stage2 build.

I tried couple of things but they all failed in different ways.

As far as I understand, both SRC_HC_OPTS and GhcStage1HcOpts are passed to
system-wide installed ghc during the stage1 build and libraries. So I do one of
these changes:

    SRC_HC_OPTS        = -O -H64m -prof -fprof-auto
    GhcStage1HcOpts    = -O0 -DDEBUG -prof -fprof-auto

The second change I want to make is I want to pass `+RTS -xc -RTS` to
ghc-stage1, for that I'm making this change:

    GhcLibHcOpts       = -O -dcore-lint -prof -fprof-auto

But, no matter what else I change, I can't get past this stage:

    "/usr/local/bin/ghc" -hisuf hi -osuf  o -hcsuf hc -static  -O
-H64m  -Wall   -package-db libraries/bootstrapping.conf
-this-package-key ghc-8.1 -hide-all-packages -i -icompiler/basicTypes
-icompiler/cmm -icompiler/codeGen -icompiler/coreSyn
-icompiler/deSugar -icompiler/ghci -icompiler/hsSyn -icompiler/iface
-icompiler/llvmGen -icompiler/main -icompiler/nativeGen
-icompiler/parser -icompiler/prelude -icompiler/profiling
-icompiler/rename -icompiler/simplCore -icompiler/simplStg
-icompiler/specialise -icompiler/stgSyn -icompiler/stranal
-icompiler/typecheck -icompiler/types -icompiler/utils
-icompiler/vectorise -icompiler/stage1/build
-icompiler/stage1/build/autogen -Icompiler/stage1/build
-Icompiler/stage1/build/autogen -Icompiler/. -Icompiler/parser
-Icompiler/utils -Icompiler/stage1    -optP-include
-optPcompiler/stage1/build/autogen/cabal_macros.h -package-id
array- -package-id
base- -package-id
binary- -package-id
bytestring- -package-id
containers- -package-id
directory- -package-id
filepath- -package-id
ghc-boot-8.1 -package-id hoopl- -package-id hpc-
-package-id process-
-package-id template-haskell- -package-id
time- -package-id
transformers- -package-id
unix- -Wall
-fno-warn-name-shadowing -this-package-key ghc -XHaskell2010 -DSTAGE=1
-Rghc-timing -O0 -DDEBUG -prof -fprof-auto  -no-user-package-db
-rtsopts       -odir compiler/stage1/build -hidir
compiler/stage1/build -stubdir compiler/stage1/build    -c
compiler/utils/Exception.hs -o compiler/stage1/build/Exception.o

        Failed to load interface for ‘Control.Monad.IO.Class’
        Perhaps you haven't installed the profiling libraries for
package ‘transformers-’?
        Use -v to see a list of the files searched for.
    <<ghc: 24684488 bytes, 15 GCs, 1388900/2559496 avg/max bytes
residency (2 samples), 46M in use, 0.000 INIT (0.001 elapsed), 0.003
MUT (0.005 elapsed), 0.015 GC (0.019 elapsed) :ghc>>

I tried enabling library-profiling in my global Cabal config, but that didn't
help. Any ideas how to do this?

If it matters, I'm on Linux.

NOTE: If I pass -v to GHC, it lists this place in the list of
locations searched:


Indeed, the file is not there. When I look at all the command the build system
run at this point, I see lines like this:

    "/usr/local/bin/ghc-pkg" update --force
    Reading package info from
"libraries/transformers/dist-boot/inplace-pkg-config" ... done.
    transformers- Warning: Unrecognized field abi on line 47
    transformers- Warning: haddock-interfaces:
doesn't exist or isn't a file
    transformers- cannot find any of
    transformers- cannot find any of
    transformers- cannot find any of
    transformers- cannot find any of
    transformers- cannot find any of
    transformers- cannot find any of
    transformers- cannot find any of
    transformers- cannot find any of

Then, after a while it's building transformers in a different way, using
arguments like `-dep-makefile` etc. which are as far as I can see not
documented in the GHC man page. When I look libraries/transformers I only see a
directory named "dist-boot" with some weird files with ".haskell" extensions.
I'm quite confused about how this is supposed to work. Can any of the build
system experts help me here?

This wiki page
says "if you have built a profiling compiler ..." but it doesn't say
anything about
how to actually build it.


More information about the ghc-devs mailing list