使用cabal分析可执行文件

mhw*_*bat 6 haskell cabal-install

在最近对cabal进行了一些更改之后,我对如何分析可执行文件感到困惑.在~/.cabal/config,我启用了性能分析:

amy@wombat$ grep prof ~/.cabal/config
library-profiling: True
executable-profiling: True
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试使用性能分析运行我的可执行文件,我会...

amy@wombat$ cabal run realtra-benchmark +RTS -p
cabal: the flag -p requires the program to be built with -prof
cabal: 
cabal: Usage: <prog> <args> [+RTS <rtsopts> | -RTS <args>] ... --RTS <args>
<snip>
Run Code Online (Sandbox Code Playgroud)

如果我试图绕过阴谋,我得到同样的回应:./dist/dist-sandbox-c8599c64/build/realtra-benchmark/realtra-benchmark +RTS -p.

当然,在我的cabal文件中添加-prof标志GHC-Options:将不起作用:

amy@wombat$ cabal build --ghc-options=-Werror && cabal test && cabal install
./realtra.cabal has been changed. Re-configuring with most recently used
options. If this fails, please run configure manually.
Resolving dependencies...
Configuring creatur-realtra-1.0.8...
Warning: 'ghc-options: -prof' is not necessary and will lead to problems when
used on a library. Use the configure flag --enable-library-profiling and/or
--enable-executable-profiling.
Run Code Online (Sandbox Code Playgroud)

我想我不应该添加这些标志,因为它们在我的配置文件中,但为了以防万一,我尝试一下:

amy@wombat$ cabal configure --enable-executable-profiling --enable-library-profiling
Resolving dependencies...
Configuring creatur-realtra-1.0.8...
amy@wombat$ cabal build --ghc-options=-Werror && cabal test && cabal install
<snip>
amy@wombat$ cabal run realtra-benchmark +RTS -p
cabal: the flag -p requires the program to be built with -prof
cabal: 
cabal: Usage: <prog> <args> [+RTS <rtsopts> | -RTS <args>] ... --RTS <args>
<snip>
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

Mik*_*kov 7

问题是该+RTS -p位被解释为cabal可执行文件本身的参数.要将这些参数转发给realtra-benchmark可执行文件,请使用cabal run realtra-benchmark -- +RTS -p.通常,在使用时要始终在要转发的参数之前放置一个双破折号cabal run(至少在修复此问题之前).