'Cannot profile a build with stack LTS 19.2 (GHC 9.0.2)
I am trying to build a profilable executable with stack build --profile. stack build, stack test, and stack ghci all work correctly. (Full repo for reference)
I get many errors like the following:
StateVar > Could not find module ‘Prelude’
StateVar > Perhaps you haven't installed the profiling libraries for package ‘base-4.15.1.0’?
StateVar > Use -v (or `:set -v` in ghci) to see a list of the files searched for.
StateVar > |
StateVar > 72 | module Data.StateVar
This kind of makes sense to me - I'm using the GHC installed by stack, and when installing it didn't give me any indication that it was using profiling libraries.
> stack exec -- which ghc
/home/xavier/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc
I'm using lts-19.2.
Problems with this command seem to be relatively common in other questions, but usually the response is "stop using system GHC". Things I have tried that haven't worked:
- Reading the stack docs for
setup, but found no reference to profiling. - Reading the stack docs for
--profile, but finding no reference to system profiling libraries. stack cleanrm -Rf ~/.stack/programssudo apt install ghc-profand thenstack build --system-ghc --profile(on a lark ... would prefer to stick to stack managed GHC...)
Solution 1:[1]
Thanks to sjakobi in the comments, this issue is most likely caused by a packaging error in GHC 9.0.2 (and 9.2.2 by the looks of it).
Downgrading to lts-18.28 (GHC 8.10.7) fixed the issue and allowed me to profile.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Xavier Shay |
