Haskell Stack 的可执行文件分析和 ghc 选项无法构建

Haskell Stack's executable profiling and ghc options fails to build

我正在尝试调试 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 exec -- which ghc" 说了什么?如果您的 ghc 是全局安装的,则可能是它缺少分析库。如果是,"stack setup --no-system-ghc" + "stack build --no-system-ghc"

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