ghc-9.10.3: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Linker.Types

Synopsis

- newtype Loader = Loader {
  - loader_state :: MVar (Maybe LoaderState)
  }
- data LoaderState = LoaderState {
  - linker_env :: !LinkerEnv
  - bcos_loaded :: !LinkableSet
  - objs_loaded :: !LinkableSet
  - pkgs_loaded :: !PkgsLoaded
  - temp_sos :: ![(FilePath, String)]
  }
- uninitializedLoader :: IO Loader
- modifyClosureEnv :: LoaderState -> (ClosureEnv -> ClosureEnv) -> LoaderState
- data LinkerEnv = LinkerEnv {
  - closure_env :: !ClosureEnv
  - itbl_env :: !ItblEnv
  - addr_env :: !AddrEnv
  }
- filterLinkerEnv :: (Name -> Bool) -> LinkerEnv -> LinkerEnv
- type ClosureEnv = NameEnv (Name, ForeignHValue)
- emptyClosureEnv :: ClosureEnv
- extendClosureEnv :: ClosureEnv -> [(Name, ForeignHValue)] -> ClosureEnv
- data Linkable = LM {
  - linkableTime :: !UTCTime
  - linkableModule :: !Module
  - linkableUnlinked :: [Unlinked]
  }
- type LinkableSet = ModuleEnv Linkable
- mkLinkableSet :: [Linkable] -> LinkableSet
- unionLinkableSet :: LinkableSet -> LinkableSet -> LinkableSet
- type ObjFile = FilePath
- data Unlinked
  - = DotO ObjFile
  - | DotA FilePath
  - | DotDLL FilePath
  - | CoreBindings WholeCoreBindings
  - | LoadedBCOs [Unlinked]
  - | BCOs CompiledByteCode [SptEntry]
- data SptEntry = SptEntry Id Fingerprint
- isObjectLinkable :: Linkable -> Bool
- linkableObjs :: Linkable -> [FilePath]
- isObject :: Unlinked -> Bool
- nameOfObject :: Unlinked -> FilePath
- nameOfObject_maybe :: Unlinked -> Maybe FilePath
- isInterpretable :: Unlinked -> Bool
- byteCodeOfObject :: Unlinked -> [CompiledByteCode]
- data LibrarySpec
  - = Objects [FilePath]
  - | Archive FilePath
  - | DLL String
  - | DLLPath FilePath
  - | Framework String
- data LoadedPkgInfo = LoadedPkgInfo {
  - loaded_pkg_uid :: !UnitId
  - loaded_pkg_hs_objs :: ![LibrarySpec]
  - loaded_pkg_non_hs_objs :: ![LibrarySpec]
  - loaded_pkg_hs_dlls :: ![RemotePtr LoadedDLL]
  - loaded_pkg_trans_deps :: UniqDSet UnitId
  }
- type PkgsLoaded = UniqDFM UnitId LoadedPkgInfo

# Documentation

newtype Loader Source #

Constructors

Loader |

Fields

- loader_state :: MVar (Maybe LoaderState)

data LoaderState Source #

Constructors

LoaderState |

Fields

- linker_env :: !LinkerEnv

  Current global mapping from Names to their true values

- bcos_loaded :: !LinkableSet

  The currently loaded interpreted modules (home package)

- objs_loaded :: !LinkableSet

  And the currently-loaded compiled modules (home package)

- pkgs_loaded :: !PkgsLoaded

  The currently-loaded packages; always object code haskell libraries, system libraries, transitive dependencies

