GHC API: Using runGhc twice or from multiple threads?

Simon Marlow marlowsd at gmail.com
Mon Jan 13 10:12:31 UTC 2014



On 07/01/2014 13:55, Benno Fünfstück wrote:
> Hello,
>
> is the following safe to do?
>
> main = do
>    runGhc libdir $ do ...
>    runGhc libdir $ do ...
>
> Or will this cause trouble? Is there state that is shared between the
> two calls?

The main restriction here is that you can only set the static flags 
once, because they depend on some global mutable state (the GLOBAL_VARs 
that Simon mentioned).

> And what about this one:
>
> main = do
>     forkIO $ runGhc libdir $ do ...
>     forkIO $ runGhc libdir $ do ...

The problem with this is the RTS linker, which is a single piece of 
shared global state.  We could actually fix that if it became important. 
  If you're not running interpreted code, this should be fine (apart 
from the static flags issue mentioned above).

Cheers,
	Simon


More information about the ghc-devs mailing list