[swift-users] statically link the standard library on Linux

Joe Groff jgroff at apple.com
Fri Feb 19 13:50:58 CST 2016


> On Feb 17, 2016, at 11:37 AM, Max Howell via swift-users <swift-users at swift.org> 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.

Static vs dynamic building of libraries may also have an interesting impact on the build system, particularly in how we set visibility for emitted symbols. For executables and dylibs, our current mapping of access control to visibility and linkage makes sense:

- public has default visibility,
- internal has hidden visibility (__attribute__((visibility("hidden"))) in Clang),
- private has private linkage (like 'static' in C).

However, when statically linking a library into another executable or dylib, the static library's public symbols in most cases probably ought to become hidden in the final target, unless the dylib or executable explicitly reexports the static library's module somehow.

-Joe


More information about the swift-users mailing list