Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 clean
  • rm -Rf ~/.stack/programs
  • sudo apt install ghc-prof and then stack build --system-ghc --profile (on a lark ... would prefer to stick to stack managed GHC...)
like image 237
Xavier Shay Avatar asked Oct 26 '25 13:10

Xavier Shay


1 Answers

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.

like image 188
Xavier Shay Avatar answered Oct 29 '25 20:10

Xavier Shay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!