Profiling the executable with cabal

After some recent changes in cabal, I am completely confused about how to profile the executable. In ~/.cabal/config , I have profiling:

 amy@wombat $ grep prof ~/.cabal/config library-profiling: True executable-profiling: True 

But if I try to run my profiled executable, 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 answer if I try to get around cabal: ./dist/dist-sandbox-c8599c64/build/realtra-benchmark/realtra-benchmark +RTS -p .

Of course, adding the -prof flag to GHC-Options: in my cache file will not 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 believe that I do not need to add these flags, as they are in my configuration file, but just in case, I will try:

 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?

+6
source share
1 answer

The problem is that the +RTS -p bit is interpreted as an argument to the cabal executable cabal . To redirect these arguments to the realtra-benchmark executable, use cabal run realtra-benchmark -- +RTS -p . In general, you should always put a double dash in front of the arguments you want to forward when using cabal run (at least until this problem has been fixed).

+7
source

All Articles