Stack Build Error with "--profile" option

Hello, the command “stack build” succeeds, but “stack build --profile” fails. I have found many discussions on many pages in the internet about different ways to do it. But they seem to be not actual for modern stack version, I have tried them all. I would like to know how to fix this.

Stack version 2.7.5. Debian OS. Default interpreter for this version.

Typical Build Error:

Could not find module ‘Control.Concurrent’
base-compat > Perhaps you haven't installed the
profiling libraries for package ‘base-4.15.1.0’?

See haskell - Cannot profile a build with stack LTS 19.2 (GHC 9.0.2) - Stack Overflow.

1 Like

Use ghcup. It provides fixed bindists (at least for some platforms).

1 Like

You also need system-ghc: true, as pointed by ghcup installation procedure.

The time center-cost profiler is not available. Only heap profiler works.

Build with $ stack --resolver lts-18.28 build --profile --library-profiling --executable-profiling

The command $ stack exec – myapp-exe +RTS -p does not work.
Error:

the flag -p requires the program to be built with -prof

But, manually setting this flag into package.yaml does not allow to compile the program:

Perhaps you haven’t installed the “p_dyn” libraries for package ‘integer-wired-in’?

AFAIK you need a full build without profiling before running with prof.

1 Like