How do I tell stack to build my executable and all its dependencies with -prof?
Simply adding it to ghc-options in the
For stack build, stack bench and stack test you can just use stack build/bench/test --profile. You may have to stack clean first to get it to recompile with profiling.
For stack build you will still have to pass +RTS -p or whatever option you need (see GHC User Guide) when running the executable as in @Tomáš Janoušek answer.
You can also find more information in the debugging section of the stack user guide.