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

Fixing Swift 6 Compatibility on Linux Issues #107

Closed
wants to merge 3 commits into from

Conversation

leogdion
Copy link
Contributor

Motivation

Fixing Issues with Building in Swift 6 for Linux

Modifications

  • Make Static Variables nonisolated safe
  • Fix Issues with Upstream Iterator

Result

Compatability with Swift 6 on Linux

Test Plan

TBD

@leogdion leogdion changed the title Fixing Concurrency Issues Fixing Swift 6 Compatibility on Linux Issues Jun 20, 2024
Package.swift Outdated Show resolved Hide resolved
@sebsto
Copy link

sebsto commented Jun 20, 2024

Can we embed the nonisolated(unsafe) section with #if swift(>=6.0) to allow to continue to use Swift < 6.0 toolchains ?

@leogdion
Copy link
Contributor Author

@czechboy0 I'm not sure in the case URL or CharacterSet we can simply just apply Sendable to these types.

URL contains a reference to NSURL and URLBox which is not Sendable and I'm not sure would be easy to apply.
Same with CharacterSet and NSCharacterSet.

Let me if I'm missing something or looking at the wrong thing.

@czechboy0
Copy link
Contributor

@czechboy0 I'm not sure in the case URL or CharacterSet we can simply just apply Sendable to these types.

URL contains a reference to NSURL and URLBox which is not Sendable and I'm not sure would be easy to apply. Same with CharacterSet and NSCharacterSet.

Let me if I'm missing something or looking at the wrong thing.

Let me ask around about this. They are both Sendable on Darwin platforms, so if they're truly not on Linux, that'd require our code to account for the difference. But let's exhaust this path first.

@MahdiBM
Copy link
Contributor

MahdiBM commented Jun 20, 2024

corelibs-foundation's URL has been replaced with swift-foundation's.
I'd think that'll make it to Swift 6 but that's just my expectations.

It appears that swift-foundation has yet to implement CharacterSet and just falls back to the closed-source Darwin implementation for now, on Darwin.
Probably the best approach is the same as with URL: to implement CharacterSet in swift-foundation then replace corelibs-foundation's version with that. Though not sure if that's possible by Swift 6.

So we likely have to move on with some workarounds in OpenAPIRuntime for now, at least for CharacterSet.
I'd love to be proven wrong though.

@leogdion
Copy link
Contributor Author

Can we embed the nonisolated(unsafe) section with #if swift(>=6.0) to allow to continue to use Swift < 6.0 toolchains ?

Done.

@czechboy0
Copy link
Contributor

I chatted with the Foundation folks and let's wait a week or two, their WIP PRs should land and have this fixed (Sendability of these two types).

Please separate the async sequence changes into a separate PR, we can land those.

@leogdion
Copy link
Contributor Author

I chatted with the Foundation folks and let's wait a week or two, their WIP PRs should land and have this fixed (Sendability of these two types).

Please separate the async sequence changes into a separate PR, we can land those.

Done #108

Any thoughts on how to move forward in the meantime regarding building my app in Swift 6?

@czechboy0
Copy link
Contributor

Any thoughts on how to move forward in the meantime regarding building my app in Swift 6?

Yes, split out the generated code into a separate module/target, and use Swift 5 language mode on it. You can keep using Swift 6 in the rest of your codebase.

@czechboy0
Copy link
Contributor

czechboy0 commented Oct 3, 2024

Our current plan is to not move to Swift 6 language mode yet, as we support 3 latest released Swift compilers (5.9, 5.10, 6.0).

If there are any warnings/errors produced when building with the Swift 6 compiler in Swift 5 language mode, with strict concurrency flags enabled, please open a new PR fixing just those.

Apologies we didn't make this clear earlier, it took us a bit of time to figure out what our approach for libraries that need to support pre-6.0 compilers would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants