Perhaps this is a documentation issue, but when I run something like cabal v2-bench --enable-profiling the benchmark runs, but produces no profiling output that I can see. If I run with cabal v2-run +RTS -p I get the the flag -p requires the program to be built with -prof error. Perhaps the bench and run executables are pointing at different things and perhaps the profiling output is buried somewhere, but the out of the box experience is suboptimal.
It's quite simple actually :-)
There's two ways of operation here: either you can operate in the non-stateful way, then you need to explicitly pass the --enable-profiling to every cabal command which is able to compute an install-plan, i.e.
cabal v2-run --enable-profiling exes -- +RTS -p
or you can persist those settings by invoking
cabal v2-configure --enable-profiling
which will merely create a file cabal.project.local with the single line
profiling: True
and then you don't need to explicitly pass --enable-profiling anymore via the CLI.
I hope this clears this up. Feel free to ask follow-up questions if something's still unclear.
Many thanks, Herbert. That makes sense. (It would be good if the cabal documentation made the basic conventions clear; they seem obvious once they are explained but the cabal manual doesn't do a great job of explaining the underlying concepts (eg, when to drive and persist through the command line and when to put things into the cabal file).
This doesn't work for me. I built with the following config:
library-profiling: True
profiling: True
package *
ghc-options: -O2 -threaded -fprof-auto "-with-rtsopts=-N -p -s -h -i0.1"
When running the executable with +RTS -p -RTS it errors out with the flag -p requires the program to be built with -prof. If you do what it says, you get the problems described in https://github.com/haskell/cabal/issues/2827
Edit: I'm using cabal v2-install and then run the exe directly.
Same issues as @hausfell; I'm building for Windows, and I've tried a few permutations of the ghc-options listed above without luck.
@Achierius did you try to run cabal v2-build instead and then manually copy the binary? I consider v2-install broken by now (for installing local packages), because it ignores project files, afais.
Most helpful comment
This doesn't work for me. I built with the following config:
When running the executable with
+RTS -p -RTSit errors out withthe flag -p requires the program to be built with -prof. If you do what it says, you get the problems described in https://github.com/haskell/cabal/issues/2827Edit: I'm using
cabal v2-installand then run the exe directly.