GHC head: cannot build a program with -O2 and -prof options
Summary
I am trying to build a small program with profiling using a ghc built from haskell gitlab master branch. It builds fine with -O2 and -fprof-auto separately, but does not build if both the options are used together.
Steps to reproduce
$ git clone https://github.com/composewell/streamly-ghc9-regression.git
$ cd streamly-ghc9-regression
$ ghc-stage2 --make -O2 -prof -fprof-auto Main.hs
Loaded package environment from /home/harendra/composewell/streamly-ghc9-regression/.ghc.environment.x86_64-linux-9.3.20210510
[ 1 of 12] Compiling Fold ( Fold.hs, Fold.o ) [flags changed]
[ 2 of 12] Compiling Step ( Step.hs, Step.o ) [flags changed]
[ 3 of 12] Compiling StreamK ( StreamK.hs, StreamK.o ) [flags changed]
[ 4 of 12] Compiling Unfold ( Unfold.hs, Unfold.o ) [flags changed]
[ 5 of 12] Compiling StreamD ( StreamD.hs, StreamD.o ) [flags changed]
[ 6 of 12] Compiling Serial ( Serial.hs, Serial.o ) [flags changed]
[ 7 of 12] Compiling MArray ( MArray.hs, MArray.o ) [flags changed]
[ 8 of 12] Compiling Array ( Array.hs, Array.o ) [flags changed]
[ 9 of 12] Compiling Ring ( Ring.hs, Ring.o ) [flags changed]
[10 of 12] Compiling Operations ( Operations.hs, Operations.o ) [flags changed]
[11 of 12] Compiling Handle ( Handle.hs, Handle.o ) [flags changed]
[12 of 12] Compiling Main ( Main.hs, Main.o ) [flags changed]
Linking Main ...
./StreamD.o(.text+0x1b9f2): error: undefined reference to 'StreamK_mkStreamFromStream_HPC_cc'
./MArray.o(.text+0xbe83): error: undefined reference to 'StreamK_mkStreamFromStream_HPC_cc'
Main.o(.text+0x6fdb): error: undefined reference to 'StreamK_mkStreamFromStream_HPC_cc'
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
The same command works for ghc-8.
Expected behavior
GHC should be able to compile the program using the CLI options described above.
Environment
- GHC version used: ghc-9.3+!5658 (closed)