rts-loader-0.0.0.3: Dynamically load Haskell libraries

CopyrightCopyright (C) 2016 Daniel Gröber
LicenseGPLv3+
Stabilityexperimental
Portabilitytested on Linux, might work on OSX, will support Win32 in the future if possible
Safe HaskellNone
LanguageHaskell2010

System.Loader.RTS

Contents

Description

Dynamically load entrypoints from Haskell libraries independent of the RTS version.

Synopsis

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.) and
  • ways 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.

See GHC-Wiki/Commentary/Rts/CompilerWays.

loaderInvocation Source

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 type IO ()) 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

type OccName = String Source

An unqualified name of a binder eg. main

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.

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.