ghc-9.15: The GHC API
Safe HaskellNone
LanguageGHC2024

GHC.Linker.Loader

Description

The loader

This module deals with the top-level issues of dynamic linking (loading), calling the object-code linker and the byte-code linker where necessary.

Synopsis

Documentation

newtype Loader Source #

Constructors

Loader 

data LoaderState Source #

Constructors

LoaderState 

Fields

initLoaderState :: Interp -> HscEnv -> IO () Source #

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 v_Opt_l,

d) Loading any .o/.dll files specified on the command line, now held in ldInputs,

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.

showLoaderState :: Interp -> IO SDoc Source #

Display the loader state.

Load & Unload

loadDecls :: Interp -> HscEnv -> SrcSpan -> Linkable -> IO ([Linkable], PkgsLoaded) Source #

Load the dependencies of a linkable, and then load the linkable itself.

loadPackages :: Interp -> HscEnv -> [UnitId] -> IO () Source #

Load exactly the specified packages, and their dependents (unless of course they are already loaded). The dependents are loaded automatically, and it doesn't matter what order you specify the input packages.

loadName :: Interp -> HscEnv -> Name -> IO (ForeignHValue, [Linkable], PkgsLoaded) Source #

Load the module containing the given Name and get its associated HValue.

Throws a ProgramError if loading fails or the name cannot be found.

unload :: Interp -> HscEnv -> IO () Source #

Unloading old objects ready for a new compilation sweep. * compilation artifacts for home modules that we might be about to recompile are unloaded from the interpreter. * we also implicitly unload all temporary bindings at this point.

LoadedEnv

withExtendedLoadedEnv :: ExceptionMonad m => Interp -> [(Name, ForeignHValue)] -> m a -> m a Source #

Temporarily extend the loaded env.

lookupFromLoadedEnv :: Interp -> Name -> IO (Maybe ForeignHValue) Source #

Have we already loaded a name into the interpreter?

Internals

allocateBreakArrays :: Interp -> ModuleEnv (ForeignRef BreakArray) -> [InternalModBreaks] -> IO (ModuleEnv (ForeignRef BreakArray)) Source #

Given a list of InternalModBreaks collected from a list of CompiledByteCode, allocate the BreakArray used to trigger breakpoints.

mkDynLoadLib :: HscEnv -> (Ways -> Ways) -> [(FilePath, String)] -> [UnitId] -> [FilePath] -> IO (Maybe (FilePath, FilePath, String)) Source #

Create a shared library containing the given object files