The rts-loader package

[Tags:deprecated, gpl, library, program]
Deprecated.

Load and execute functions from Haskell dynamic libraries without being restricted to a single RTS/GHC version.

See README.md below for more information.


[Skip to Readme]

Properties

Versions 0.0.0.0, 0.0.0.1, 0.0.0.2, 0.0.0.3 (info)
Change log ChangeLog
Dependencies base (>=4.8.0.0 && <4.10), Cabal (>=1.24.0.0 && <1.25), directory (>=1.2.2.0 && <1.3), filepath (>=1.4.0.0 && <1.5), process (>=1.2.3.0 && <1.5), rts-loader, unix (>=2.7.1.0 && <2.8), zenc (==0.1.1) [details]
License GPL-3[multiple license files]
Copyright Copyright (C) 2016 Daniel Gröber
Author Daneil Gröber
Maintainer dxld@darkboxed.org
Category Distribution
Home page https://github.com/DanielG/rts-loader
Source repository head: git clone https://github.com/DanielG/rts-loader.git
Uploaded Thu Jun 23 23:54:39 UTC 2016 by DanielG
Distributions NixOS:0.0.0.3
Downloads 135 total (3 in the last 30 days)
Votes
0 []
Status Docs uploaded by user [build log]
All reported builds failed as of 2016-06-23 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for rts-loader

Readme for rts-loader-0.0.0.3

Haskell dynamic library loader

Load and execute functions from Haskell dynamic libraries without being restricted to a single RTS/GHC version.

This package consists of the initial loader executable rts-loader written in plain C and a Haskell library providing a convinient interface to it. The initial loader executable is implemented in C since writing it in Haskell would mean linking against the RTS which means we can't load libraries compiled with another version of GHC.

In order to get Cabal to compile a pure C executable while not linking against the RTS still some hacks in Setup.hs are employed to call gcc directly so beware.

Usage

The example below will locate the package "foopkg" in the package databases configured for the Cabal project in the current directory and execute the function "main" from the module "Lib". The package can be found in tests/lib in the rts-loader source tree.

To run the example, execute the following commands in the rts-loader source tree.

$ cabal install --only-dependencies && cabal configure && cabal build && cabal install tests/lib
$ rts_loader_libexecdir=dist/build/rts-loader dist/build/rts-loader-example/rts-loader-example

rts_loader_libexecdir=... is only required if you didn't install rts-loader into a sandbox or elsewhere already.

import System.Loader.RTS
import System.Process

import Distribution.Verbosity
import Distribution.Package
import Distribution.Simple.Configure

import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Configure (getPersistBuildConfig)

main :: IO ()
main = do
  lbi <- getPersistBuildConfig "dist"

  let verbosity = normal
      comp = compiler lbi
      pkg_db_stack = withPackageDB lbi
      prog_conf = withPrograms lbi

  pidx <- getInstalledPackages verbosity comp pkg_db_stack prog_conf

  loader_exe <- loaderExecutablePath
  loader_args <- loaderInvocation (SymbolIdentifier "Lib" "main") [] <$>
    (resolveLibraryInfo comp [WayDyn] $
      lookupLibraryInfo pidx $
        PQName $ PackageName "foopkg")

  print =<< rawSystem loader_exe loader_args

We use information written by cabal configure (see getPersistBuildConfig) for convinience only this is not actually required to use the loader.