How to get stacktraces with stack and GHCI?

Viewed 364

With

stack ghci --profile --ghci-options '+RTS -xc -RTS'

I get:

ghc: the flag -xc requires the program to be built with -prof

Which program is not built with -prof and why?

1 Answers
stack ghci --profile app --ghci-options "-fexternal-interpreter -prof"

The above seems to work for me (does take a few seconds to start). I had to add the following to my stack.yaml:

build:
  library-profiling: true
  executable-profiling: true

More informotation: https://github.com/commercialhaskell/stack/blob/master/doc/GUIDE.md#debugging http://simonmar.github.io/posts/2016-02-12-Stack-traces-in-GHCi.html

I may have actually run some additional commands, possibly stack build --enable-library-profiling.

Related