Multiple GHC sessions

Alan & Kim Zimmerman alan.zimm at gmail.com
Sun Jan 17 14:49:43 UTC 2016


At the moment there are issues with having multiple GHC API sessions
in a single executable, which boil down to GHC having global
variables.

A quick grep over the GHC sources shows the following instances

compiler/ghci/Linker.hs:90:GLOBAL_VAR_M(v_PersistentLinkerState, ...
compiler/ghci/Linker.hs:91:GLOBAL_VAR(v_InitLinkerDone, ....

compiler/main/StaticFlags.hs:94:GLOBAL_VAR(v_opt_C, ....
compiler/main/StaticFlags.hs:95:GLOBAL_VAR(v_opt_C_ready, ....

compiler/main/DynFlags.hs:4453:GLOBAL_VAR(v_unsafeGlobalDynFlags,....

ghc/GHCi/UI.hs:149:GLOBAL_VAR(macros_ref,....

Of these the v_unsafeGlobalDynFlags can probably be ignored, as they
are intended to be used in very specific, limited circumstances only.

So, would it be possible to create a structure housing the remaining
ones, and somehow make it possible to access these in some kind of
session? Or preferably get rid of them, or move them into existing
structures such as DynFlags.

This is an exploratory email, more to get a handle on what has been
done/considered already in this space.

The issue does have a major impact on tooling developers though.

Regards
  Alan


More information about the ghc-devs mailing list