【问题标题】:Haskell Stack's executable profiling and ghc options fails to buildHaskell Stack 的可执行分析和 ghc 选项无法构建
【发布时间】:2016-07-15 20:52:06
【问题描述】:

我正在尝试调试 Haskell 项目中的性能问题,但我无法在其中编译分析,因此我可以通过 +RTS -p 命令行参数使用它。

我的.cabal 文件中的 GHC 选项是:

ghc-options:         -threaded -rtsopts -with-rtsopts=-N -Wall -Werror

我正在尝试构建它:

stack build --executable-profiling --library-profiling --ghc-options="-fprof-auto -rtsopts"

结果:

While constructing the BuildPlan the following exceptions were encountered:

--  Failure when adding dependencies:    
      base: needed (>=2 && <5), not present in build plan (latest applicable is 4.9.0.0)
      mtl: needed (>=2.1 && <2.3), couldn't resolve its dependencies
      random: needed (-any), couldn't resolve its dependencies
      transformers: needed (>=0.3 && <0.6), couldn't resolve its dependencies
      transformers-compat: needed (>=0.4 && <0.6), couldn't resolve its dependencies
    needed for package: MonadRandom-0.4.2.3

--  Failure when adding dependencies:    
      base: needed (>=4 && <5), not present in build plan (latest applicable is 4.9.0.0)
      stm: needed (>=2.0 && <2.5), couldn't resolve its dependencies
      transformers: needed (>=0.2 && <0.6), couldn't resolve its dependencies
    needed for package: StateVar-1.1.0.4
<snipped large log>

即使只尝试 stack build --executable-profiling 也会导致相同的错误。

作为参考,我的库依赖项是:

   build-depends:       base >= 4.7 && < 5
                     , aeson
                     , servant
                     , servant-server 
                     , wai
                     , warp
                     , either
                     , bytestring
                     , transformers
                     , postgresql-simple
                     , amazonka
                     , amazonka-sqs
                     , lens
                     , text
                     , time
                     , resource-pool

我该如何解决这个问题,以便我可以使用堆栈编译我的项目并内置分析以与+RTS -p 一起使用?

【问题讨论】:

  • 在较新的堆栈版本中,您也可以只调用 stack build --profile 作为所有其他标志的快捷方式。
  • 更多信息请见this example

标签: haskell haskell-stack


【解决方案1】:

“stack exec -- which ghc”是怎么说的?如果您的 ghc 是全局安装的,则可能是它缺少分析库。如果是这样,“堆栈设置--no-system-ghc”+“堆栈构建--no-system-ghc”

您的 stack.yaml 配置是什么?如果您设置了“ghc-*”的解析器,除非您在“extra-deps”中指定所有依赖项的版本,否则它将无法工作。通常你会想要使用堆栈快照 - https://www.stackage.org/

【讨论】:

  • stack exec -- which ghc 说 /usr/bin/ghc。我的 stack.yml 只有 lts-5.17 用于解析器。我现在正在尝试stack build --executable-profiling --library-profiling --ghc-options="-fprof-auto -rtsopts" --no-system-ghc。我应该从系统中删除 ghc 吗?
  • 我将-threaded -rtsopts -with-rtsopts=-N -eventlog -prof 添加到我的.cabal 中的ghc-options,然后运行-threaded -rtsopts -with-rtsopts=-N -eventlog -prof。我现在可以从我的应用程序中获取分析信息并使用+RTS -p 运行。感谢您的帮助!
猜你喜欢
  • 2023-03-29
  • 2016-07-08
  • 1970-01-01
  • 1970-01-01
  • 2018-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多