How does TH know to load non-profiled object code when compiling profiled?

Edward Z. Yang ezyang at
Fri Jan 8 05:21:39 UTC 2016


In fact, I have just realized that Template Haskell does something
very dodgy when it is loading profiled code: it will use the
*profiled* interface files (things that are used in splices
are brought into scope with import) to figure out what is going on with
the *non-profiled* object files.  I'm a bit surprised that we haven't
had any terrifying bugs related to this.  (It should be relatively
easy to trigger horrible brokenness; just compile hi and p_hi with
different code so that they are inconsistent.)


Excerpts from Simon Marlow's message of 2016-01-07 09:42:27 -0800:
> On 07/01/2016 16:28, Edward Z. Yang wrote:
> > I've been looking for the code that implements this logic, but I can't
> > seem to find it.  (For what it's worth, compiler plugins *incorrectly*
> > load the profiling interface when compiling profiled, which is wrong
> > and something I'd like to fix.)  Simon Marlow, do you happen to know?
> Yeah, I've been fiddling with this lately.  It's this function here: 
> Cheers,
> Simon

More information about the ghc-devs mailing list