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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Edward Z. Yang
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?

Edward
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

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

Simon Marlow-7
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:
https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler/ghci/Linker.hs;c78fedde7055490ca6f6210ada797190f3c35d87$520-539

Cheers,
Simon
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

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

Edward Z. Yang
Thanks!

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.)

Edward

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:
> https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler/ghci/Linker.hs;c78fedde7055490ca6f6210ada797190f3c35d87$520-539
>
> Cheers,
> Simon
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

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

Simon Marlow-7
Correct, it's entirely dodgy.  (I seem to remember a Note about this
somewhere, but I can't find it right now)

In any case, -fexternal-interpreter fixes this properly.

Cheers,
Simon

On 08/01/2016 05:21, Edward Z. Yang wrote:

> Thanks!
>
> 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.)
>
> Edward
>
> 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:
>> https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler/ghci/Linker.hs;c78fedde7055490ca6f6210ada797190f3c35d87$520-539
>>
>> Cheers,
>> Simon
_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs