Compile errors when compiling with performance flags

I’m trying to investigate the performance of a project and am following the guide here. I added -prof -fprof-auto to the GHC flags in the Cabal file and tried building. I get these strange errors:

src/TinyAPL/Complex.hs:3:8: error: [GHC-47808]
    Failed to load dynamic interface file for Prelude:
      Exception when reading interface file  /home/rubenverg/.ghcup/ghc/9.10.1/lib/ghc-9.10.1/lib/../lib/x86_64-linux-ghc-9.10.1/base-4.20.0.0-4014/Prelude.p_dyn_hi
        /home/rubenverg/.ghcup/ghc/9.10.1/lib/ghc-9.10.1/lib/../lib/x86_64-linux-ghc-9.10.1/base-4.20.0.0-4014/Prelude.p_dyn_hi: withBinaryFile: does not exist (No such file or directory)

and the same for many more modules, both from base and from other libraries. Looking in that directory, there are .hi, .dyn_hi and .p_hi files but no .p_dyn_hi. What am I doing wrong? If the rest of the Cabal file matters, it’s here.

I believe that is because the libraries that you are implicitly depending on, via cabal, have not been compiled with profiling enabled. I believe the guide you are referencing only applies when invoking ghc directly. If you’re using cabal you should set the profiling flags in cabal.project.local elsewhere in the .cabal file. [EDIT: thanks @jaror]

Perhaps start here: 5.1. Quickstart — Cabal 3.4.0.0 User's Guide

The profiling options should go into cabal.project.local.

1 Like

Thanks, this worked. Now to figure out what numbers are relevant for my program(:

1 Like