After some of the recent-ish changes to cabal, I am totally confused as to how to profile an executable. In ~/.cabal/config
, I have profiling enabled:
amy@wombat$ grep prof ~/.cabal/config
library-profiling: True
executable-profiling: True
But if I try to run my executable with profiling, I get...
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>
I get the same response if I try to bypass cabal: ./dist/dist-sandbox-c8599c64/build/realtra-benchmark/realtra-benchmark +RTS -p
.
Of course, adding the -prof
flag to GHC-Options:
in my cabal file won't work:
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.
I figure I shouldn't have to add those flags since they're in my config file, but just in case, I try it:
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>
What am I missing?
cabal run realtra-benchmark +RTS -p -RTS
– Darlenedarline-RTS
flag is only needed when you're following with non-runtime flags. But just to make sure, I tried it just now with-RTS
at the end, and got the same error. – Aggrievedcabal run realtra-benchmark -- +RTS -p
. My guess is that+RTS
gets interpreted as argument to thecabal
executable itself. – Replaycabal run realtra-benchmark +RTS --RTS -- +RTS -p
. – Replay