I’m looking into profiling a Haskell cabal project and I added the following lines to ghc-options
:
-threaded
-prof
-fprof-auto
"-with-rtsopts=-N -p -s -h -i0.1"
according to this tutorial this should work. But when I run the resulting resulting binary I get the following message:
<no location info>: 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.
I assume this is because of the way nixos builds GHC. Is there a way to not build GHC with the -dynamic
flag and allow profiling to work? I use external plugins so I can’t use -fexternal-interpreter
because this results in the following message:
<command line>: Plugins require -fno-external-interpreter
I’d rather not have to compile everything twice when I’m trying to optimize my code.