[swift-users] Swift Package Manager: Linker Flags

Max Howell max.howell at apple.com
Fri Feb 26 15:51:45 CST 2016


> On Feb 24, 2016, at 6:03 PM, Stephen Celis via swift-users <swift-users at swift.org> wrote:
> 
> Thanks for following up :)
> 
>> On Feb 24, 2016, at 8:46 PM, Fabio Kaminski <fabiokaminski at gmail.com <mailto:fabiokaminski at gmail.com>> wrote:
>> 
>> 1 - For me at least the "link" directive works only for shared libs,
>> and given you are looking into the symbols of the .a file and not the
>> .dylib or .so, that its probably what the modulemap will try to link
>> against?
> 
> Ah, interesting! Is there a reason for this limitation? Could a bug be filed for a swiftpm enhancement that automatically adds `-l` flags for whatever is included as a `link` in the module map?

This is a limitation of module maps, so any improvement would have to go into clang.

>> I think the [extern_c] directive maybe is the magic sauce that will
>> try to link the symbols using the correct mangling technique "_" ?
> 
> Unfortunately [extern_c] doesn't seem to have any effect on linking, though it appears to be the correct attribute according to http://clang.llvm.org/docs/Modules.html#module-declaration <http://clang.llvm.org/docs/Modules.html#module-declaration>. I was able to fix the problem, though, with this Makefile in my dependent project:
> 
> https://gist.github.com/stephencelis/7f76f8d26a1df64ee3ff#file-llvm_makefile-mak <https://gist.github.com/stephencelis/7f76f8d26a1df64ee3ff#file-llvm_makefile-mak>
> 
> It's an unfortunate limitation. Requiring dependent projects to set certain `-Xcc` and `-Xlinker` flags makes the parent CLLVM dependency a lot less easy to use. I'm not sure if there have been evolution, bug, or internal discussions around this, though. At least I'm unblocked in the meantime. Thanks again!

-Xcc/-Xlinker are strictly work-ardoun methods so that people can make progress with swift build until we have real solutions.

Watch for my proposal to improve module map support coming to swift-evolution at some point.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160226/d46c478d/attachment.html>


More information about the swift-users mailing list