The dynamic linker for GHCi.
This module deals with the top-level issues of dynamic linking, calling the object-code linker and the byte-code linker where necessary.
- data HValue
- getHValue :: HscEnv -> Name -> IO HValue
- showLinkerState :: IO ()
- linkExpr :: HscEnv -> SrcSpan -> UnlinkedBCO -> IO HValue
- unload :: DynFlags -> [Linkable] -> IO ()
- withExtendedLinkEnv :: (MonadIO m, ExceptionMonad m) => [(Name, HValue)] -> m a -> m a
- extendLinkEnv :: [(Name, HValue)] -> IO ()
- deleteFromLinkEnv :: [Name] -> IO ()
- extendLoadedPkgs :: [PackageId] -> IO ()
- linkPackages :: DynFlags -> [PackageId] -> IO ()
- initDynLinker :: DynFlags -> IO ()
- linkModule :: HscEnv -> Module -> IO ()
- dataConInfoPtrToName :: Ptr () -> TcM (Either String Name)
- lessUnsafeCoerce :: DynFlags -> String -> a -> IO b
- data PersistentLinkerState
- saveLinkerGlobals :: IO (MVar PersistentLinkerState, Bool)
- restoreLinkerGlobals :: (MVar PersistentLinkerState, Bool) -> IO ()
Link a single expression, including first linking packages and modules that this expression depends on.
Raises an IO exception (
ProgramError) if it can't find a compiled
version of the dependents to link.
Unloading old objects ready for a new compilation sweep.
The compilation manager provides us with a list of linkables that it considers "stable", i.e. won't be recompiled this time around. For each of the modules current linked in memory,
- if the linkable is stable (and it's the same one -- the user may have recompiled the module on the side), we keep it,
- otherwise, we unload it.
- we also implicitly unload all temporary bindings at this point.
Temporarily extend the linker state.
Link exactly the specified packages, and their dependents (unless of course they are already linked). The dependents are linked automatically, and it doesn't matter what order you specify the input packages.
Initialise the dynamic linker. This entails
a) Calling the C initialisation procedure,
b) Loading any packages specified on the command line,
c) Loading any packages specified on the command line, now held in the
-l options in
d) Loading any
.o/.dll files specified on the command line, now held
e) Loading any MacOS frameworks.
NOTE: This function is idempotent; if called more than once, it does nothing. This is useful in Template Haskell, where we call it before trying to link.
Given a data constructor in the heap, find its Name. The info tables for data constructors have a field which records the source name of the constructor as a Ptr Word8 (UTF-8 encoded string). The format is:
We use this string to lookup the interpreter's internal representation of the name using the lookupOrig.
Coerce a value as usual, but:
1) Evaluate it immediately to get a segfault early if the coercion was wrong
2) Wrap it in some debug messages at verbosity 3 or higher so we can see what happened if it does segfault