如何在cabal-dev安装中启用分析?

Chr*_*ite 9 profiling haskell cabal

我正试图描述一个程序的数字,它有一些依赖性.Per 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
    
    Run Code Online (Sandbox Code Playgroud)
  • 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>
Run Code Online (Sandbox Code Playgroud)

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

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

Mik*_*kov 4

看起来每次运行都会cabal-dev重写。./cabal-dev/cabal.config但是,您可以编辑~/.cabal/share/cabal-dev-$VERSION/admin/cabal-config.in以设置默认值:

$  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
Run Code Online (Sandbox Code Playgroud)

如果您不想对使用 管理的所有项目启用分析cabal-dev,请使用该--extra-config-file选项(--config仅设置自动生成的配置文件的位置):

$ 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
Run Code Online (Sandbox Code Playgroud)

不建议使用ghc-options.cabal 文件中的字段来启用分析 - 您不希望每个从 Hackage 安装您的软件包的人都使用分析进行构建。用于cabal-dev configure -p --ghc-options="-fprof-auto"仅对当前版本启用分析。