-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Simplify Swift SDK installation/selection with aliases #8703
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
base: main
Are you sure you want to change the base?
Conversation
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way this could be more data driven, so we don't have to change the toolchain every time there's a new Swift SDK? Or is this meant to be geared towards supporting just the Swift SDKs that are officially distributed by swift.org, and you need to do manual selection for others?
} else if let bundlePathOrURL { | ||
bundlePathOrURL | ||
} else { | ||
throw InternalError("foo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be changed to a real message before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree with @jakepetroules. I think we should explore more data-driven way for installation process by even changing the current distribution scheme. At least, SwiftPM should not know about the list of aliases.
@jakepetroules Can you elaborate on what you mean by "data driven"? As for changing the toolchain, we don't build Swift SDKs for older toolchains, so new Swift SDKs would require new toolchains either way.
Yes |
@kateinoigakukun Can you elaborate? How would it get the list of aliases otherwise? Any server-based solutions are out of scope for this change. We can only rely on changes to client-side tools distributed to users at this moment. Relying on external sources is not possible due to multiple reasons. |
I keep wondering whether we should really be fixing that problem, instead of trying to work around it (either with this PR or by giving people complicated instructions about matching them up). The fundamental issue here is that we aren't ABI stable, so we're relying on
I think I also agree with that sentiment. Could we perhaps have an option to specify the SDK by pointing at a JSON file that provides the required information to locate the actual SDK according to the current toolchain version? So, e.g. you'd write something like
or (to give a purely imaginary third-party example)
Then if the JSON data at the given URL doesn't contain a version matching the toolchain, we'd respond with something like
|
Making Swift ABI-stable on non-Darwin platforms is out of scope of this PR 🙂
@al45tair That's the problem, what would generate that JSON? As server-side solutions are out of scope (due to time constraints), we'd have to hardcode that JSON somewhere, either in SwiftPM or in the toolchain. Since SwiftPM is responsible for Swift SDK installation, hardcoding it in SwiftPM makes the most sense. And as we're already hardcoding it, JSON brings no benefits when compared to just writing this logic in plain Swift. |
@swift-ci test self hosted windows |
We'd hand-write it (initially — though it might in the longer term be automatically generated by the CI jobs) and put it on the web site (as opposed to in the source code for SwiftPM). So e.g. if you wrote
that would try to fetch the JSON file at e.g. |
As mentioned above, any server-side solutions are out of scope of this PR. We're looking for something very targeted and focused that can resolve the installation issues for user's in the short term. When a solution for hosting a Swift SDKs index on swift.org is available, I'd be very happy to implement it in a separate PR. |
What do you mean by "server-side solutions"? I think we can implement something what @al45tair suggested by putting static files like what we do in https://github.com/swiftwasm/swift-sdk-index or https://github.com/swiftlang/swift-org-website/blob/main/api/v1/install/dev/6.0/static-sdk.json, and it shouldn't require "server" process other than just a static HTTP server we already have on swift.org. I'm ok with hardcoding the SDK source URL locations and limiting the alias with known ones for now for time constraints, but I think we should at least define what it will be eventually to allow third-parties to provide their SDK index and we need to make sure we can implement it without changing CLI interface. |
I mean deploying payloads on any server, including a static server. This suggestion glosses over complexities of deployment on an arbitrary static server. What's very easy to set up in a GitHub organization with GitHub Actions can't be universally replicated in all scenarios. There's a lot of mechanics involved in keeping these payloads up-to-date, tying them to existing Swift CI jobs etc. That's definitely out of scope of this PR. When these deployment and CI issues are resolved, I'd very happy to come back and overhaul everything to be dynamically configurable, generalized, and clean, avoiding any hardcoding etc. But before that we need something that solves immediate problems that users already have been having for quite a long time. |
@swift-ci test self hosted windows |
@jakepetroules do you have any remaining objections here? This PR is purely for simplifying interactions with few existing Swift SDKs from swift.org. To summarize the conversion on this thread: I'd be super happy to make this configurable with some manifest hosted on swift.org website, but that has to be implemented by swift.org infrastructure team first and is out of scope of this PR. I still think hardcoding URL components for now is a significant improvement, while configurability remains an implementation detail that we can add later when necessary server-side components are ready. And to be extra-safe, this has an |
Motivation:
As Swift SDKs require host toolchain version to exactly match the version used to build a Swift SDK that's used, we need to automate Swift SDK installation and selection process. Proposed solution is for the users to rely on predefined aliases, that SwiftPM uses as inputs to compute the exact Swift SDK installation URL and selection ID. New CLI options are added, which in the future could be unified with existing CLI arguments and options for Swift SDKs.
Modifications:
Implemented for installation of Swift SDKs from swift.org:
For
swift build
,swift run
, andswift test
:This assumes
version.json
is available inusr/lib/swift
directory of the host toolchain, looking like thisInformation from this file is used to compute Swift SDK URLs and IDs.
Error messages are shown when either
version.json
is not found or an unknown alias is used.Result:
Users no longer need to find the exactly matching Swift SDK for the currently selected toolchain version.
Resolves rdar://150227998.