ghc-lib-parser-9.10.1.20250103: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
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_trans_deps :: UniqDSet UnitId
  }
- type PkgsLoaded = UniqDFM UnitId LoadedPkgInfo

# Documentation

newtype Loader #

Constructors

Loader |
Fields loader_state :: MVar (Maybe LoaderState)

data LoaderState #

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 #

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

data LinkerEnv #

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 #

type ClosureEnv = NameEnv (Name, ForeignHValue) #

emptyClosureEnv :: ClosureEnv #

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

data Linkable #

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 # |
Instance details Defined in GHC.Linker.Types Methods ppr :: Linkable -> SDoc #

type LinkableSet = ModuleEnv Linkable #

mkLinkableSet :: [Linkable] -> LinkableSet #

unionLinkableSet :: LinkableSet -> LinkableSet -> LinkableSet #

type ObjFile = FilePath #

data Unlinked #

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 # |
Instance details Defined in GHC.Linker.Types Methods ppr :: Unlinked -> SDoc #

data SptEntry #

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 # |
Instance details Defined in GHC.Linker.Types Methods ppr :: SptEntry -> SDoc #

isObjectLinkable :: Linkable -> Bool #

linkableObjs :: Linkable -> [FilePath] #

isObject :: Unlinked -> Bool #

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

nameOfObject :: Unlinked -> FilePath #

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

nameOfObject_maybe :: Unlinked -> Maybe FilePath #

isInterpretable :: Unlinked -> Bool #

Is this a bytecode linkable with no file on disk?

byteCodeOfObject :: Unlinked -> [CompiledByteCode] #

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

data LibrarySpec #

Constructors

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

#### Instances

Instances details

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

data LoadedPkgInfo #

Constructors

LoadedPkgInfo |
Fields loaded_pkg_uid :: !UnitId loaded_pkg_hs_objs :: ![LibrarySpec] loaded_pkg_non_hs_objs :: ![LibrarySpec] loaded_pkg_trans_deps :: UniqDSet UnitId

#### Instances

Instances details

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

type PkgsLoaded = UniqDFM UnitId LoadedPkgInfo #