haskellcabalcabal-install

Problem installing haskell profiling libraries with cabal


I have a cabal project and I'm trying to compile it with profiling turned on. I'm following the instructions here but cabal build fails with the following error:

app/WordMap.hs:5:1: error:
    Could not find module ‘Data.HashMap.Strict’
    Perhaps you haven't installed the profiling libraries for package ‘unordered-containers-0.2.19.1’?
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
5 | import qualified Data.HashMap.Strict as HashMap
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The only change I made to cause this was to add the -prof and -fprof-auto to the ghc-options in the .cabal file. It compiles fine without those options.

I'm using GHC version 9.2.4 and cabal version 3.6.2.0.

I've tried running cabal install unordered-containers --enable-profiling --lib --reinstall (and various derivatives to that) but it doesn't seem to work. The command completes fine but doesn't change the output of cabal build.

I've also tried rm'ing the package from the cabal store, and then installing the package again with profiling. Still doesn't work.


Solution

  • Found a way forward. I needed to remove the -prof and -fprof-auto from the .cabal ghc-options, and then just run cabal v2-run <project> --enable-profiling -- +RTS -p.

    More info in the cabal docs.