Dockerfile for building a GHC package for Debian/Ubuntu which supports
statically linking Haskell dependencies into dynamic (e.g.
Supported GHC versions:
Install docker, run
make, wait. When make is done, you'll find your package
To build a shared library with all Haskell dependencies statically linked, use the following GHC flags:
-fPIC -shared -optl-Wl,-Bstatic -lHSrts -lCffi -optl-Wl,-Bdynamic -lrt -lpthread
cabal has its own ideas about what flags to pass to the linker,
which makes it unable to produce shared libraries with statically linked Haskell
dependencies even when properly setting
Because it's nice to be able to distribute Haskell .so files without having to
also distribute the roughly seven million
libHSwhatever-x.y.z.so it ends
up depending on with dynamic linking.
With the right flags, this GHC build produces .so files that are only dependent
on the standard system libraries