我正在尝试配置一个程序windingnumber,它有一些依赖关系。根据Aleksander Dmitrov在Profile Haskell中的回答,我使用cabal-dev来(尝试)在启用了分析的情况下构建所有依赖。我试过了
-
cabal-dev install --config=./cabal-dev.config
,其中cabal-dev。配置是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配置中设置"executableprofiling: True"并没有做到这一点。感谢Daniel Fischer
看起来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
如果您不想为所有使用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
不建议使用.cabal文件中的ghc-options
字段来启用分析—您不希望每个从Hackage安装您的包的人都使用分析构建。使用cabal-dev configure -p --ghc-options="-fprof-auto"
只启用当前构建的分析