- temp_sos :: ![(FilePath, String)]

  We need to remember the name of previous temporary DLL/.so libraries so we can link them (see #10322)

uninitializedLoader :: IO Loader Source #

modifyClosureEnv :: LoaderState -> (ClosureEnv -> ClosureEnv) -> LoaderState Source #

data LinkerEnv Source #

Constructors

LinkerEnv |

Fields

- closure_env :: !ClosureEnv

  Current global mapping from closure Names to their true values

- itbl_env :: !ItblEnv

  The current global mapping from RdrNames of DataCons to info table addresses. When a new Unlinked is linked into the running image, or an existing module in the image is replaced, the itbl_env must be updated appropriately.

- addr_env :: !AddrEnv

  Like `closure_env` and `itbl_env`, but for top-level 'Addr#' literals, see Note [Generating code for top-level string literal bindings] in GHC.StgToByteCode.

filterLinkerEnv :: (Name -> Bool) -> LinkerEnv -> LinkerEnv Source #

type ClosureEnv = NameEnv (Name, ForeignHValue) Source #

emptyClosureEnv :: ClosureEnv Source #

extendClosureEnv :: ClosureEnv -> [(Name, ForeignHValue)] -> ClosureEnv Source #

data Linkable Source #

Information we can use to dynamically link modules into the compiler

Constructors

LM |

Fields

- linkableTime :: !UTCTime

  Time at which this linkable was built (i.e. when the bytecodes were produced, or the mod date on the files)

- linkableModule :: !Module

  The linkable module itself

- linkableUnlinked :: [Unlinked]

  Those files and chunks of code we have yet to link.

  INVARIANT: A valid linkable always has at least one `Unlinked` item.

#### Instances

Instances details

Outputable Linkable Source # |
Instance details Defined in GHC.Linker.Types Methods ppr :: Linkable -> SDoc Source #

type LinkableSet = ModuleEnv Linkable Source #

mkLinkableSet :: [Linkable] -> LinkableSet Source #

unionLinkableSet :: LinkableSet -> LinkableSet -> LinkableSet Source #

type ObjFile = FilePath Source #

data Unlinked Source #

Objects which have yet to be linked by the compiler

Constructors

DotO ObjFile | An object file (.o)
DotA FilePath | Static archive file (.a)
DotDLL FilePath | Dynamically linked library file (.so, .dll, .dylib)
CoreBindings WholeCoreBindings | Serialised core which we can turn into BCOs (or object files), or used by some other backend See Note [Interface Files with Core Definitions]
LoadedBCOs [Unlinked] | A list of BCOs, but hidden behind extra indirection to avoid being too strict.
BCOs CompiledByteCode [SptEntry] | A byte-code object, lives only in memory. Also carries some static pointer table entries which should be loaded along with the BCOs. See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable.

#### Instances

Instances details

Outputable Unlinked Source # |
Instance details Defined in GHC.Linker.Types Methods ppr :: Unlinked -> SDoc Source #

data SptEntry Source #

An entry to be inserted into a module's static pointer table. See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable.

Constructors

SptEntry Id Fingerprint |

#### Instances

Instances details

Outputable SptEntry Source # |
Instance details Defined in GHC.Linker.Types Methods ppr :: SptEntry -> SDoc Source #

isObjectLinkable :: Linkable -> Bool Source #

linkableObjs :: Linkable -> [FilePath] Source #

isObject :: Unlinked -> Bool Source #

Is this an actual file on disk we can link in somehow?

nameOfObject :: Unlinked -> FilePath Source #

Retrieve the filename of the linkable if possible. Panic if it is a byte-code object

nameOfObject_maybe :: Unlinked -> Maybe FilePath Source #

isInterpretable :: Unlinked -> Bool Source #

Is this a bytecode linkable with no file on disk?

byteCodeOfObject :: Unlinked -> [CompiledByteCode] Source #

Retrieve the compiled byte-code if possible. Panic if it is a file-based linkable

data LibrarySpec Source #

Constructors

Objects [FilePath] |
Archive FilePath |
DLL String |
DLLPath FilePath |
Framework String |

#### Instances

Instances details

Outputable LibrarySpec Source # |
Instance details Defined in GHC.Linker.Types Methods ppr :: LibrarySpec -> SDoc Source #

data LoadedPkgInfo Source #

Constructors

LoadedPkgInfo |

Fields

- loaded_pkg_uid :: !UnitId
- loaded_pkg_hs_objs :: ![LibrarySpec]
- loaded_pkg_non_hs_objs :: ![LibrarySpec]
- loaded_pkg_hs_dlls :: ![RemotePtr LoadedDLL]

  See Note [Looking up symbols in the relevant objects]

- loaded_pkg_trans_deps :: UniqDSet UnitId

#### Instances

Instances details

Outputable LoadedPkgInfo Source # |
Instance details Defined in GHC.Linker.Types Methods ppr :: LoadedPkgInfo -> SDoc Source #

type PkgsLoaded = UniqDFM UnitId LoadedPkgInfo Source #