How to build profiled stage1?

Ömer Sinan Ağacan omeragacan at gmail.com
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-0.5.1.0-960bf9ae8875cc30355e086f8853a049 -package-id
base-4.8.2.0-0d6d1084fbc041e1cded9228e80e264d -package-id
binary-0.8.0.0 -package-id
bytestring-0.10.6.0-9a873bcf33d6ce2fd2698ce69e2c1c66 -package-id
containers-0.5.6.2-59326c33e30ec8f6afd574cbac625bbb -package-id
directory-1.2.2.0-660a7a83a753ed85c8a374c15dae2b97 -package-id
filepath-1.4.0.0-f97d1e4aebfd7a03be6980454fe31d6e -package-id
ghc-boot-8.1 -package-id hoopl-3.10.2.1 -package-id hpc-0.6.0.3
-package-id process-1.2.3.0-a22328103774f0499a990653944cbf99
-package-id template-haskell-2.11.0.0 -package-id
time-1.5.0.1-1b9a502bb07a3e6f4d6935fbf9db7181 -package-id
transformers-0.5.0.0 -package-id
unix-2.7.1.0-bb54ee8f9f6b2600aae7a748eb88a610 -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

    compiler/utils/Exception.hs:10:1:
        Failed to load interface for ‘Control.Monad.IO.Class’
        Perhaps you haven't installed the profiling libraries for
package ‘transformers-0.5.0.0’?
        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:

    /home/omer/haskell/ghc_unboxed_sums/libraries/transformers/dist-boot/build/Control/Monad/IO/Class.p_hi

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
--package-db=libraries/bootstrapping.conf
libraries/transformers/dist-boot/inplace-pkg-config
    Reading package info from
"libraries/transformers/dist-boot/inplace-pkg-config" ... done.
    transformers-0.5.0.0: Warning: Unrecognized field abi on line 47
    transformers-0.5.0.0: Warning: haddock-interfaces:
/home/omer/haskell/ghc_unboxed_sums/libraries/transformers/dist-boot/doc/html/transformers/transformers.haddock
doesn't exist or isn't a file
    transformers-0.5.0.0: cannot find any of
["Control/Applicative/Backwards.hi","Control/Applicative/Backwards.p_hi","Control/Applicative/Backwards.dyn_hi"]
(ignoring)
    transformers-0.5.0.0: cannot find any of
["Control/Applicative/Lift.hi","Control/Applicative/Lift.p_hi","Control/Applicative/Lift.dyn_hi"]
(ignoring)
    transformers-0.5.0.0: cannot find any of
["Control/Monad/Signatures.hi","Control/Monad/Signatures.p_hi","Control/Monad/Signatures.dyn_hi"]
(ignoring)
    transformers-0.5.0.0: cannot find any of
["Control/Monad/Trans/Class.hi","Control/Monad/Trans/Class.p_hi","Control/Monad/Trans/Class.dyn_hi"]
(ignoring)
    transformers-0.5.0.0: cannot find any of
["Control/Monad/Trans/Cont.hi","Control/Monad/Trans/Cont.p_hi","Control/Monad/Trans/Cont.dyn_hi"]
(ignoring)
    transformers-0.5.0.0: cannot find any of
["Control/Monad/Trans/Except.hi","Control/Monad/Trans/Except.p_hi","Control/Monad/Trans/Except.dyn_hi"]
(ignoring)
    transformers-0.5.0.0: cannot find any of
["Control/Monad/Trans/Error.hi","Control/Monad/Trans/Error.p_hi","Control/Monad/Trans/Error.dyn_hi"]
(ignoring)
    transformers-0.5.0.0: cannot find any of
["Control/Monad/Trans/Identity.hi","Control/Monad/Trans/Identity.p_hi","Control/Monad/Trans/Identity.dyn_hi"]
(ignoring)

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
https://ghc.haskell.org/trac/ghc/wiki/Debugging/Compiler#Addingdebuggingcodetothecompiler
says "if you have built a profiling compiler ..." but it doesn't say
anything about
how to actually build it.

Thanks.


More information about the ghc-devs mailing list