22
33# Debugging
44
5- To profile a component of the current project, simply pass the ` --profile `
6- flag to ` stack ` . The ` --profile ` flag turns on the ` --enable-library-profiling `
7- and ` --enable-executable-profiling ` Cabal options _ and_ passes the ` +RTS -p `
8- runtime options to any testsuites and benchmarks.
5+ To profile a component of the current project, pass the
6+ [ ` --profile ` flag] ( build_command.md#-profile-flag ) to ` stack build ` .
7+
8+ The flag:
9+
10+ * for project packages, turns on the Cabal flag
11+ [ ` --enable-profiling ` ] ( https://cabal.readthedocs.io/en/stable/setup-commands.html#cmdoption-runhaskell-Setup.hs-configure-enable-profiling ) ;
12+ * turns on the Cabal flag
13+ [ ` --enable-library-profiling ` ] ( https://cabal.readthedocs.io/en/stable/setup-commands.html#cmdoption-runhaskell-Setup.hs-configure-enable-library-profiling ) ; and
14+ * passes GHC's
15+ [ ` +RTS -p ` runtime options] ( https://downloads.haskell.org/ghc/latest/docs/users_guide/profiling.html#rts-flag--p )
16+ to any test suites and benchmarks.
917
1018For example the following command will build the ` my-tests ` testsuite with
1119profiling options and create a ` my-tests.prof ` file in the current directory
@@ -24,13 +32,29 @@ stack exec --profile -- my-exe +RTS -p
2432~~~
2533
2634For more fine-grained control of compilation options there are the
27- ` --library-profiling ` and ` --executable-profiling ` flags which will turn on the
28- ` --enable-library-profiling ` and ` --enable-executable-profiling ` Cabal
29- options respectively. Custom GHC options can be passed in with
30- ` --ghc-options "more options here" ` .
35+ [ ` --library-profiling ` flag] ( build_command.md#-no-library-profiling-flag ) and
36+ [ ` --executable-profiling ` flag] ( build_command.md#-no-executable-profiling-flag ) .
37+
38+ The ` --library-profiling ` flag:
39+
40+ * turns on the Cabal flag
41+ [ ` --enable-library-profiling ` ] ( https://cabal.readthedocs.io/en/stable/setup-commands.html#cmdoption-runhaskell-Setup.hs-configure-enable-library-profiling ) ; and
42+ * passes GHC's
43+ [ ` +RTS -p ` runtime options] ( https://downloads.haskell.org/ghc/latest/docs/users_guide/profiling.html#rts-flag--p )
44+ to any test suites and benchmarks.
45+
46+ The ` --executable-profiling ` flag:
47+
48+ * for project packages, turns on the Cabal flag
49+ [ ` --enable-profiling ` ] ( https://cabal.readthedocs.io/en/stable/setup-commands.html#cmdoption-runhaskell-Setup.hs-configure-enable-profiling ) ;
50+ * turns on the Cabal flag
51+ [ ` --enable-library-profiling ` ] ( https://cabal.readthedocs.io/en/stable/setup-commands.html#cmdoption-runhaskell-Setup.hs-configure-enable-library-profiling ) ; and
52+ * passes GHC's
53+ [ ` +RTS -p ` runtime options] ( https://downloads.haskell.org/ghc/latest/docs/users_guide/profiling.html#rts-flag--p )
54+ to any test suites and benchmarks.
3155
3256To enable compilation with profiling options by default you can add the
33- following snippet to your ` stack.yaml ` or ` ~/.stack/config.yaml ` :
57+ following to a project-level or global YAML configuration file :
3458
3559~~~ yaml
3660build :
0 commit comments