Skip to content

Commit d5ed335

Browse files
authored
Merge pull request #81440 from al45tair/currentos-availability
[Concurrency][Stdlib] Add SwiftStdlibCurrentOS availability, use it.
2 parents adedf15 + 467f401 commit d5ed335

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+480
-267
lines changed

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ option(SWIFT_STDLIB_ASSERTIONS
464464
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
465465
"${SWIFT_STDLIB_ASSERTIONS_default}")
466466

467+
option(SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY
468+
"Enable strict availability; this will cause things to break at desk or in CI if the host OS is a lower version than some `@availability` annotations in the runtime code"
469+
FALSE)
470+
467471
option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
468472
"Use the host compiler and not the internal clang to build the swift runtime"
469473
FALSE)
@@ -1406,8 +1410,9 @@ endif()
14061410

14071411
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
14081412
message(STATUS "Building Swift standard library and overlays for SDKs: ${SWIFT_SDKS}")
1409-
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
1410-
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
1413+
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
1414+
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
1415+
message(STATUS " Strict availability: ${SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY}")
14111416
message(STATUS "")
14121417

14131418
message(STATUS "Building Swift runtime with:")

Runtimes/Core/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ set(SwiftCore_VENDOR_MODULE_DIR "${SwiftCore_CMAKE_MODULES_DIR}/vendor"
7878
include(GNUInstallDirs)
7979
include(CheckSymbolExists)
8080
include(CheckIncludeFileCXX)
81-
include(AvailabilityMacros)
8281
include(CompilerSettings)
8382
include(DefaultSettings)
8483
include(EmitSwiftInterface)
@@ -87,6 +86,7 @@ include(PlatformInfo)
8786
include(gyb)
8887
include(ResourceEmbedding)
8988
include(CatalystSupport)
89+
include(AvailabilityMacros)
9090

9191
check_symbol_exists("asl_log" "asl.h" SwiftCore_HAS_ASL)
9292
check_symbol_exists("dladdr" "dlfcn.h" SwiftCore_HAS_DLADDR)
@@ -126,6 +126,7 @@ defaulted_option(SwiftCore_ENABLE_BACKTRACING "Enable backtracing runtime suppor
126126
defaulted_set(SwiftCore_BACKTRACER_PATH STRING "Set a fixed path to the Swift backtracer")
127127
defaulted_option(SwiftCore_ENABLE_FATALERROR_BACKTRACE "Build stdlib fatalError with backtrace output")
128128
defaulted_option(SwiftCore_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization")
129+
defaulted_option(SwiftCore_ENABLE_STRICT_AVAILABILITY "Enable strict availability; this will cause things to break at desk or in CI if the host OS is a lower version than some `@availability` annotations in the runtime code")
129130

130131
option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" OFF)
131132
option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" OFF)

Runtimes/Core/cmake/caches/Vendors/Apple/apple-common.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ set(SwiftCore_ENABLE_VECTOR_TYPES ON CACHE BOOL "")
1212
set(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS ON CACHE BOOL "")
1313
set(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT ON CACHE BOOL "")
1414
set(SwiftCore_ENABLE_FILESYSTEM_SUPPORT ON CACHE BOOL "")
15+
set(SwiftCore_ENABLE_STRICT_AVAILABILITY ON CACHE BOOL "")
16+
1517
set(SwiftCore_OPTIMIZATION_REMARKS "bitstream" CACHE STRING "")
1618

1719
set(SwiftCore_INSTALL_NESTED_SUBDIR OFF CACHE BOOL "")

Runtimes/Core/cmake/modules/AvailabilityMacros.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,32 @@ file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/availability-macros.def" availability_
55
list(FILTER availability_defs EXCLUDE REGEX "^\\s*(#.*)?$")
66
foreach(def ${availability_defs})
77
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${def}\">")
8+
9+
if("${def}" MATCHES "SwiftStdlib .*")
10+
# For each SwiftStdlib x.y, also define SwiftStdlibCurrentOS x.y, which,
11+
# will expand to the current `-target` platform if the macro defines a
12+
# newer platform as its availability.
13+
#
14+
# There is a setting, SwiftCore_ENABLE_STRICT_AVAILABILITY, which if set
15+
# ON will cause us to use the "proper" availability instead.
16+
string(REPLACE "SwiftStdlib" "SwiftStdlibCurrentOS" current "${def}")
17+
if(NOT SwiftCore_ENABLE_STRICT_AVAILABILITY AND SwiftCore_SWIFT_AVAILABILITY_PLATFORM)
18+
if("${SwiftCore_SWIFT_AVAILABILITY_PLATFORM}" STREQUAL "macOS" AND "${SwiftCore_VARIANT_AVAILABILITY_PLATFORM}" STREQUAL "iOS")
19+
string(REGEX MATCH "iOS ([0-9]+(\.[0-9]+)+)" ios_platform_version "${def}")
20+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" ios_version "${ios_platform_version}")
21+
string(REGEX MATCH "macOS ([0-9]+(\.[0-9]+)+)" macos_platform_version "${def}")
22+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" macos_version "${macos_platform_version}")
23+
if((NOT macos_version STREQUAL "9999" OR NOT ios_version STREQUAL "9999") AND (macos_version VERSION_GREATER CMAKE_OSX_DEPLOYMENT_TARGET OR ios_version VERSION_GREATER SwiftCore_VARIANT_DEPLOYMENT_VERSION))
24+
string(REGEX REPLACE ":.*" ": macOS ${CMAKE_OSX_DEPLOYMENT_VERSION}, iOS ${SwiftCore_VARIANT_DEPLOYMENT_VERSION}" current "${current}")
25+
endif()
26+
else()
27+
string(REGEX MATCH "${SwiftCore_SWIFT_AVAILABILITY_PLATFORM} ([0-9]+(\.[0-9]+)+)" platform_version "${def}")
28+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" version "${platform_version}")
29+
if(NOT version STREQUAL "9999" AND version VERSION_GREATER CMAKE_OSX_DEPLOYMENT_TARGET)
30+
string(REGEX REPLACE ":.*" ":${SwiftCore_SWIFT_AVAILABILITY_PLATFORM} ${CMAKE_OSX_DEPLOYMENT_TARGET}" current "${current}")
31+
endif()
32+
endif()
33+
endif()
34+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${current}\">")
35+
endif()
836
endforeach()

Runtimes/Core/cmake/modules/CatalystSupport.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,12 @@ if(SwiftCore_COMPILER_VARIANT_TARGET)
3434
set(SwiftCore_VARIANT_MODULE_TRIPLE "${module_triple}" CACHE STRING "Triple used for installed swift{module,interface} files for the target variant")
3535
mark_as_advanced(SwiftCore_VARIANT_MODULE_TRIPLE)
3636
message(CONFIGURE_LOG "Swift target variant module triple: ${module_triple}")
37+
38+
string(JSON triple GET "${target_info_json}" "target" "triple")
39+
if(triple MATCHES "apple-([a-zA-Z]+)([0-9]+[.0-9]*)-macabi")
40+
set(SwiftCore_VARIANT_DEPLOYMENT_VERSION "${CMAKE_MATCH_2}")
41+
mark_as_advanced(SwiftCore_VARIANT_DEPLOYMENT_VERSION)
42+
message(CONFIGURE_LOG "Swift target variant deployment version: ${SwiftCore_VARIANT_DEPLOYMENT_VERSION}")
43+
endif()
3744
endif()
3845
endif()

Runtimes/Core/cmake/modules/DefaultSettings.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ set(SwiftCore_ENABLE_BACKTRACING_default OFF) # TODO: enable this by default
1010
set(SwiftCore_ENABLE_STDIN_default ON)
1111
set(SwiftCore_ENABLE_TYPE_PRINTING_default ON)
1212

13+
set(SwiftCore_ENABLE_STRICT_AVAILABILITY_default OFF)
14+
1315
set(SwiftCore_BACKTRACER_PATH_default "")
1416

1517
# Provide a boolean option that a user can optionally enable.
@@ -19,7 +21,7 @@ macro(defaulted_option variable helptext)
1921
if(NOT DEFINED ${variable}_default)
2022
set(${variable}_default OFF)
2123
endif()
22-
option(${variable} ${helptext} ${${variable}_default})
24+
option(${variable} "${helptext}" ${${variable}_default})
2325
endmacro()
2426

2527
# Create a defaulted cache entry

Runtimes/Core/cmake/modules/PlatformInfo.cmake

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,47 @@ if(NOT SwiftCore_ARCH_SUBDIR)
3636

3737
message(CONFIGURE_LOG "Swift Arch: ${arch}")
3838
endif()
39+
40+
# Note: *moduleTriple* doesn't have an "x" on the end of "macos"; just to be
41+
# safe, we support both cases here.
42+
set(availability_platform_macos "macOS")
43+
set(availaiblity_platform_macosx "macOS")
44+
set(availability_platform_ios "iOS")
45+
set(availability_platform_watchos "watchOS")
46+
set(availability_platform_tvos "tvOS")
47+
set(availability_platform_xros "visionOS")
48+
set(availability_platform_bridgeos "bridgeOS")
49+
50+
if(NOT SwiftCore_SWIFT_AVAILABILITY_PLATFORM)
51+
if(SwiftCore_MODULE_TRIPLE MATCHES ".*-([^-]+)-simulator$")
52+
set(platform "${CMAKE_MATCH_1}")
53+
elseif(SwiftCore_MODULE_TRIPLE MATCHES ".*-([^-]+)-msvc$")
54+
set(platform "${CMAKE_MATCH_1}")
55+
elseif(SwiftCore_MODULE_TRIPLE MATCHES ".*-([^-]+)$")
56+
set(platform "${CMAKE_MATCH_1}")
57+
else()
58+
message(WARNING "Unable to extract platform name from triple ${SwiftCore_MODULE_TRIPLE}")
59+
endif()
60+
61+
if(availability_platform_${platform})
62+
set(SwiftCore_SWIFT_AVAILABILITY_PLATFORM "${availability_platform_${platform}}")
63+
else()
64+
set(SwiftCore_SWIFT_AVAILABILITY_PLATFORM "unknown")
65+
message(WARNING "Unknown platform ${platform} for availability")
66+
endif()
67+
endif()
68+
69+
set(SwiftCore_VARIANT_AVAILABILITY_PLATFORM "none")
70+
if(SwiftCore_VARIANT_MODULE_TRIPLE)
71+
if(SwiftCore_VARIANT_MODULE_TRIPLE MATCHES ".*-([^-]+)$")
72+
set(platform "${CMAKE_MATCH_1}")
73+
else()
74+
message(FATAL_ERROR "Unable to extract platform name from triple ${SwiftCore_VARIANT_MODULE_TRIPLE}")
75+
endif()
76+
77+
if(availability_platform_${platform})
78+
set(SwiftCore_VARIANT_AVAILABILITY_PLATFORM "${availability_platform_${platform}}")
79+
else()
80+
message(WARNING "Unknown platform ${platform} for variant availability")
81+
endif()
82+
endif()

cmake/modules/DarwinSDKs.cmake

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ is_sdk_requested(OSX swift_build_osx)
1212
if(swift_build_osx)
1313
configure_sdk_darwin(
1414
OSX "OS X" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX}"
15-
macosx macosx macos "${SUPPORTED_OSX_ARCHS}")
15+
macosx macosx macos macOS "${SUPPORTED_OSX_ARCHS}")
1616
configure_target_variant(OSX-DA "OS X Debug+Asserts" OSX DA "Debug+Asserts")
1717
configure_target_variant(OSX-RA "OS X Release+Asserts" OSX RA "Release+Asserts")
1818
configure_target_variant(OSX-R "OS X Release" OSX R "Release")
@@ -26,12 +26,15 @@ if(swift_build_freestanding AND (SWIFT_FREESTANDING_FLAVOR STREQUAL "apple"))
2626
"Which triple name (e.g. 'none-macho') to use when building the FREESTANDING stdlib")
2727
set(SWIFT_FREESTANDING_MODULE_NAME "" CACHE STRING
2828
"Which .swiftmodule name (e.g. 'freestanding') to use when building the FREESTANDING stdlib")
29+
set(SWIFT_FREESTANDING_AVAILABILITY_NAME "" CACHE STRING
30+
"Which @availability name (e.g. 'macOS') to use when building the FREESTANDING stdlib")
2931
set(SWIFT_FREESTANDING_ARCHS "" CACHE STRING
3032
"Which architectures to build when building the FREESTANDING stdlib")
3133
configure_sdk_darwin(
3234
FREESTANDING "FREESTANDING" ""
3335
"${SWIFT_FREESTANDING_SDK}"
34-
"${SWIFT_FREESTANDING_TRIPLE_NAME}" "${SWIFT_FREESTANDING_MODULE_NAME}" "${SWIFT_FREESTANDING_ARCHS}")
36+
"${SWIFT_FREESTANDING_TRIPLE_NAME}" "${SWIFT_FREESTANDING_MODULE_NAME}"
37+
"${SWIFT_FREESTANDING_AVAILABILITY_NAME}" "${SWIFT_FREESTANDING_ARCHS}")
3538
set(SWIFT_SDK_FREESTANDING_LIB_SUBDIR "freestanding")
3639
configure_target_variant(FREESTANDING-DA "FREESTANDING Debug+Asserts" FREESTANDING DA "Debug+Asserts")
3740
configure_target_variant(FREESTANDING-RA "FREESTANDING Release+Asserts" FREESTANDING RA "Release+Asserts")
@@ -49,7 +52,7 @@ is_sdk_requested(IOS swift_build_ios)
4952
if(swift_build_ios)
5053
configure_sdk_darwin(
5154
IOS "iOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
52-
iphoneos ios ios "${SUPPORTED_IOS_ARCHS}")
55+
iphoneos ios ios iOS "${SUPPORTED_IOS_ARCHS}")
5356
configure_target_variant(IOS-DA "iOS Debug+Asserts" IOS DA "Debug+Asserts")
5457
configure_target_variant(IOS-RA "iOS Release+Asserts" IOS RA "Release+Asserts")
5558
configure_target_variant(IOS-R "iOS Release" IOS R "Release")
@@ -59,7 +62,7 @@ is_sdk_requested(IOS_SIMULATOR swift_build_ios_simulator)
5962
if(swift_build_ios_simulator)
6063
configure_sdk_darwin(
6164
IOS_SIMULATOR "iOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
62-
iphonesimulator ios ios-simulator
65+
iphonesimulator ios ios-simulator iOS
6366
"${SUPPORTED_IOS_SIMULATOR_ARCHS}")
6467
configure_target_variant(
6568
IOS_SIMULATOR-DA "iOS Debug+Asserts" IOS_SIMULATOR DA "Debug+Asserts")
@@ -73,7 +76,7 @@ is_sdk_requested(TVOS swift_build_tvos)
7376
if(swift_build_tvos)
7477
configure_sdk_darwin(
7578
TVOS "tvOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
76-
appletvos tvos tvos "${SUPPORTED_TVOS_ARCHS}")
79+
appletvos tvos tvos tvOS "${SUPPORTED_TVOS_ARCHS}")
7780
configure_target_variant(TVOS-DA "tvOS Debug+Asserts" TVOS DA "Debug+Asserts")
7881
configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts")
7982
configure_target_variant(TVOS-R "tvOS Release" TVOS R "Release")
@@ -83,7 +86,7 @@ is_sdk_requested(TVOS_SIMULATOR swift_build_tvos_simulator)
8386
if(swift_build_tvos_simulator)
8487
configure_sdk_darwin(
8588
TVOS_SIMULATOR "tvOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
86-
appletvsimulator tvos tvos-simulator
89+
appletvsimulator tvos tvos-simulator tvOS
8790
"${SUPPORTED_TVOS_SIMULATOR_ARCHS}")
8891
configure_target_variant(
8992
TVOS_SIMULATOR-DA "tvOS Debug+Asserts" TVOS_SIMULATOR DA "Debug+Asserts")
@@ -97,7 +100,7 @@ is_sdk_requested(WATCHOS swift_build_watchos)
97100
if(swift_build_watchos)
98101
configure_sdk_darwin(
99102
WATCHOS "watchOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
100-
watchos watchos watchos "${SUPPORTED_WATCHOS_ARCHS}")
103+
watchos watchos watchos watchOS "${SUPPORTED_WATCHOS_ARCHS}")
101104
configure_target_variant(WATCHOS-DA "watchOS Debug+Asserts" WATCHOS DA "Debug+Asserts")
102105
configure_target_variant(WATCHOS-RA "watchOS Release+Asserts" WATCHOS RA "Release+Asserts")
103106
configure_target_variant(WATCHOS-R "watchOS Release" WATCHOS R "Release")
@@ -107,7 +110,7 @@ is_sdk_requested(WATCHOS_SIMULATOR swift_build_watchos_simulator)
107110
if(swift_build_watchos_simulator)
108111
configure_sdk_darwin(
109112
WATCHOS_SIMULATOR "watchOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
110-
watchsimulator watchos watchos-simulator
113+
watchsimulator watchos watchos-simulator watchOS
111114
"${SUPPORTED_WATCHOS_SIMULATOR_ARCHS}")
112115
configure_target_variant(WATCHOS_SIMULATOR-DA "watchOS Debug+Asserts" WATCHOS_SIMULATOR DA "Debug+Asserts")
113116
configure_target_variant(WATCHOS_SIMULATOR-RA "watchOS Release+Asserts" WATCHOS_SIMULATOR RA "Release+Asserts")
@@ -118,7 +121,7 @@ is_sdk_requested(XROS swift_build_xros)
118121
if(swift_build_xros)
119122
configure_sdk_darwin(
120123
XROS "xrOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}"
121-
xros xros xros "${SUPPORTED_XROS_ARCHS}")
124+
xros xros xros visionOS "${SUPPORTED_XROS_ARCHS}")
122125
configure_target_variant(XROS-DA "xrOS Debug+Asserts" XROS DA "Debug+Asserts")
123126
configure_target_variant(XROS-RA "xrOS Release+Asserts" XROS RA "Release+Asserts")
124127
configure_target_variant(XROS-R "xrOS Release" XROS R "Release")
@@ -128,7 +131,7 @@ is_sdk_requested(XROS_SIMULATOR swift_build_xros_simulator)
128131
if(swift_build_xros_simulator)
129132
configure_sdk_darwin(
130133
XROS_SIMULATOR "xrOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}"
131-
xrsimulator xros xros-simulator
134+
xrsimulator xros xros-simulator visionOS
132135
"${SUPPORTED_XROS_SIMULATOR_ARCHS}")
133136

