[Haskell-cafe] Partial statical linking

Jason Dusek jason.dusek at gmail.com
Sat Nov 26 07:59:18 CET 2011

Some time ago, I wrote to this list about making shared
libraries with GHC, in such a way that the RTS was linked and
ready to go. Recently, I've been looking a similar but, in a
sense, opposite problem: linking Haskell executables with some
of their non-Haskell dependencies, for distribution.

I tried passing a few different sets of options to the linker
through GHC, with -optl:


None of these had the desired effect. In the end, running GHC
with -v and carefully editing the linker line produced the
desired change (I have linked to and provided the diff below).

The effect -optl seems to be to introduce options in the linker
line just before -lHSrtsmain, which would seem to prevent one
from linking libffi and libgmp differently. Is editing and
storing away the linker script the best option at present for
partially static linking?

Jason Dusek
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

#@@ -122,10 +122,8 @@
#   -lHSarray- \
#   -lHSbase- \
#   -lHSinteger-gmp- \
#-  -lgmp \
#   -lHSghc-prim- \
#   -lHSrts \
#-  -lffi \
#   -lm \
#   -lrt \
#   -ldl \
#@@ -136,4 +134,7 @@
#   -lgcc_s --no-as-needed \
#   /usr/lib/gcc/x86_64-linux-gnu/4.6.1/crtend.o \
#   /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crtn.o \
#+  -static \
#+  -lgmp \
#+  -lffi \

More information about the Haskell-Cafe mailing list