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

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
This commit is contained in:
Alastair Houghton
2025-05-09 16:53:19 +01:00
parent 0e6f3a8d54
commit 28f96e64ab
41 changed files with 416 additions and 266 deletions

View File

@@ -12,7 +12,7 @@ is_sdk_requested(OSX swift_build_osx)
if(swift_build_osx)
configure_sdk_darwin(
OSX "OS X" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX}"
macosx macosx macos "${SUPPORTED_OSX_ARCHS}")
macosx macosx macos macOS "${SUPPORTED_OSX_ARCHS}")
configure_target_variant(OSX-DA "OS X Debug+Asserts" OSX DA "Debug+Asserts")
configure_target_variant(OSX-RA "OS X Release+Asserts" OSX RA "Release+Asserts")
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"))
"Which triple name (e.g. 'none-macho') to use when building the FREESTANDING stdlib")
set(SWIFT_FREESTANDING_MODULE_NAME "" CACHE STRING
"Which .swiftmodule name (e.g. 'freestanding') to use when building the FREESTANDING stdlib")
set(SWIFT_FREESTANDING_AVAILABILITY_NAME "" CACHE STRING
"Which @availability name (e.g. 'macOS') to use when building the FREESTANDING stdlib")
set(SWIFT_FREESTANDING_ARCHS "" CACHE STRING
"Which architectures to build when building the FREESTANDING stdlib")
configure_sdk_darwin(
FREESTANDING "FREESTANDING" ""
"${SWIFT_FREESTANDING_SDK}"
"${SWIFT_FREESTANDING_TRIPLE_NAME}" "${SWIFT_FREESTANDING_MODULE_NAME}" "${SWIFT_FREESTANDING_ARCHS}")
"${SWIFT_FREESTANDING_TRIPLE_NAME}" "${SWIFT_FREESTANDING_MODULE_NAME}"
"${SWIFT_FREESTANDING_AVAILABILITY_NAME}" "${SWIFT_FREESTANDING_ARCHS}")
set(SWIFT_SDK_FREESTANDING_LIB_SUBDIR "freestanding")
configure_target_variant(FREESTANDING-DA "FREESTANDING Debug+Asserts" FREESTANDING DA "Debug+Asserts")
configure_target_variant(FREESTANDING-RA "FREESTANDING Release+Asserts" FREESTANDING RA "Release+Asserts")
@@ -53,7 +56,7 @@ is_sdk_requested(IOS swift_build_ios)
if(swift_build_ios)
configure_sdk_darwin(
IOS "iOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
iphoneos ios ios "${SUPPORTED_IOS_ARCHS}")
iphoneos ios ios iOS "${SUPPORTED_IOS_ARCHS}")
configure_target_variant(IOS-DA "iOS Debug+Asserts" IOS DA "Debug+Asserts")
configure_target_variant(IOS-RA "iOS Release+Asserts" IOS RA "Release+Asserts")
configure_target_variant(IOS-R "iOS Release" IOS R "Release")
@@ -63,7 +66,7 @@ is_sdk_requested(IOS_SIMULATOR swift_build_ios_simulator)
if(swift_build_ios_simulator)
configure_sdk_darwin(
IOS_SIMULATOR "iOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
iphonesimulator ios ios-simulator
iphonesimulator ios ios-simulator iOS
"${SUPPORTED_IOS_SIMULATOR_ARCHS}")
configure_target_variant(
IOS_SIMULATOR-DA "iOS Debug+Asserts" IOS_SIMULATOR DA "Debug+Asserts")
@@ -77,7 +80,7 @@ is_sdk_requested(TVOS swift_build_tvos)
if(swift_build_tvos)
configure_sdk_darwin(
TVOS "tvOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvos tvos tvos "${SUPPORTED_TVOS_ARCHS}")
appletvos tvos tvos tvOS "${SUPPORTED_TVOS_ARCHS}")
configure_target_variant(TVOS-DA "tvOS Debug+Asserts" TVOS DA "Debug+Asserts")
configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts")
configure_target_variant(TVOS-R "tvOS Release" TVOS R "Release")
@@ -87,7 +90,7 @@ is_sdk_requested(TVOS_SIMULATOR swift_build_tvos_simulator)
if(swift_build_tvos_simulator)
configure_sdk_darwin(
TVOS_SIMULATOR "tvOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvsimulator tvos tvos-simulator
appletvsimulator tvos tvos-simulator tvOS
"${SUPPORTED_TVOS_SIMULATOR_ARCHS}")
configure_target_variant(
TVOS_SIMULATOR-DA "tvOS Debug+Asserts" TVOS_SIMULATOR DA "Debug+Asserts")
@@ -101,7 +104,7 @@ is_sdk_requested(WATCHOS swift_build_watchos)
if(swift_build_watchos)
configure_sdk_darwin(
WATCHOS "watchOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
watchos watchos watchos "${SUPPORTED_WATCHOS_ARCHS}")
watchos watchos watchos watchOS "${SUPPORTED_WATCHOS_ARCHS}")
configure_target_variant(WATCHOS-DA "watchOS Debug+Asserts" WATCHOS DA "Debug+Asserts")
configure_target_variant(WATCHOS-RA "watchOS Release+Asserts" WATCHOS RA "Release+Asserts")
configure_target_variant(WATCHOS-R "watchOS Release" WATCHOS R "Release")
@@ -111,7 +114,7 @@ is_sdk_requested(WATCHOS_SIMULATOR swift_build_watchos_simulator)
if(swift_build_watchos_simulator)
configure_sdk_darwin(
WATCHOS_SIMULATOR "watchOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
watchsimulator watchos watchos-simulator
watchsimulator watchos watchos-simulator watchOS
"${SUPPORTED_WATCHOS_SIMULATOR_ARCHS}")
configure_target_variant(WATCHOS_SIMULATOR-DA "watchOS Debug+Asserts" WATCHOS_SIMULATOR DA "Debug+Asserts")
configure_target_variant(WATCHOS_SIMULATOR-RA "watchOS Release+Asserts" WATCHOS_SIMULATOR RA "Release+Asserts")
@@ -122,7 +125,7 @@ is_sdk_requested(XROS swift_build_xros)
if(swift_build_xros)
configure_sdk_darwin(
XROS "xrOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}"
xros xros xros "${SUPPORTED_XROS_ARCHS}")
xros xros xros visionOS "${SUPPORTED_XROS_ARCHS}")
configure_target_variant(XROS-DA "xrOS Debug+Asserts" XROS DA "Debug+Asserts")
configure_target_variant(XROS-RA "xrOS Release+Asserts" XROS RA "Release+Asserts")
configure_target_variant(XROS-R "xrOS Release" XROS R "Release")
@@ -132,7 +135,7 @@ is_sdk_requested(XROS_SIMULATOR swift_build_xros_simulator)
if(swift_build_xros_simulator)
configure_sdk_darwin(
XROS_SIMULATOR "xrOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}"
xrsimulator xros xros-simulator
xrsimulator xros xros-simulator visionOS
"${SUPPORTED_XROS_SIMULATOR_ARCHS}")
configure_target_variant(

View File

@@ -136,6 +136,7 @@ endfunction()
# deployment_version # Deployment version
# xcrun_name # SDK name to use with xcrun
# triple_name # The name used in Swift's -triple
# availability_name # The name used in Swift's @availability
# architectures # A list of architectures this SDK supports
# )
#
@@ -165,9 +166,11 @@ endfunction()
# SWIFT_SDK_${prefix}_ARCH_${ARCH}_TRIPLE Triple name
# SWIFT_SDK_${prefix}_ARCH_${ARCH}_MODULE Module triple name for this SDK
# SWIFT_SDK_${prefix}_USE_BUILD_ID Whether to pass --build-id to the linker
# SWIFT_SDK_${prefix}_AVAILABILITY_NAME Name to use in @availability
#
macro(configure_sdk_darwin
prefix name deployment_version xcrun_name
triple_name module_name architectures)
triple_name module_name availability_name architectures)
# Note: this has to be implemented as a macro because it sets global
# variables.
@@ -201,6 +204,7 @@ macro(configure_sdk_darwin
set(SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION "${deployment_version}")
set(SWIFT_SDK_${prefix}_LIB_SUBDIR "${xcrun_name}")
set(SWIFT_SDK_${prefix}_TRIPLE_NAME "${triple_name}")
set(SWIFT_SDK_${prefix}_AVAILABILITY_NAME "${availability_name}")
set(SWIFT_SDK_${prefix}_OBJECT_FORMAT "MACHO")
set(SWIFT_SDK_${prefix}_USE_ISYSROOT TRUE)
set(SWIFT_SDK_${prefix}_SHARED_LIBRARY_PREFIX "lib")