传递 +RTS 选项以使用 stack exec 运行程序

Cir*_*dec 5 haskell haskell-stack

如何将+RTS选项传递给使用 运行的程序stack exec

我已经添加-rtsoptsghc-options我的 cabal 文件中,并使用stack build. 如果我手动运行程序,普通和+RTS命令行参数都可以工作:

>.stack-work\dist\ca59d0ab\build\iterate-strict-exe\iterate-strict-exe.exe 25 +RTS -s
OK
   3,758,156,184 bytes allocated in the heap
         297,976 bytes copied during GC
         ...
Run Code Online (Sandbox Code Playgroud)

但是如果我stack exec只用普通选项运行它到达程序

>stack exec iterate-strict-exe -- 25 +RTS -s
OK
Run Code Online (Sandbox Code Playgroud)

其他不起作用的东西

如果我按照@epsilonhalbe 的建议调整参数的顺序,我会得到相同的结果。

>stack exec -- iterate-strict-exe 25 +RTS -s
OK
Run Code Online (Sandbox Code Playgroud)

似乎没有建议的--rts-options选项传递给stack exec.

>stack exec --rts-options "-s" -- iterate-strict-exe 25
Invalid option `--rts-options'

Usage: stack exec CMD [-- ARGS (e.g. stack ghc -- X.hs -o x)] ([--plain] |
                  [--[no-]ghc-package-path] [--[no-]stack-exe] [--package ARG])
                  [--help]
  Execute a command
Run Code Online (Sandbox Code Playgroud)

我正在使用stack版本1.1.2

>stack --version
Version 1.1.2, Git revision c6dac65e3174dea79df54ce6d56f3e98bc060ecc (3647 commits) x86_64 hpack-0.14.0
Run Code Online (Sandbox Code Playgroud)

stack upgrade到了之后也是一样1.4.0


将整个命令作为字符串传递(另一个建议)会导致找不到该名称的命令

>stack exec -- "iterate-strict-exe 25 +RTS -s"
Executable named iterate-strict-exe 25 +RTS -s not found on path: ...
Run Code Online (Sandbox Code Playgroud)

Rei*_*ton 4

看起来您在 Windows 上遇到了 GHC bug #13287(将在 8.2 中修复)。另请参阅堆栈问题20222640--RTS显然,解决方法是在之前添加--,例如

stack exec iterate-strict-exe --RTS -- 25 +RTS -s
Run Code Online (Sandbox Code Playgroud)