id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
2730,Quasiquote or TH linking may need HPC flag,simonpj,,"Test `quasiquotation/qq005` fails in the `hpc` way:
{{{
'/64playpen/simonpj/builds/HEAD-1/ghc/stage2-inplace/ghc' -fforce-recomp -dcore-lint -dcmm-lint -Dx86_64_unknown_linux  -dno-debug-output -c -o qq005 Main.hs -O -fhpc
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Loading package syb ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package packedstring-0.1.0.1 ... linking ... done.
Loading package containers-0.2.0.0 ... linking ... done.
Loading package pretty-1.0.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package parsec-2.1.0.1 ... linking ... done.
ghc: ./Expr.o: unknown symbol `hs_hpc_module'
}}}
I believe the reason is this:
 * `Expr.hs` contains a quasiquote parser
 * This parser is invoked in `Main.hs`
 * But `Expr.hs` is compiled with `-fhpc` and contains a reference to the RTS function `hs_hpc_module`
 * When doing dynamic linking of `Expr.o` (to run the quasiquote parser) the linker can't find `hs_hpc_module`.  (Even though `Main.hs` is also compiled with `-fhpc`.

The same thing happens with Template Haskell. (Try running the `th` tests with the `hpc` way.  Not all tests fail, but some do, with the same error.)

I'm no expert on the dynamic linking part. Is `hs_hpc_module` (defined in `rts/Hpc.c`) always part of the RTS?  Does it need to be added to a list I vaguely recall, of externally linkable symbols (perhaps `RTS_SYMBOLS` in `rts/Linker.c`) [PS: some comments explaining these lists would be v useful]?  Or what?

I'll milestone this for 6.10.1, because it does seem a bug that TH and HPC don't mix; but it should probably not hold up the release.

Simon",bug,closed,normal,6.10.2,Compiler,6.10.1,duplicate,,,Unknown/Multiple,Unknown/Multiple,,Unknown,,,,
