Copyright | Copyright (C) 2016 Daniel Gröber |
---|---|
License | GPLv3+ |
Stability | experimental |
Portability | tested on Linux, might work on OSX, will support Win32 in the future if possible |
Safe Haskell | None |
Language | Haskell2010 |
System.Loader.RTS
Description
Dynamically load entrypoints from Haskell libraries independent of the RTS version.
- lookupLibraryInfo :: InstalledPackageIndex -> PackageQualifier -> LibraryInfo
- resolveLibraryInfo :: Compiler -> [Way] -> LibraryInfo -> IO ResolvedLibraryInfo
- loaderInvocation :: SymbolIdentifier -> [String] -> ResolvedLibraryInfo -> [String]
- loaderExecutablePath :: IO FilePath
- type ModuleName = String
- type OccName = String
- data PackageQualifier
- data SymbolIdentifier = SymbolIdentifier ModuleName OccName
- data LibraryInfo
- data ResolvedLibraryInfo
- data Way
Functions
lookupLibraryInfo :: InstalledPackageIndex -> PackageQualifier -> LibraryInfo Source
lookupLibraryInfo pkg_index pkg_qual
Gets all the information required for loading a library from a package
database out of the corresponding package index pkg_index
. The desired
package is identified using pkg_qual
which allows doing the lookup by name,
name+version or the unique "unit id" associated with a package.
The pkg_index
must at the very least contain the packages "base", "rts" and
the package identified by pkg_qual
. The packages "base" and "rts" are
required because of GHC bug
#10352 thus this restriction might disappear eventually.
The required package index can be obtained using
getInstalledPackages
verbosity comp
pkg_db_stack prog_conf
resolveLibraryInfo :: Compiler -> [Way] -> LibraryInfo -> IO ResolvedLibraryInfo Source
resolveLibraryInfo comp ways li
Find libraries mentioned in li
on the filesystem.
comp
identifies the compiler (version, ABI etc.) andways
allows looking for the different library versions, i.e. "plain", "profiled", "threaded" and combinations thereof (note that order is significant"). Usually you'll just want[WayDyn]
though even this is implied so[]
would suffice for a plain library.
Arguments
:: SymbolIdentifier | |
-> [String] | Command line arguments to pass to hs_main |
-> ResolvedLibraryInfo | |
-> [String] |
loaderInvocation sym args rli
Construct the commandline for the rts-loader
program which
- loads the library described by
rli
, - executes
sym
as its "main" function (i.e. it should be of typeIO ()
) and - passes the command line arguments
args
via the environment.
loaderExecutablePath :: IO FilePath Source
Path to the "rts-loader
" executable distributed along with this
library, "$libexec/rts-loader
". If set the environment variable
rts_loader_libexecdir
is used instead of Cabal's "$libexec
" variable
which was set during installation time.
Type Synonyms
type ModuleName = String Source
A regular Haskell module name eg. System.Loader.RTS
Datatypes
data PackageQualifier Source
Encodes the ways a package can be looked up in a PackageIndex
Constructors
PQName PackageName | Identify a package by just its name, if multiple packages match the latest version is picked but which unit id is picked is undefined. |
PQId PackageId | Identify a package by its name and version. If multiple packages are found with varying unit ids which one is picked is undefined. |
PQUnitId UnitId | Fully qualified package only one package matching can be present in a package database. |
data SymbolIdentifier Source
Identify a binder (aka. a "symbol" at the object file level) within a package.
Constructors
SymbolIdentifier ModuleName OccName |
Internal Datatypes
data LibraryInfo Source
Information about a library extracted from a package database stack.
data ResolvedLibraryInfo Source
Everything in LibraryInfo
plus fully resolved library paths.