Haskell 分析选项会导致构建错误“当使用 -dynamic 构建 GHC 时无法加载 -prof 对象”

问题描述 投票:0回答:1

我想对 Haskell 应用程序进行一些分析,因此在我的 hpack 中我添加了一些

ghc-options
:

  example-executable:
    source-dirs: src
    main: Main.hs
    ghc-options:
      - -O2
      - -prof
      - -fprof-auto
      - -rtsopts

导致此错误:

[ 6 of 19] Compiling Model.Server     ( src/Model/Server.hs, dist/build/discord-app-prof/discord-app-prof-tmp/Model/Server.o )
<no location info>: error:
    src/Model/Server.hs:125:13: fatal:
    Cannot load -prof objects when GHC is built with -dynamic
    To fix this, either:
      (1) Use -fexternal-interpreter, or
      (2) Build the program twice: once with -dynamic, and then
          with -prof using -osuf to set a different object file suffix.

这个

-dynamic
来自哪里?我不记得以前在分析时遇到过这个问题,这也很奇怪。当它说“GHC 是用 -dynamic 构建的”时,它也很令人困惑 - 当然 GHC 不是在这里构建的,而是 haskell 可执行文件?

我正在使用 GHC 9.0.2

haskell cabal nix
1个回答
0
投票

一个快速的解决方案是改变我的

default.nix

- myHaskellPackages.callCabal2nix "HaskellNixCabalStarter" (src) {}
+ myHaskellPackages.callCabal2nixWithOptions "HaskellNixCabalStarter" (src) "--enable-profiling" {}

正如这里提到的:如何在使用 Nix 的 callCabal2nix 时启用 Haskell 分析

© www.soinside.com 2019 - 2024. All rights reserved.