-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic library support on Linux with library evolution #5714
Comments
I think this couples a lot of different topics together that should be separate:
Only the first one is really needed for the main topic of this particular issue, right? |
Hi Boris, Thanks for trying to split this up,
Yes, that's the biggest issue.
Agree, that's just fine I think - one can have two conditionalized dependencies (thanks to
Well, in Xcode there's
Well, after googling a bit it seems one could use e.g. swift-create-xcframework, but it would be desirable that the same SwiftPM package could be used to generate a dynamic library that is able to be packaged for multiple platforms (even if that packaging might differ) - we don't have any Xcode projects for any of our code, we just only use SwiftPM (as we want portability).
I think the other two would be needed as well to be able to build versioned resilient libraries? |
Right, there is no equivalent to Non-Darwin platforms do not currently offer ABI stability for Swift, so you can just use a regular release build for those. |
We’d like to use that on Linux too - according to the blog post linked above it should be possible to use library evolution mode on Linux too if matching tool chains :
We are fine enforcing identical compiler versions on Linux, yet we’d like to use stable module interfaces and evolution to allow for selectively upgrading shared libraries. We’ll always ensure the same tool chain versions are used by our customers. |
(So the need to pass that on Linux remains even if it’s useful to know about the Xcodebuild workaround on macOS, thanks) |
Ah interesting, I wasn't aware of that. Yes, I guess that means we'll want to support it. You can try directly passing the compiler flags via |
Hmmm. I'm starting playing with it to see what can be done (on macOS to start) and adding a couple of unsafe flags
actually gave me a
Then trying to build a client of this library failed:
It seems SwiftPM is too smart and will statically link when there's a local dependency even when the product
I'll see if I can wrap it as a binary dependency (XCFramework) instead and if that makes a difference. |
I wrapped it as an xcframework and that works - but only in Xcode - not from the command line - details here for anyone interested. |
Another question came up now when I played with this a bit more when validating your fix for the XCFramework search paths. It seems SwiftPM copies the binary target dependencies (shared library) to the build directory and use it from there - I tested it on Linux (did a simple POC by enabling .xcframework in my local toolchain for linux and handcrafted a Linux .xcframework just for validation) and could see this when checking what was actually dynamically loaded:
I could see in the build log that the first thing done was copying the
To me this is related to have the full support for library evolution using shared libraries, but maybe that should be broken out as a separate case from supporting the binaryTarget (both are needed to reach the end goal though, to be able to build shared libraries that use library evolution support and that can be shared across multiple consumer of the library - just as for system framework from Apple) |
Description
Background
We have an enterprise-style application where we have a large number of libraries (swift packages) that we'd like to be able to evolve independently using library evolution and to dynamically link them to a large number of consumers.
Basically adding binary dependency support to a dynamic library generated using SPM similar to XCFrameworks.
I've read https://github.com/apple/swift-evolution/blob/main/proposals/0305-swiftpm-binary-target-improvements.md and would like to suggest a first step could be to cater to this kind of 'enterprise' deployment scenario rather than taking on the full 'many linuxes support everywhere' - we have full control over deployment operating system and swift toolchain (we can mandate for our customers what they must have to run the software and would do builds for a small number of deployment environments that we support).
The artefact bundle format seems that it would suffice for such a scenario.
So trying to break down what's needed (perhaps missing something):
artifactbundle
format so we can have both macOS and Linux in a single dependency if putting things in the right places)I think this single-linux-distribution as a first step could be very useful not only for us, but also for others - and help as a stopgap deployment measure.
See also related discussions / issues:
swiftlang/swift#60458
https://forums.swift.org/t/use-a-dynamic-library-in-a-swift-package-on-linux/59510
https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341/3
etc.
Also recently added:
swiftlang/swift#66156
Expected behavior
No response
Actual behavior
No response
Steps to reproduce
No response
Swift Package Manager version/commit hash
No response
Swift & OS version (output of
swift --version && uname -a
)No response
The text was updated successfully, but these errors were encountered: