9

I'm trying to profile a program windingnumber which has some few dependencies. Per Aleksander Dmitrov's answer in Profile Haskell without installing installing profiling libraries for all dependencies, I'm using cabal-dev to (attempt to) build all of the dependencies with profiling enabled. I have tried

  • cabal-dev install --config=./cabal-dev.config, where cabal-dev.config is

    library-profiling: True
    executable-profiling: True
    package-db: /home/christopher/school/senior/senior_thesis/windingnumber_integration/cabal-dev/packages-7.6.1.conf
    local-repo: /home/christopher/school/senior/senior_thesis/windingnumber_integration/cabal-dev/packages
    user-install: False
    remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
    remote-repo-cache: /home/christopher/.cabal/packages
    optimization: True
    build-summary: /home/christopher/school/senior/senior_thesis/windingnumber_integration/cabal-dev/logs/build.log
    remote-build-reporting: anonymous
    optimization: True
    
    install-dirs user
      prefix: /home/christopher/school/senior/senior_thesis/windingnumber_integration/cabal-dev/
    install-dirs global
    
  • cabal-dev install --cabal-install-arg='--enable-library-profiling' --cabal-install-arg='--enable-executable-profiling'

(with rm -rf cabal-dev in between, of course, to start from a pristine environment.) In each case, I get:

arch% cabal-dev/bin/windingnumber +RTS -p
cabal-dev/bin/windingnumber +RTS -p
windingnumber: the flag -p requires the program to be built with -prof
windingnumber: 
windingnumber: Usage: <prog> <args> [+RTS <rtsopts> | -RTS <args>] ... --RTS <args>
<snip>

---i.e., profiling is not enabled. How can I enable it?

ETA Solution: add -prof to ghc-options in the .cabal file for the project did it. Apparently setting `executable-profiling: True" in the cabal-dev config didn't do it. Thanks to Daniel Fischer.

Community
  • 1
  • 1
Christopher White
  • 185
  • 1
  • 1
  • 8

1 Answers1

4

It looks like cabal-dev rewrites ./cabal-dev/cabal.config every time it runs. However, you can edit ~/.cabal/share/cabal-dev-$VERSION/admin/cabal-config.in to set the default values:

$  vim ~/.cabal/share/cabal-dev-0.9.1/admin/cabal-config.in
# Set executable-profiling and library-profiling to True
$ cabal unpack ghc-core
$ cd ghc-core-0.5.6
$ cabal-dev install --dependencies-only
$ cabal-dev configure -p
$ cabal-dev build
$ ./dist/build/ghc-core/ghc-core +RTS -p
# much success

If you don't want to enable profiling for all projects managed with cabal-dev, use the --extra-config-file option (--config just sets the location of the auto-generated config file):

$ cat cabal-dev.config 
executable-profiling: True
library-profiling: True
$ cabal-dev --extra-config-file='./cabal-dev.config' install
$ ./cabal-dev/bin/ghc-core +RTS -p
# success

Using the ghc-options field in the .cabal file for enabling profiling is not recommended - you don't want everyone who installs your package from Hackage to build with profiling. Use cabal-dev configure -p --ghc-options="-fprof-auto" to enable profiling for the current build only.

Mikhail Glushenkov
  • 14,928
  • 3
  • 52
  • 65
  • Ah. That's good to know, though it doesn't solve my problem (I'm specifying an alternate config file with --config.) – Christopher White Jan 01 '13 at 19:43
  • @ChristopherWhite Apparently `--config` just sets the location of the cabal-dev's config file, which is auto-generated on each startup. You need to use `--extra-config-file` instead. I've updated my answer. – Mikhail Glushenkov Jan 01 '13 at 22:57
  • That explains things; I should have read the documentation more carefully. Sorry about that, and thank you. – Christopher White Jan 01 '13 at 23:35