9

我正在尝试分析一个具有一些依赖项的程序 Windingnumber。根据 Aleksander Dmitrov 在Profile Haskell 中的回答,没有为所有依赖项安装安装分析库,我正在使用 cabal-dev 来(尝试)构建启用分析的所有依赖项。我努力了

  • cabal-dev install --config=./cabal-dev.config,其中 cabal-dev.config 是

    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'

rm -rf cabal-dev当然,从原始环境开始。)在每种情况下,我得到:

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>

---即,未启用分析。我该如何启用它?

ETA 解决方案:将项目添加-prof到 .cabal 文件中的 ghc-options 中。显然在 cabal-dev 配置中设置 `executable-profiling: True" 并没有这样做。感谢 Daniel Fischer。

4

1 回答 1

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.

于 2013-01-01T19:15:15.240 回答