Forgot to add that my current workaround is to compile with "-static -package-env=-" i.e.

ghc  -static -package-env=- -prof -fprof-auto  hello.hs 

Adding  just  -package-env=- i.e. gives me the same error as compiling without it. 

 ghc   -package-env=- -prof -fprof-auto  hello.hs
[1 of 2] Compiling Main             ( hello.hs, hello.o )

hello.hs:1:1: error:
    Could not find module ‘Prelude’
    Perhaps you haven't installed the "p_dyn" libraries for package ‘base-4.18.0.0’?
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
1 |
  | ^

Adding just -static gives 

 ghc   -static -prof -fprof-auto  hello.hs
Loaded package environment from /Users/gcolpitts/.ghc/x86_64-darwin-9.6.1/environments/default
[1 of 2] Compiling Main             ( hello.hs, hello.o ) [Missing object file]
[2 of 2] Linking hello
ld: warning: directory not found for option '-L/opt/local/lib/'
ld: library not found for -lHStxmth-0.12.7.1-f954854b_p
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ghc-9.6.1: `gcc' failed in phase `Linker'. (Exit code: 1)

I can't find any doc saying that -static is required for profiling on the Mac but perhaps that is the case?


On Sun, May 14, 2023 at 3:43 PM George Colpitts <george.colpitts@gmail.com> wrote:
Is anybody on 9.6.1 having problems profiling on a Mac? As I reported in https://gitlab.haskell.org/ghc/ghc/-/issues/23211 

ghc -prof -fprof-auto hello.hs

where the file hello.hs consists of the line: 

main = print "hello"

gets the error:

Could not find module ‘Prelude’
 Perhaps you haven't installed the "p_dyn" libraries for package ‘base-4.18.0.0’?

It seems to me like a regression of the closed bug https://gitlab.haskell.org/ghc/ghc/-/issues/20707

Thanks
George