我有一个用 Haskell 编写的程序,打算用 GHC 编译。该程序在多核上的扩展性非常好,因此启用多线程非常重要。在我的 .cabal
文件中,我添加了 ghc-options: -O3 -threaded
以与线程运行时链接。问题在于,使用这种方法,用户需要使用 foo +RTS -N
运行程序,这似乎有点神秘,而且对用户不太友好。
如何告诉 cabal/ghc 对用户不可见地启用这些运行时标志?我读过--with-rtsopts
,但是当我尝试使用它时,GHC (7.0.3) 只是吐出unrecognized flag
。
最佳答案
标志是-with-rtsopts
,而不是--with-rtsopts
,所以应该加上-with-rtsopts=-N
到 ghc-options 字段。 GHC Flag Reference.
请注意,这还需要您通过将 -rtsopts
添加到 ghc-options 来链接运行时支持。
https://stackoverflow.com/questions/6505648/