-
Notifications
You must be signed in to change notification settings - Fork 18
Add new options that control whether host toolchain is included #165
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
Add new options that control whether host toolchain is included #165
Conversation
- So we end up with no swift.xctoolchain so that the toolchain installed on the host is used instead.
- Also don't download host LLVM if excluding host toolchain
- This way since 5.9 and 5.10 require the supportedTriples in info.json, they will still work, and all supported host versions of Swift can compile for the SDK.
Update: since both 5.9 and 5.10 require the "supportedTriples" : [
"x86_64-unknown-linux-gnu",
"aarch64-unknown-linux-gnu",
"x86_64-apple-macos",
"arm64-apple-macos"
], Then, either Linux x86_64/aarch64 or macOS x86_64/arm64 hosts can cross compile with the SDK. Since the SDK doesn't contain the Swift toolchain, though, the open source Swift toolchain is required to be used on macOS for it to compile. I think this is also the case with the Linux Static SDK. @euanh @MaxDesiatov please have a look here and see what you think! |
--no-host-toolchain
flag that generates an SDK without the host Swift toolchainThere 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.
Phrasing nit: we should not call these "SDK", but use "Swift SDK" wording instead, since these terms are separate from each other. In the Swift context, plain "SDK" is an Xcode-specific term, where its Darwin SDKs have a distinct file system layout that Xcode build system can consume. "Swift SDK" is a SwiftPM feature, unrelated to plain "SDK"s for Darwin. These are different features in different products and are not interchangeable with each other.
It's unfortunate though that swift.org website doesn't make this distinction, but that would have to be resolved with swift.org website maintainers.
- Pass --no-host-include-toolchain to build the Swift SDK without the host toolchain.
…nd 5.10 - Both of these versions require supportedTriples to be set and populated, but 6.0 and later can simply exclude the field for supporting all hosts.
Yes please, that would be much appreciated. |
- Instead set rootPath to nil in Toolset if toolchain is preinstalled.
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.
Thanks!
@MaxDesiatov I added tests that check the following pieces of functionality in
I did not add tests for all of the functionality of |
@swift-ci test |
@@ -27,7 +27,6 @@ extension SwiftSDKGenerator { | |||
let toolsetJSONPath = pathsConfiguration.swiftSDKRootPath.appending("toolset.json") | |||
|
|||
var relativeToolchainBinDir = pathsConfiguration.toolchainBinDirPath | |||
|
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.
nit: unnecessary newline that only adds to the diff as an unrelated change
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.
Fixed!
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.
LGTM modulo a super minor formatting nit
@swift-ci test |
All good to merge since everything's in there? |
I wonder if @euanh would have any feedback, since he contributed to the Linux generator a lot recently and also enabled e2e tests for it? |
I've run the EndToEnd tests. They didn't find any regressions (they take a while):
|
but requires exactly the same version of the swift.org toolchain to be installed for it to work. | ||
""" | ||
) | ||
var includeHostToolchain: Bool = true |
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.
Sorry about a request coming this late, just noticed that --no-include-host-toolchain
reads quite weird to me? Although I'm not a native English speaker, so take this concern with a grain of salt. If you agree that --no-host-toolchain
reads better, let's use that shorter wording and I'm ready to merge immediately after that.
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.
Yes, --no-host-toolchain
sounds better.
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.
Done:
--host-toolchain/--no-host-toolchain
Whether or not to include the host toolchain in the Swift SDK.
If the host toolchain is not included, this makes the Swift SDK compatible with any host, but requires exactly the same version of the
swift.org toolchain to be installed for it to work. (default: --host-toolchain)
@swift-ci test |
I'm fully prepared for this to be torn apart, but this is hopefully a good "first PR" for this configuration. @euanh @MaxDesiatov
This adds a new
--no-include-host-toolchain
flag to themake-linux-sdk
sub-command, making it possible to generate an SDK for x86_64 or aarch64 with only the target sysroot and Swift libraries, like this:I tested the generated SDKs on both Ubuntu 22.04 and macOS 15 and they work just fine.
Ubuntu x86_64 -> aarch64:
macOS arm64 -> x86_64:
Also, is there a need/desire to add some unit testing for this flag?