134137
configure_target_variant(

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ endfunction()
136136
# deployment_version # Deployment version
137137
# xcrun_name # SDK name to use with xcrun
138138
# triple_name # The name used in Swift's -triple
139+
# availability_name # The name used in Swift's @availability
139140
# architectures # A list of architectures this SDK supports
140141
# )
141142
#
@@ -165,9 +166,11 @@ endfunction()
165166
# SWIFT_SDK_${prefix}_ARCH_${ARCH}_TRIPLE Triple name
166167
# SWIFT_SDK_${prefix}_ARCH_${ARCH}_MODULE Module triple name for this SDK
167168
# SWIFT_SDK_${prefix}_USE_BUILD_ID Whether to pass --build-id to the linker
169+
# SWIFT_SDK_${prefix}_AVAILABILITY_NAME Name to use in @availability
170+
#
168171
macro(configure_sdk_darwin
169172
prefix name deployment_version xcrun_name
170-
triple_name module_name architectures)
173+
triple_name module_name availability_name architectures)
171174
# Note: this has to be implemented as a macro because it sets global
172175
# variables.
173176

@@ -201,6 +204,7 @@ macro(configure_sdk_darwin
201204
set(SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION "${deployment_version}")
202205
set(SWIFT_SDK_${prefix}_LIB_SUBDIR "${xcrun_name}")
203206
set(SWIFT_SDK_${prefix}_TRIPLE_NAME "${triple_name}")
207+
set(SWIFT_SDK_${prefix}_AVAILABILITY_NAME "${availability_name}")
204208
set(SWIFT_SDK_${prefix}_OBJECT_FORMAT "MACHO")
205209
set(SWIFT_SDK_${prefix}_USE_ISYSROOT TRUE)
206210
set(SWIFT_SDK_${prefix}_SHARED_LIBRARY_PREFIX "lib")

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,41 @@ function(add_swift_target_library_single target name)
10031003
# Define availability macros.
10041004
foreach(def ${SWIFT_STDLIB_AVAILABILITY_DEFINITIONS})
10051005
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-Xfrontend" "-define-availability" "-Xfrontend" "${def}")
1006+
1007+
if("${def}" MATCHES "SwiftStdlib .*")
1008+
# For each SwiftStdlib x.y, also define SwiftStdlibCurrentOS x.y, which,
1009+
# will expand to the current `-target` platform if the macro defines a
1010+
# newer platform as its availability.
1011+
#
1012+
# There is a setting, SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY, which if set
1013+
# ON will cause us to use the "proper" availability instead.
1014+
string(REPLACE "SwiftStdlib" "SwiftStdlibCurrentOS" current "${def}")
1015+
if(NOT SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY AND SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_AVAILABILITY_NAME)
1016+
if(SWIFTLIB_SINGLE_SDK STREQUAL "OSX" AND SWIFTLIB_SINGLE_MACCATALYST_BUILD_FLAVOR STREQUAL "ios-like")
1017+
string(REGEX MATCH "iOS ([0-9]+(\.[0-9]+)+)" platform_version "${def}")
1018+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" version "${platform_version}")
1019+
if(NOT version STREQUAL "9999" AND version VERSION_GREATER "${SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST}")
1020+
string(REGEX REPLACE ":.*" ":iOS ${SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST}" current "${current}")
1021+
endif()
1022+
elseif(SWIFTLIB_SINGLE_SDK STREQUAL "OSX" AND SWIFTLIB_SINGLE_MACCATALYST_BUILD_FLAVOR STREQUAL "zippered")
1023+
string(REGEX MATCH "iOS ([0-9]+(\.[0-9]+)+)" ios_platform_version "${def}")
1024+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" ios_version "${ios_platform_version}")
1025+
string(REGEX MATCH "macOS ([0-9]+(\.[0-9]+)+)" macos_platform_version "${def}")
1026+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" macos_version "${macos_platform_version}")
1027+
if((NOT macos_version STREQUAL "9999" OR NOT ios_version STREQUAL "9999") AND (macos_version VERSION_GREATER "${SWIFT_SDK_OSX_DEPLOYMENT_VERSION}" OR ios_version VERSION_GREATER "${SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST}"))
1028+
string(REGEX REPLACE ":.*" ": macOS ${SWIFT_SDK_OSX_DEPLOYMENT_VERSION}, iOS ${SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST}" current "${current}")
1029+
endif()
1030+
else()
1031+
string(REGEX MATCH "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_AVAILABILITY_NAME} ([0-9]+(\.[0-9]+)+)" platform_version "${def}")
1032+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" version "${platform_version}")
1033+
if(NOT version STREQUAL "9999" AND version VERSION_GREATER "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_DEPLOYMENT_VERSION}")
1034+
string(REGEX REPLACE ":.*" ":${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_AVAILABILITY_NAME} ${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_DEPLOYMENT_VERSION}" current "${current}")
1035+
endif()
1036+
endif()
1037+
endif()
1038+
1039+
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-Xfrontend" "-define-availability" "-Xfrontend" "${current}")
1040+
endif()
10061041
endforeach()
10071042

10081043
# Enable -target-min-inlining-version

stdlib/public/Concurrency/CFExecutor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum CoreFoundation {
4343

4444
// .. Main Executor ............................................................
4545

46-
@available(SwiftStdlib 6.2, *)
46+
@available(SwiftStdlibCurrentOS 6.2, *)
4747
public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable {
4848

4949
override public func run() throws {
@@ -58,7 +58,7 @@ public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable {
5858

5959
// .. Task Executor ............................................................
6060

61-
@available(SwiftStdlib 6.2, *)
61+
@available(SwiftStdlibCurrentOS 6.2, *)
6262
public final class CFTaskExecutor: DispatchGlobalTaskExecutor,
6363
@unchecked Sendable {
6464

0 commit comments

Comments
 (0)