[Haskell-cafe] Partial statical linking
Brandon Allbery
allbery.b at gmail.com
Wed Sep 19 17:00:35 CEST 2012
On Wed, Sep 19, 2012 at 7:06 AM, Jason Dusek <jason.dusek at gmail.com> wrote:
> 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.
--
brandon s allbery allbery.b at gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120919/b7efdcbe/attachment.htm>
More information about the Haskell-Cafe
mailing list