Skip to content

[Concurrency][Stdlib] Add SwiftStdlibCurrentOS availability, use it. #81440

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

al45tair
Copy link
Contributor

@al45tair al45tair commented May 12, 2025

If you use SwiftStdlibCurrentOS availability, you will be able to use new types and functions from within the implementation. This works by, when appropriate, building with the CurrentOS availability set to the current deployment target.

rdar://150944675

If you use SwiftStdlibCurrentOS availability, you will be able to
use new types and functions from within the implementation. This
works by, when appropriate, building with the CurrentOS availability
set to the current deployment target.

rdar://150944675
@al45tair al45tair force-pushed the currentos-availability branch from d36db74 to 28f96e6 Compare May 12, 2025 11:07
@al45tair
Copy link
Contributor Author

@swift-ci Please test

@stephentyrone
Copy link
Contributor

stephentyrone commented May 12, 2025

Love where this is going, but I think the names are more-or-less backwards; we shouldn't reference the "OS" for changes that are just new API additions in the stdlib at all. They should be "SwiftStdlib x.y," and the rare change that does depend on an outside OS feature should either reference the OS version, or reference the feature itself (Foundation does this).

This may make phasing adoption in slightly more complex however.

@@ -36,3 +36,26 @@ if(NOT SwiftCore_ARCH_SUBDIR)

message(CONFIGURE_LOG "Swift Arch: ${arch}")
endif()

if(NOT SwiftCore_SWIFT_AVAILABILITY_PLATFORM)
set(availability_platform_macosx "macOS")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love this bit. We're trying to get away from the hard-coded hand-maintained tables. I wonder if there is any way we could embed it into the existing availability macro file?
CC @compnerd, do you have any ideas?

Maybe this is something we can embed in cache files?

Copy link
Member

Choose a reason for hiding this comment

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

CPP to generate a response file would be my recommendation. I think that we were already doing that somewhere? (Perhaps the new build system?)

set(availability_platform_bridgeos "bridgeOS")

if(SwiftCore_SWIFT_MODULE_TRIPLE MATCHES ".*-([^-]+)-simulator$")
set(platform "${CMAKE_MATCH_1}")
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 you should be able to get this information from the platform entry in the target info without needing to regex it out of the module triple.

string(JSON platform GET "${target_info_json}" "target" "platform")

# ON will cause us to use the "proper" availability instead.
string(REPLACE "SwiftStdlib" "SwiftStdlibCurrentOS" current "${def}")
if(NOT SwiftCore_ENABLE_STRICT_AVAILABILITY AND SwiftCore_SWIFT_AVAILABILITY_PLATFORM)
string(REGEX MATCH "${SwiftCore_SWIFT_AVAILABILITY_PLATFORM} ([0-9]+(\.[0-9]+)+)" platform_version "${def}")
Copy link
Contributor

Choose a reason for hiding this comment

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

AvailabilityMacros.cmake is loaded before platform info, so SwiftCore_SWIFT_AVAILABILITY_PLATFORM won't be set by that here.

@al45tair
Copy link
Contributor Author

Love where this is going, but I think the names are more-or-less backwards

Agreed, but I didn't want to change the meaning of SwiftStdlib; for context, the reason I'm doing this now is that when we tell Swift what SwiftStdlib 6.2 is, a load of Concurrency things will break because Concurrency wants to use new things to implement other things, but that won't work on the CI machines (or in OSS) where the build system is a lower version than whatever SwiftStdlib 6.2 ends up being.

We could make changing the names a separate task, if someone comes up with something better.

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.

6 participants