Skip to content
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

SwiftSDKTool: convert previously blocking code to async #6623

Merged
merged 2 commits into from
Jun 14, 2023

Conversation

MaxDesiatov
Copy link
Contributor

We previously had to roll back these changes due to CI issues, this is another attempt to bring them back.

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

// This is quite ugly, but it works in terms of unambiguously specifying the async overload of `main()`.
_ = await { () async -> () in
await SwiftSDKTool.main()
}()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant we make this into a struct with a @main instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had it previously in Sources/swift-experimental-sdk/SwiftSDKTool.swift, which you can see removed in the diff right above this file, but that required duplicating SwiftSDKTool from SwiftSDKTool module verbatim, which I think is much worse than this. Unfortunately, @main can't be added to a type declared in a different module.

Copy link
Contributor

@tomerd tomerd Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not define a private "Runner" struct with @main that calls the underlying static main as the closure does?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great point, addressed now.

@@ -22,14 +22,14 @@ let execName = (try? AbsolutePath(validating: firstArg).basenameWithoutExt) ??

@main
struct SwiftPM {
static func main() {
static func main() async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we had trouble with this change in the past, are we out of the wood on that now?

cc @neonichu

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR those were CI issues, but I don't see them reproduced now and this passes tests and runs well locally. I don't plan to cherry-pick this to 5.9, so we'll have enough time to investigate anything that could potentially go wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows is another question, I think? Supposedly async doesn't really work well there IIRC. cc @compnerd

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also check the toolchain CI, ie try to create a toolchain with this PR, I remember we had SwiftPM green but it caused downstream issues. in any case, I think we should not merge this in the immediate timeframe to avoid 🔥 in a sensitive time

Copy link
Contributor Author

@MaxDesiatov MaxDesiatov Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be ok to merge now? I only need a review approval for that.

@MaxDesiatov MaxDesiatov marked this pull request as ready for review May 26, 2023 17:04
@MaxDesiatov MaxDesiatov requested a review from compnerd May 26, 2023 17:14
@MaxDesiatov MaxDesiatov requested a review from tomerd June 12, 2023 22:04
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows

@MaxDesiatov MaxDesiatov merged commit fa042e3 into main Jun 14, 2023
@MaxDesiatov MaxDesiatov deleted the maxd/async-swift-sdk branch June 14, 2023 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants