diff options
author | Max Bolingbroke <batterseapower@hotmail.com> | 2011-07-29 12:05:46 +0100 |
---|---|---|
committer | Max Bolingbroke <batterseapower@hotmail.com> | 2011-07-29 12:54:23 +0100 |
commit | 0e765db44229aed591f9f423ef909b5f76696de0 (patch) | |
tree | ea3dfabe0073b43f476864bbd0109b25b505a3c2 /compiler/HsVersions.h | |
parent | 969383ba17493d67664b2c0faaec481561401b18 (diff) | |
download | haskell-0e765db44229aed591f9f423ef909b5f76696de0.tar.gz |
Add CoreMonad.reinitializeGlobals so plugins can work around linker issues
When a plugin is loaded, it currently gets linked against a *newly loaded* copy
of the GHC package. This would not be a problem, except that the new copy has its
own mutable state that is not shared with that state that has already been initialized by
the original GHC package.
This leads to loaded plugins calling GHC code which pokes the static flags,
and then dying with a panic because the static flags *it* sees are uninitialized.
There are two possible solutions:
1. Export the symbols from the GHC executable from the GHC library and link
against this existing copy rather than a new copy of the GHC library
2. Carefully ensure that the global state in the two copies of the GHC
library matches
I tried 1. and it *almost* works (and speeds up plugin load times!) except
on Windows. On Windows the GHC library tends to export more than 65536 symbols
(see #5292) which overflows the limit of what we can export from the EXE and
causes breakage.
(Note that if the GHC exeecutable was dynamically linked this wouldn't be a problem,
because we could share the GHC library it links to.)
We are going to try 2. instead. Unfortunately, this means that every plugin
will have to say `reinitializeGlobals` before it does anything, but never mind.
I've threaded the cr_globals through CoreM rather than giving them as an
argument to the plugin function so that we can turn this function into
(return ()) without breaking any plugins when we eventually get 1. working.
Diffstat (limited to 'compiler/HsVersions.h')
-rw-r--r-- | compiler/HsVersions.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/HsVersions.h b/compiler/HsVersions.h index 303d2bdc65..b6f92ae2e7 100644 --- a/compiler/HsVersions.h +++ b/compiler/HsVersions.h @@ -36,19 +36,19 @@ you will screw up the layout where they are used in case expressions! name :: IORef (ty); \ name = Util.global (value); -#define GLOBAL_MVAR(name,value,ty) \ -{-# NOINLINE name #-}; \ -name :: MVar (ty); \ -name = Util.globalMVar (value); +#define GLOBAL_VAR_M(name,value,ty) \ +{-# NOINLINE name #-}; \ +name :: IORef (ty); \ +name = Util.globalM (value); #endif #else /* __HADDOCK__ */ #define GLOBAL_VAR(name,value,ty) \ name :: IORef (ty); \ name = Util.global (value); -#define GLOBAL_MVAR(name,value,ty) \ -name :: MVar (ty); \ -name = Util.globalMVar (value); +#define GLOBAL_VAR_M(name,value,ty) \ +name :: IORef (ty); \ +name = Util.globalM (value); #endif #define COMMA , |