在最近对cabal进行了一些更改之后,我对如何分析可执行文件感到困惑。在~/.cabal/config
中,我启用了分析:
amy@wombat$ grep prof ~/.cabal/config
library-profiling: True
executable-profiling: True
但是,如果我尝试使用性能分析运行我的可执行文件,我会...
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>
如果我试图绕过阴谋,我会得到相同的回复:./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.
我认为我不应该添加这些标记,因为它们在我的配置文件中,但为了以防万一,我尝试一下:
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>
我错过了什么?
答案 0 :(得分:7)
问题是+RTS -p
位被解释为cabal
可执行文件本身的参数。要将这些参数转发到realtra-benchmark
可执行文件,请使用cabal run realtra-benchmark -- +RTS -p
。一般情况下,在使用cabal run
时(至少在修复this issue之前),您应该始终在要转发的参数前加一个双击。