7

在对 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>

如果我尝试绕过 cabal,我会得到相同的响应:./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>

我错过了什么?

4

1 回答 1

7

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

于 2014-04-09T16:17:32.847 回答