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

Switch up compiler directives for concurrency #111

Merged
merged 4 commits into from
Sep 22, 2021
Merged

Switch up compiler directives for concurrency #111

merged 4 commits into from
Sep 22, 2021

Conversation

joshuawright11
Copy link
Contributor

This may be misguided, see comments in #110

@swift-server-bot
Copy link

Can one of the admins verify this patch?

7 similar comments
@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@tomerd
Copy link
Contributor

tomerd commented Sep 21, 2021

@swift-server-bot test this please

@tomerd
Copy link
Contributor

tomerd commented Sep 21, 2021

@ktoso is this the right approach?

@joshuawright11
Copy link
Contributor Author

Seeing as CI is failing, I assume the tests are all running on an OS where _Concurrency is available. Added compiler(>=5.5) to the conditionals.

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

This is partially correct.

  • We should remove any mention of import _Concurrency at all; completely. This module is imported automatically when it exists. It should not be imported explicitly - it just adds more noise to the project.

  • The #if guard IS correct though for guarding any code actually using async/Concurrency, we can't just detect the swift version but have to guard with the concurrency import availability as well.

Would you mind changing the PR to remove the imports? Then it's LGTM :)

@adam-fowler
Copy link
Member

Once Monterey is out should we still be checking for existence of _Concurrency. Is this a temporary fix until that point?

@ktoso
Copy link
Contributor

ktoso commented Sep 21, 2021

For now assume it'll be around.

@joshuawright11
Copy link
Contributor Author

joshuawright11 commented Sep 22, 2021

Great, thanks @ktoso. Updated.

@ktoso
Copy link
Contributor

ktoso commented Sep 22, 2021

@swift-server-bot test this please

@tomerd
Copy link
Contributor

tomerd commented Sep 22, 2021

thanks for the PR @joshuawright11, something does not seem to be correct with the conditions give the CI failures in > 5.2 < 5.5 version. have not tried to compile this but perhaps replace

         #if compiler(<5.2)
         return
         #elseif compiler(<5.5) || !canImport(_Concurrency)
         throw XCTSkip()
         #else
         guard #available(macOS 12.0, *) else {
            throw XCTSkip()
         }

with

         #if compiler(<5.2)
         return
         #elseif compiler(<5.5)
         throw XCTSkip()
         #else
         guard #canImport(_Concurrency) else {
            throw XCTSkip()
         }
         guard #available(macOS 12.0, *) else {
            throw XCTSkip()
         }

@ktoso
Copy link
Contributor

ktoso commented Sep 22, 2021

Something is indeed weird here... I was checking with the compiler team if these are the guards we should use and we think those are right 🤔

@tomerd
Copy link
Contributor

tomerd commented Sep 22, 2021

I had trouble composing them in the past, hence the guards

@joshuawright11
Copy link
Contributor Author

Yeah it does seem like something odd is going on, I poked around with the complex #if statements on my machine and it worked fine; though my machine is also 5.5 so perhaps it's an issue with older swift versions.

Alas, guard #canImport(_Concurrency) gave an error: use of unknown directive '#canImport, so I split up the if statement further to:

#if compiler(<5.2)
return
#elseif compiler(<5.5)
throw XCTSkip()
#elseif !canImport(_Concurrency)
throw XCTSkip()
#else
...
#endif

Let's see if it likes that.

@tomerd
Copy link
Contributor

tomerd commented Sep 22, 2021

@swift-server-bot test this please

@tomerd
Copy link
Contributor

tomerd commented Sep 22, 2021

Yeah it does seem like something odd is going on, I poked around with the complex #if statements on my machine and it worked fine; though my machine is also 5.5 so perhaps it's an issue with older swift versions.

fyi you can run the tests we run in CI locally using docker, see the docker-compose files

@tomerd
Copy link
Contributor

tomerd commented Sep 22, 2021

nightly CI failure expected due to @sendable changes

@tomerd tomerd merged commit cea89ce into swift-server:main Sep 22, 2021
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.

5 participants