HORIZON HASKELLDocslts/ghc-10.0.x8174fa42026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11

Moduleghc-10.0.0.20260917GHC2024

GHC.Linker.Loader

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.

  • 2 types
  • 22 values
datadata LoaderState
#

Constructors

valueinitLoaderState :: Interp -> HscEnv -> IO ()
#

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.

Load & Unload

6 declarations
valueloadPackages :: Interp -> HscEnv -> [UnitId] -> IO ()
#

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.

valueunload :: Interp -> HscEnv -> IO ()
#

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

4 declarations

Internals

8 declarations
valueloadMoreUnits
  1. :: HscEnv
  2. -> [UnitId]

    New packages to process (not yet in PkgsLoaded)

  3. -> PkgsLoaded

    Existing loaded packages (used for memoization)

  4. -> 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).