What I attempted was building a binary with only some C libraries
statically linked, with this command line:
# Build https://github.com/erudify/sssp on Ubunut 12.04
ghc -outputdir ./tmp -v --make -O2 sssp.hs -o sssp.ubuntu \
/usr/lib/x86_64-linux-gnu/libffi.a \
/usr/lib/x86_64-linux-gnu/libgmp.a \
/usr/lib/x86_64-linux-gnu/libz.a
However, this really made no difference. Running `ldd' on the
resulting binary reveals that libz and friends are still
dynamically linked:
On Linux you probably need -optl--whole-archive for this to do anything; alternately, you would need to get the final ld command line out of ghc and insert the above libraries into it *after* the package .a files.
Putting them before the packages (including the GHC runtime) that need them, as will happen by default, will cause them to be ignored because they contain no required symbols *at that point* in the link. --whole-archive tells to blindly link the whole static archive in instead of ignoring it.