[swift-users] statically link the standard library on Linux
Drew Crawford
drew at sealedabstract.com
Wed Feb 17 14:40:01 CST 2016
I traced this down to the sourcecode after I posted here: https://bugs.swift.org/browse/SR-730 <https://bugs.swift.org/browse/SR-730>
tll;dr the standard library is forcibly dynamically-linked on Linux, and we need a way to opt out of that from the swift frontend. I have not gone further with that since A) my C++-foo is not very excellent and B) core hasn't blessed any particular solution I proffered in that thread. If you can make progress there I would be grateful.
Then it is just a matter of getting the flags right; in practice, OSX wants -L path/to/swift_static -lc++ -framework Foundation -Xlinker -force_load_swift_libs, whereas Linux wants (I believe) -licuuc -licu18n -lbsd /path/to/swift_static/a.a /path/to/swift_static/b.a /path/to/swift_static/c.a ... There may be an equivalent to force_load_swift_libs that knows what libs to load, but I haven't found it yet.
However as long as the Swift frontend forcibly injects the dynamic link we are SOL, so some progress needs to be made in the frontend first.
> On Feb 17, 2016, at 1:37 PM, Max Howell <max.howell at apple.com> wrote:
>
> We have a ticket open to implement static linking of swift libs.
>
> If anyone on the Swift team knows how to do this and can comment here then I’m sure we can get it implemented pretty quickly.
>
>> On Feb 13, 2016, at 7:54 PM, Drew Crawford via swift-users <swift-users at swift.org <mailto:swift-users at swift.org>> wrote:
>>
>> Whenever I update the installed Linux snapshot, my binaries break, with errors of the form:
>>
>> [programname]: symbol lookup error: [programname]: undefined symbol: _TFOs7Processau9argumentsGSaSS_
>>
>> I assume this is the standard library symbol Process.arguments (which is used in my program).
>>
>> I guess this is because the standard library is not statically linked/embedded in this executable. This happens by default on OSX, but I guess might not on Linux.
>>
>> Is that a bug?
>> Is there a way to force statically link the standard library on Linux, so my binaries work without a recompile each new snapshot?
>>
>>
>>
>>
>> _______________________________________________
>> swift-users mailing list
>> swift-users at swift.org <mailto:swift-users at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160217/1480fa6d/attachment.html>
More information about the swift-users
mailing list