| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
GHC.Linker.Loader
Contents
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
- newtype Loader = Loader {
- loader_state :: MVar (Maybe LoaderState)
- data LoaderState = LoaderState {
- bco_loader_state :: !BytecodeLoaderState
- bcos_loaded :: !(LinkableSet LinkableUsage)
- objs_loaded :: !(LinkableSet LinkableUsage)
- pkgs_loaded :: !PkgsLoaded
- temp_sos :: ![(FilePath, String)]
- initLoaderState :: Interp -> HscEnv -> IO ()
- uninitializedLoader :: IO Loader
- showLoaderState :: Interp -> IO SDoc
- getLoaderState :: Interp -> IO (Maybe LoaderState)
- loadDecls :: Interp -> HscEnv -> SrcSpan -> Linkable -> IO ([LinkableUsage], PkgsLoaded)
- loadPackages :: Interp -> HscEnv -> [UnitId] -> IO ()
- loadModule :: Interp -> HscEnv -> Module -> IO ()
- loadCmdLineLibs :: Interp -> HscEnv -> IO ()
- loadName :: Interp -> HscEnv -> Name -> IO (ForeignHValue, [LinkableUsage], PkgsLoaded)
- unload :: Interp -> HscEnv -> IO ()
- withExtendedLoadedEnv :: ExceptionMonad m => Interp -> [(Name, ForeignHValue)] -> m a -> m a
- extendLoadedEnv :: Interp -> BytecodeLoaderStateModifier -> [(Name, ForeignHValue)] -> IO ()
- deleteFromLoadedHomeEnv :: Interp -> [Name] -> IO ()
- lookupFromLoadedEnv :: Interp -> Name -> IO (Maybe ForeignHValue)
- allocateBreakArrays :: Interp -> ModuleEnv (ForeignRef BreakArray) -> [InternalModBreaks] -> IO (ModuleEnv (ForeignRef BreakArray))
- rmDupLinkables :: LinkableSet LinkableUsage -> [Linkable] -> (LinkableSet LinkableUsage, [Linkable])
- modifyLoaderState :: Interp -> (LoaderState -> IO (LoaderState, a)) -> IO a
- initLinkDepsOpts :: HscEnv -> LinkDepsOpts
- getGccSearchDirectory :: Logger -> LdConfig -> String -> IO [FilePath]
- mkDynLoadLib :: HscEnv -> (Ways -> Ways) -> [(FilePath, String)] -> [UnitId] -> [FilePath] -> IO (Maybe (FilePath, FilePath, String))
- loadMoreUnits :: HscEnv -> [UnitId] -> PkgsLoaded -> IO ([UnitInfo], PkgsLoaded)
- filterNeededPkgsLoaded :: UniqDSet UnitId -> PkgsLoaded -> PkgsLoaded
Documentation
Constructors
| Loader | |
Fields
| |
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.
getLoaderState :: Interp -> IO (Maybe LoaderState) Source #
Load & Unload
loadDecls :: Interp -> HscEnv -> SrcSpan -> Linkable -> IO ([LinkableUsage], 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, [LinkableUsage], 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.
extendLoadedEnv :: Interp -> BytecodeLoaderStateModifier -> [(Name, ForeignHValue)] -> IO () Source #
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.
Arguments
| :: LinkableSet LinkableUsage | Already loaded |
| -> [Linkable] | New linkables |
| -> (LinkableSet LinkableUsage, [Linkable]) |
modifyLoaderState :: Interp -> (LoaderState -> IO (LoaderState, a)) -> IO a Source #
mkDynLoadLib :: HscEnv -> (Ways -> Ways) -> [(FilePath, String)] -> [UnitId] -> [FilePath] -> IO (Maybe (FilePath, FilePath, String)) Source #
Create a shared library containing the given object files
Arguments
| :: HscEnv | |
| -> [UnitId] | New packages to process (not yet in PkgsLoaded) |
| -> PkgsLoaded | Existing loaded packages (used for memoization) |
| -> IO ([UnitInfo], PkgsLoaded) | Reverse topologically-sorted new package infos + updated PkgsLoaded |
Compute LoadedPkgInfo metadata (with transitive deps) for new packages,
without loading any native libraries. Used for recompilation-avoidance
tracking and as the first pass of loadPackages'.
The returned '[UnitInfo]' list is an accumulated *reverse* topologically
sorted list of new packages. The returned PkgsLoaded is populated with
placeholder LoadedPkgInfo for new packages (empty artifact fields, correct
loaded_pkg_trans_deps).
filterNeededPkgsLoaded :: UniqDSet UnitId -> PkgsLoaded -> PkgsLoaded Source #
Restrict a PkgsLoaded map to the packages directly needed and their
full transitive closure (via loaded_pkg_trans_deps).