Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-08 Thread Ján Kosa via swift-users
I filed bug report: https://bugs.swift.org/browse/SR-6091 On 8 October 2017 at 20:31, Daniel Dunbar wrote: > Can you file this on bugs.swift.org? We are likely to lose track of it if > it just an email thread > > - Daniel > > On Oct 8, 2017, at 8:27 AM, Ján Kosa wrote: > > Hey guys, > > I have

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-08 Thread Ján Kosa via swift-users
Hey guys, I have been able to create simplest possible setup that exhibits this problem, the protobuf module wasn't necessary. All I import is PluginInterface and I get the error: objc[66212]: Class _TtC15PluginInterface15PluginInterface is implemented in both /Users/Lope/Dev/swift/SwiftPlugins/P

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-07 Thread Ján Kosa via swift-users
I was afraid it will come to that :) I will try to make something tonight, either it will help you fix it, or I will find out what I did wrong On 8 October 2017 at 09:49, Daniel Dunbar wrote: > Is it possible for you to make a small test package that shows the > problem, and file a bug in bugs.s

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-07 Thread Daniel Dunbar via swift-users
Is it possible for you to make a small test package that shows the problem, and file a bug in bugs.swift.org? There may be something we need to fix in SwiftPM before this can work (because of our linking model). - Daniel > On Oct 7, 2017, at 10:42 PM, Ján Kosa via swift-users > wrote: > > T

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-07 Thread Ján Kosa via swift-users
That is exactly what I did. The only package that depends on the protobuf is the PluginInterface. Both MyPlugin and and PluginConsumer depend on the PluginInterface and not on the protobuf itself. I had to shuffle around my dependencies a bit, which resulted in smaller number of dependencies but th

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-07 Thread Geordie Jay via swift-users
Ján Kosa schrieb am Sa. 7. Okt. 2017 um 15:27: > I tried to use @_exported and it helped somewhat. While I still have same > warnings, size of the PluginInterface library went down by 6mb (to 120kb) > so it looks like Protobuf is no longer statically linked to it. However, > size of PluginConsume

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-07 Thread Ján Kosa via swift-users
I tried to use @_exported and it helped somewhat. While I still have same warnings, size of the PluginInterface library went down by 6mb (to 120kb) so it looks like Protobuf is no longer statically linked to it. However, size of PluginConsumer executable went up by same 6mb, it looks like it is lin

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-07 Thread Geordie Jay via swift-users
Ján Kosa schrieb am Sa. 7. Okt. 2017 um 13:34: > I tried swift package clean, but it didn't help > > "Try to ensure the plugin provider module (libA) is (only) being compiled > into its standalone shared library file." > How do I go about this? It is 3rd party module, it doesn't define any > prod

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-07 Thread Ján Kosa via swift-users
I tried swift package clean, but it didn't help "Try to ensure the plugin provider module (libA) is (only) being compiled into its standalone shared library file." How do I go about this? It is 3rd party module, it doesn't define any products (https://github.com/apple/swift-protobuf.git). Is there

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-06 Thread Geordie Jay via swift-users
I think SwiftPM is (incorrectly) compiling A.XYZ into each of the modules that depend on it, as well as into your intended libA.so file. Try to ensure the plugin provider module (libA) is (only) being compiled into its standalone shared library file. Try cleaning the swiftpm build for one (swift p

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-06 Thread Ján Kosa via swift-users
It worked! Took me a while to iron out details, but it is working now. Huge thanks sir, I will name my firstborn after you. Thanks for the @_cdecl("initializePlugin") tip as well, I didn't know about it and it will be very useful. I am having slightly related problem now (it was there before, but

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-04 Thread Joe Groff via swift-users
> On Oct 4, 2017, at 11:02 AM, Ján Kosa via swift-users > wrote: > > Hello folks, > > I have been toying with dynamic libraries, trying to implement plugin > functionality. I was able to get to the point where I can call simple > function in loaded library, but I am having troubles starting

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-04 Thread Daniel Dunbar via swift-users
The way that I have done this in the past is pass a protocol as an unsafe pointer to an exposed entry point: ```swift let entryPoint = dlsym(handle, “initializePlugin”) guard entryPoint != nil else { fatalError("missing plugin entry point: \(pluginPath)")

[swift-users] Communicating with dynamically loaded swift library

2017-10-04 Thread Ján Kosa via swift-users
Hello folks, I have been toying with dynamic libraries, trying to implement plugin functionality. I was able to get to the point where I can call simple function in loaded library, but I am having troubles starting more sophisticated communication channel. There are 3 projects - PluginConsumer is