foreign import from RTS into GHC source

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

foreign import from RTS into GHC source

Nicolas Frisby
I'm adding a foreign import in a GHC module from the RTS. I'm using a CPP
directive to avoid the import in the stage1 compiler, since the RTS
function I need doesn't necessarily exist in that version of the RTS.

> #if STAGE < 2
>   ? -- make do without the import
> #else
>   ? -- do the import and use it
> #endif

Do you have any criticism of this overall design?

EG Is there a preference to use Config.cStage instead of CPP and the STAGE
symbol?

Thanks.

P.S. ? for some context, this is for Solution 1 at
http://ghc.haskell.org/trac/ghc/wiki/Plugins/ReinitializeGlobals
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20130710/69723185/attachment.htm>

Reply | Threaded
Open this post in threaded view
|

foreign import from RTS into GHC source

Ian Lynagh-2
On Wed, Jul 10, 2013 at 04:26:23PM -0500, Nicolas Frisby wrote:
> I'm adding a foreign import in a GHC module from the RTS. I'm using a CPP
> directive to avoid the import in the stage1 compiler, since the RTS
> function I need doesn't necessarily exist in that version of the RTS.
>
> EG Is there a preference to use Config.cStage instead of CPP and the STAGE
> symbol?

It's always better to not use CPP if possible, but in this instance
you'd presumably get a missing-symbol error, so CPP is necessary.


Thanks
Ian
--
Ian Lynagh, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com/