finagolfin / swift-android-sdk

Android SDKs for Swift
Apache License 2.0
152 stars 15 forks source link

Linking a dynamic library product with --static-swift-stdlib fails due to missing DispatchStubs #194

Open ephemer opened 1 week ago

ephemer commented 1 week ago

Hi @finagolfin, thanks a lot for implementing and building this as a Swift SDK. This is a big step forward!

I noticed when testing this just now that swift build --static-swift-stdlib appears to fail because DispatchStubs cannot be found. This library is linked from static/dispatch/module.modulemap in the case of a static stdlib build. And indeed, the DispatchStubs.a static library does exist. It's just that the linker appears to be searching for it in the wrong location. If I add swift build ... -Xlinker --verbose I can see that ldd is trying to link the .so dependencies (as well?). So there appears to be some internal confusion here.

For now, we cannot remove our dependency on Dispatch entirely, so I will continue to try without --static-swift-stdlib. But I would be interested to hear if you have an idea of why this is happening. Again, we're trying to build a .dynamic library product via swift build, but are hoping that its dependencies (including the swift stdlib) will be linked statically.

finagolfin commented 1 week ago

I'll take a look, thanks for reporting. I'm trying to get that flag working better with Swift 6, but there may still be some holes.