<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 3, 2015, at 3:24 PM, Brian Swetland &lt;<a href="mailto:swetland@frotz.net" class="">swetland@frotz.net</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Dec 3, 2015 at 1:57 PM, Joe Groff <span dir="ltr" class="">&lt;<a href="mailto:jgroff@apple.com" target="_blank" class="">jgroff@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5"><br class="">
&gt; On Dec 3, 2015, at 1:54 PM, Brian Swetland &lt;<a href="mailto:swetland@frotz.net" class="">swetland@frotz.net</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt; If I want to build something I can hope will run on other linux machines with potentially arbitrary distributions, it'd be really nice to be able to build fully static, or at least more self-contained binaries.<br class="">
&gt;<br class="">
&gt; Both license-wise and operationally, linking glibc staticly is problematic, but at least glibc has very strong backward compatibility with itself.&nbsp; libstdc++ on the other hand is something I'd always want staticly linked to not be at the whim of ABI breakages from release to release.<br class="">
&gt;<br class="">
&gt; I'm curious about the libstdc++ dependency, since I was under the impression the swift runtime was written in swift.&nbsp; What part of the runtime or generated code causes this dependency to exist?<br class="">
&gt;<br class="">
&gt; The libc dependency could be simplified by supporting musl-libc (small, MIT licensed, pretty source-compatible with glibc).<br class="">
&gt;<br class="">
&gt; Given that libbsd and libicu are under permissive licenses and libstdc++ (if it's needed) has a linkage exception), it'd be nice to have a way to include those staticly (in either libswiftCore.so or final binaries), resulting in the only remaining dependencies being on libc/libc/libpthread/libdl which have extremely robust and well maintained API/ABI backward compatibility.<br class="">
&gt;<br class="">
&gt; This should allow for linux binaries which have significantly better chances of working correctly on an arbitrary linux machine.<br class="">
<br class="">
</div></div>It should be possible to configure Swift to statically link libswiftCore.so on Linux. We dynamically link on Apple platforms for future-proofing, but that's not a concern on Linux as far as I can see. The Swift core runtime is written in C++, as are some edges of the standard library, hence the libstdc++ dependency. If you're concerned about licensing issues statically linking libstdc++, then building against LLVM's UIUC-licensed libc++ might be a possibility.<br class=""></blockquote><div class=""><br class="">libstdc++ has a pretty clear linkage exception that allows it to be 
bolted into whatever, so the license is less of a concern than the fact that it often is not forward/backward compatible across versions.&nbsp; Static linking libc/glibc is problematic license-wise, but since it's very stable from a compatibility viewpoint linking it dynamically is not a worry.&nbsp; Also glibc's dns resolver and some other features do not work correctly when it's linked staticly.<br class=""><br class=""></div><div class="">An option to link the non-libc/libm/libpthread/libdl dependencies of libswiftCore.so into it on Linux would allow for far more robust binaries (worst case you bundle the particular libswiftCore.so you built against with your app and you should be pretty safe).<br class=""></div></div></div></div></div></blockquote></div><br class=""><div class="">Sounds good. Statically linking libstdc++ and libswiftCore while leaving glibc dynamically linked should be fine. Porting to musl libc might be interesting too, but I'm not sure how dependent the core libs are/will be on glibc stuff.</div><div class=""><br class=""></div><div class="">-Joe</div></body></html>