<div dir="ltr">On Wed, Sep 19, 2012 at 7:06 AM, Jason Dusek <span dir="ltr">&lt;<a href="mailto:jason.dusek@gmail.com" target="_blank">jason.dusek@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What I attempted was building a binary with only some C libraries<br>
statically linked, with this command line:<br>
<br>
  # Build <a href="https://github.com/erudify/sssp" target="_blank">https://github.com/erudify/sssp</a> on Ubunut 12.04<br>
  ghc -outputdir ./tmp -v --make -O2 sssp.hs -o sssp.ubuntu \<br>
    /usr/lib/x86_64-linux-gnu/libffi.a \<br>
    /usr/lib/x86_64-linux-gnu/libgmp.a \<br>
    /usr/lib/x86_64-linux-gnu/libz.a<br>
<br>
However, this really made no difference. Running `ldd&#39; on the<br>
resulting binary reveals that libz and friends are still<br>
dynamically linked:<br></blockquote><div><br></div><div>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.</div>
<div><br></div><div>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.</div>
</div><div><br></div>-- <br>brandon s allbery                                      <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a><br>wandering unix systems administrator (available)     (412) 475-9364 vm/sms<br>
<br>
</div>