<div dir="ltr">The --exclude-libs linker option does exactly that.<div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 19, 2016 at 4:08 PM, Joe Groff via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
> On Feb 19, 2016, at 1:06 PM, Max Howell <<a href="mailto:max.howell@apple.com" target="_blank">max.howell@apple.com</a>> wrote:<br>
><br>
>>>> 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:<br>
>>>><br>
>>>> - public has default visibility,<br>
>>>> - internal has hidden visibility (__attribute__((visibility("hidden"))) in Clang),<br>
>>>> - private has private linkage (like 'static' in C).<br>
>>>><br>
>>>> 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.<br>
>>><br>
>>> I’ve worried about such things, but my conclusions were there weren’t any practically compelling reasons to worry about it too much.<br>
>>><br>
>>> My reasoning being: when writing a Swift file the compiler won’t give you access to those symbols unless you `import` that module, in which case you want them.<br>
>>><br>
>>> Unless there is something I’m missing?<br>
>><br>
>> Maybe not huge problems, but it's a secrecy violation and unwanted ABI liability, and also limits LTO-level optimization opportunities since exported functions have to preserve their existence and calling convention.<br>
><br>
> Makes sense, can we solve it? Our current direction is certainly one of: stuff all the (library) modules into a single linkage unit, be that a single dylib, a static library or a framework.<br>
<br>
</span>If the frontend knows it's building for a static library, it could conceivably set the correct visibility contingent on that flag. There may also be ld flags to suppress exporting symbols from particular .o and .a files post-hoc.<br>
<br>
-Joe<br>
<div><div>_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Trent Nadeau</div>
</div></div>