I used
stack bench --profile --ba +RTS -hy -l
and this reported the error:
stack: the flag -hy requires the program to be built with -prof
I am confused by this as I thought stack bench --profile does build with -prof
I had no problem with
stack bench --profile --ba +RTS -hc -l
presumably because that does not require a build with -prof
Can anyone tell me what I am missing here?
(I am using Stack Version 3.1.1)
1 Like
Looks like you are passing the +RTS
options to the stack
executable itself, rather than to the executable you are trying to profile. Try using --
to separate arguments to stack
from arguments to the profiled executable. (I’m not a Stack user, so I’m not completely sure that works for stack bench
, but if it doesn’t you should be able to use stack exec
which does.)
2 Likes
Many thanks.
This worked as expected
stack bench --profile --ba ‘+RTS -hy -l’
I think you have found a gap in Stack’s online documentation.
The stack
executable is built by GHC with option -rtsopts
, equivalent to -rtsopts=some
. (That is not yet documented.) That means that the RTS extracts the command-line arguments bracketed between +RTS
and -RTS
as its own, as described here: 5.7. Runtime system (RTS) options — Glasgow Haskell Compiler 9.10.1 User's Guide.
As you have found, quoting the argument to --ba
stops the RTS from taking +RTS -hy -l
for itself.
EDIT: Stack’s documentation is now updated: Commands - The Haskell Tool Stack
3 Likes