GHC API: Using runGhc twice or from multiple threads?

Simon Peyton Jones simonpj at microsoft.com
Wed Jan 8 08:42:22 UTC 2014


Benno

I think that both ought to be ok, but I'd welcome other input.

GHC.runGHC calls initGhcMonad, which allocates an entirely new session (in newHscEnv).   So the two will work entirely independently.

Unfortunately that's not 100% true. If you search for GLOBAL_VAR you'll see a handful of disgusting global state variables, and they *will* be shared between GHC sessions.

There really aren't many.  I'd love someone to eliminate them!  (NB ghc-devs)

Simon

From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Benno Fünfstück
Sent: 07 January 2014 13:56
To: ghc-devs
Subject: GHC API: Using runGhc twice or from multiple threads?

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?

And what about this one:

main = do
   forkIO $ runGhc libdir $ do ...
   forkIO $ runGhc libdir $ do ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140108/c893ba4e/attachment.html>


More information about the ghc-devs mailing list