[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

@@ -462,6 +462,10 @@ option(SWIFT_STDLIB_ASSERTIONS
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)" "Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
"${SWIFT_STDLIB_ASSERTIONS_default}") "${SWIFT_STDLIB_ASSERTIONS_default}")
option(SWIFT_STDLIB_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"
FALSE)
option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
"Use the host compiler and not the internal clang to build the swift runtime" "Use the host compiler and not the internal clang to build the swift runtime"
FALSE) FALSE)
@@ -1404,8 +1408,9 @@ endif()
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY) if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
message(STATUS "Building Swift standard library and overlays for SDKs: ${SWIFT_SDKS}") message(STATUS "Building Swift standard library and overlays for SDKs: ${SWIFT_SDKS}")
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}") message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}") message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
message(STATUS " Strict availability: ${SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY}")
message(STATUS "") message(STATUS "")
message(STATUS "Building Swift runtime with:") message(STATUS "Building Swift runtime with:")

View File

@@ -125,6 +125,7 @@ defaulted_option(SwiftCore_ENABLE_BACKTRACING "Enable backtracing runtime suppor
defaulted_set(SwiftCore_BACKTRACER_PATH STRING "Set a fixed path to the Swift backtracer") defaulted_set(SwiftCore_BACKTRACER_PATH STRING "Set a fixed path to the Swift backtracer")
defaulted_option(SwiftCore_ENABLE_FATALERROR_BACKTRACE "Build stdlib fatalError with backtrace output") defaulted_option(SwiftCore_ENABLE_FATALERROR_BACKTRACE "Build stdlib fatalError with backtrace output")
defaulted_option(SwiftCore_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization") defaulted_option(SwiftCore_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization")
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")
option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" OFF) option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" OFF)
option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" OFF) option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" OFF)

View File

@@ -12,6 +12,8 @@ set(SwiftCore_ENABLE_VECTOR_TYPES ON CACHE BOOL "")
set(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS ON CACHE BOOL "") set(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS ON CACHE BOOL "")
set(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT ON CACHE BOOL "") set(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT ON CACHE BOOL "")
set(SwiftCore_ENABLE_FILESYSTEM_SUPPORT ON CACHE BOOL "") set(SwiftCore_ENABLE_FILESYSTEM_SUPPORT ON CACHE BOOL "")
set(SwiftCore_ENABLE_STRICT_AVAILABILITY ON CACHE BOOL "")
set(SwiftCore_OPTIMIZATION_REMARKS "bitstream" CACHE STRING "") set(SwiftCore_OPTIMIZATION_REMARKS "bitstream" CACHE STRING "")
set(SwiftCore_INSTALL_NESTED_SUBDIR OFF CACHE BOOL "") set(SwiftCore_INSTALL_NESTED_SUBDIR OFF CACHE BOOL "")

View File

@@ -5,4 +5,22 @@ file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/availability-macros.def" availability_
list(FILTER availability_defs EXCLUDE REGEX "^\\s*(#.*)?$") list(FILTER availability_defs EXCLUDE REGEX "^\\s*(#.*)?$")
foreach(def ${availability_defs}) foreach(def ${availability_defs})
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${def}\">") add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${def}\">")
if("${def}" MATCHES "SwiftStdlib .*")
# For each SwiftStdlib x.y, also define SwiftStdlibTargetOS x.y, which,
# will expand to the current `-target` platform if the macro defines a
# newer platform as its availability.
#
# There is a setting, SwiftCore_ENABLE_STRICT_AVAILABILITY, which if set
# 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}")
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" version "${platform_version}")
if(NOT version STREQUAL "9999" AND version VERSION_GREATER CMAKE_OSX_DEPLOYMENT_TARGET)
string(REGEX REPLACE ":.*" ":${SwiftCore_SWIFT_AVAILABILITY_PLATFORM} ${CMAKE_OSX_DEPLOYMENT_TARGET}" current "${current}")
endif()
endif()
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${current}\">")
endif()
endforeach() endforeach()

View File

@@ -11,6 +11,8 @@ set(SwiftCore_ENABLE_COMMANDLINE_SUPPORT_default OFF) # TODO: enable this by def
set(SwiftCore_ENABLE_STDIN_default ON) set(SwiftCore_ENABLE_STDIN_default ON)
set(SwiftCore_ENABLE_TYPE_PRINTING_default ON) set(SwiftCore_ENABLE_TYPE_PRINTING_default ON)
set(SwiftCore_ENABLE_STRICT_AVAILABILITY_default OFF)
set(SwiftCore_BACKTRACER_PATH_default "") set(SwiftCore_BACKTRACER_PATH_default "")
# Provide a boolean option that a user can optionally enable. # Provide a boolean option that a user can optionally enable.
@@ -20,7 +22,7 @@ macro(defaulted_option variable helptext)
if(NOT DEFINED ${variable}_default) if(NOT DEFINED ${variable}_default)
set(${variable}_default OFF) set(${variable}_default OFF)
endif() endif()
option(${variable} ${helptext} ${${variable}_default}) option(${variable} "${helptext}" ${${variable}_default})
endmacro() endmacro()
# Create a defaulted cache entry # Create a defaulted cache entry

View File

@@ -36,3 +36,26 @@ if(NOT SwiftCore_ARCH_SUBDIR)
message(CONFIGURE_LOG "Swift Arch: ${arch}") message(CONFIGURE_LOG "Swift Arch: ${arch}")
endif() endif()
if(NOT SwiftCore_SWIFT_AVAILABILITY_PLATFORM)
set(availability_platform_macosx "macOS")
set(availability_platform_ios "iOS")
set(availability_platform_watchos "watchOS")
set(availability_platform_tvos "tvOS")
set(availability_platform_xros "visionOS")
set(availability_platform_bridgeos "bridgeOS")
if(SwiftCore_SWIFT_MODULE_TRIPLE MATCHES ".*-([^-]+)-simulator$")
set(platform "${CMAKE_MATCH_1}")
elseif(SwiftCore_SWIFT_MODULE_TRIPLE MATCHES ".*-([^-]+)$")
set(platform "${CMAKE_MATCH_1}")
else()
message(ERROR "Unable to extract platform name from triple ${SwiftCore_SWIFT_MODULE_TRIPLE}")
endif()
if(availability_platform_${platform})
set(SwiftCore_SWIFT_AVAILABILITY_PLATFORM "${availability_platform_${platform}}")
else()
message(ERROR "Unknown platform ${platform} for availability")
endif()
endif()

View File

@@ -12,7 +12,7 @@ is_sdk_requested(OSX swift_build_osx)
if(swift_build_osx) if(swift_build_osx)
configure_sdk_darwin( configure_sdk_darwin(
OSX "OS X" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX}" 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-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-RA "OS X Release+Asserts" OSX RA "Release+Asserts")
configure_target_variant(OSX-R "OS X Release" OSX R "Release") 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") "Which triple name (e.g. 'none-macho') to use when building the FREESTANDING stdlib")
set(SWIFT_FREESTANDING_MODULE_NAME "" CACHE STRING set(SWIFT_FREESTANDING_MODULE_NAME "" CACHE STRING
"Which .swiftmodule name (e.g. 'freestanding') to use when building the FREESTANDING stdlib") "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 set(SWIFT_FREESTANDING_ARCHS "" CACHE STRING
"Which architectures to build when building the FREESTANDING stdlib") "Which architectures to build when building the FREESTANDING stdlib")
configure_sdk_darwin( configure_sdk_darwin(
FREESTANDING "FREESTANDING" "" FREESTANDING "FREESTANDING" ""
"${SWIFT_FREESTANDING_SDK}" "${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") set(SWIFT_SDK_FREESTANDING_LIB_SUBDIR "freestanding")
configure_target_variant(FREESTANDING-DA "FREESTANDING Debug+Asserts" FREESTANDING DA "Debug+Asserts") configure_target_variant(FREESTANDING-DA "FREESTANDING Debug+Asserts" FREESTANDING DA "Debug+Asserts")
configure_target_variant(FREESTANDING-RA "FREESTANDING Release+Asserts" FREESTANDING RA "Release+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) if(swift_build_ios)
configure_sdk_darwin( configure_sdk_darwin(
IOS "iOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}" 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-DA "iOS Debug+Asserts" IOS DA "Debug+Asserts")
configure_target_variant(IOS-RA "iOS Release+Asserts" IOS RA "Release+Asserts") configure_target_variant(IOS-RA "iOS Release+Asserts" IOS RA "Release+Asserts")
configure_target_variant(IOS-R "iOS Release" IOS R "Release") 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) if(swift_build_ios_simulator)
configure_sdk_darwin( configure_sdk_darwin(
IOS_SIMULATOR "iOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}" IOS_SIMULATOR "iOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
iphonesimulator ios ios-simulator iphonesimulator ios ios-simulator iOS
"${SUPPORTED_IOS_SIMULATOR_ARCHS}") "${SUPPORTED_IOS_SIMULATOR_ARCHS}")
configure_target_variant( configure_target_variant(
IOS_SIMULATOR-DA "iOS Debug+Asserts" IOS_SIMULATOR DA "Debug+Asserts") 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) if(swift_build_tvos)
configure_sdk_darwin( configure_sdk_darwin(
TVOS "tvOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}" 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-DA "tvOS Debug+Asserts" TVOS DA "Debug+Asserts")
configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts") configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts")
configure_target_variant(TVOS-R "tvOS Release" TVOS R "Release") 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) if(swift_build_tvos_simulator)
configure_sdk_darwin( configure_sdk_darwin(
TVOS_SIMULATOR "tvOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}" TVOS_SIMULATOR "tvOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvsimulator tvos tvos-simulator appletvsimulator tvos tvos-simulator tvOS
"${SUPPORTED_TVOS_SIMULATOR_ARCHS}") "${SUPPORTED_TVOS_SIMULATOR_ARCHS}")
configure_target_variant( configure_target_variant(
TVOS_SIMULATOR-DA "tvOS Debug+Asserts" TVOS_SIMULATOR DA "Debug+Asserts") 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) if(swift_build_watchos)
configure_sdk_darwin( configure_sdk_darwin(
WATCHOS "watchOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}" 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-DA "watchOS Debug+Asserts" WATCHOS DA "Debug+Asserts")
configure_target_variant(WATCHOS-RA "watchOS Release+Asserts" WATCHOS RA "Release+Asserts") configure_target_variant(WATCHOS-RA "watchOS Release+Asserts" WATCHOS RA "Release+Asserts")
configure_target_variant(WATCHOS-R "watchOS Release" WATCHOS R "Release") 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) if(swift_build_watchos_simulator)
configure_sdk_darwin( configure_sdk_darwin(
WATCHOS_SIMULATOR "watchOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}" WATCHOS_SIMULATOR "watchOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
watchsimulator watchos watchos-simulator watchsimulator watchos watchos-simulator watchOS
"${SUPPORTED_WATCHOS_SIMULATOR_ARCHS}") "${SUPPORTED_WATCHOS_SIMULATOR_ARCHS}")
configure_target_variant(WATCHOS_SIMULATOR-DA "watchOS Debug+Asserts" WATCHOS_SIMULATOR DA "Debug+Asserts") 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") 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) if(swift_build_xros)
configure_sdk_darwin( configure_sdk_darwin(
XROS "xrOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}" 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-DA "xrOS Debug+Asserts" XROS DA "Debug+Asserts")
configure_target_variant(XROS-RA "xrOS Release+Asserts" XROS RA "Release+Asserts") configure_target_variant(XROS-RA "xrOS Release+Asserts" XROS RA "Release+Asserts")
configure_target_variant(XROS-R "xrOS Release" XROS R "Release") 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) if(swift_build_xros_simulator)
configure_sdk_darwin( configure_sdk_darwin(
XROS_SIMULATOR "xrOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}" XROS_SIMULATOR "xrOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}"
xrsimulator xros xros-simulator xrsimulator xros xros-simulator visionOS
"${SUPPORTED_XROS_SIMULATOR_ARCHS}") "${SUPPORTED_XROS_SIMULATOR_ARCHS}")
configure_target_variant( configure_target_variant(

View File

@@ -136,6 +136,7 @@ endfunction()
# deployment_version # Deployment version # deployment_version # Deployment version
# xcrun_name # SDK name to use with xcrun # xcrun_name # SDK name to use with xcrun
# triple_name # The name used in Swift's -triple # 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 # 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}_TRIPLE Triple name
# SWIFT_SDK_${prefix}_ARCH_${ARCH}_MODULE Module triple name for this SDK # 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}_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 macro(configure_sdk_darwin
prefix name deployment_version xcrun_name 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 # Note: this has to be implemented as a macro because it sets global
# variables. # variables.
@@ -201,6 +204,7 @@ macro(configure_sdk_darwin
set(SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION "${deployment_version}") set(SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION "${deployment_version}")
set(SWIFT_SDK_${prefix}_LIB_SUBDIR "${xcrun_name}") set(SWIFT_SDK_${prefix}_LIB_SUBDIR "${xcrun_name}")
set(SWIFT_SDK_${prefix}_TRIPLE_NAME "${triple_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}_OBJECT_FORMAT "MACHO")
set(SWIFT_SDK_${prefix}_USE_ISYSROOT TRUE) set(SWIFT_SDK_${prefix}_USE_ISYSROOT TRUE)
set(SWIFT_SDK_${prefix}_SHARED_LIBRARY_PREFIX "lib") set(SWIFT_SDK_${prefix}_SHARED_LIBRARY_PREFIX "lib")

View File

@@ -1003,6 +1003,25 @@ function(add_swift_target_library_single target name)
# Define availability macros. # Define availability macros.
foreach(def ${SWIFT_STDLIB_AVAILABILITY_DEFINITIONS}) foreach(def ${SWIFT_STDLIB_AVAILABILITY_DEFINITIONS})
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-Xfrontend" "-define-availability" "-Xfrontend" "${def}") list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-Xfrontend" "-define-availability" "-Xfrontend" "${def}")
if("${def}" MATCHES "SwiftStdlib .*")
# For each SwiftStdlib x.y, also define SwiftStdlibTargetOS x.y, which,
# will expand to the current `-target` platform if the macro defines a
# newer platform as its availability.
#
# There is a setting, SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY, which if set
# ON will cause us to use the "proper" availability instead.
string(REPLACE "SwiftStdlib" "SwiftStdlibCurrentOS" current "${def}")
if(NOT SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY AND SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_AVAILABILITY_NAME)
string(REGEX MATCH "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_AVAILABILITY_NAME} ([0-9]+(\.[0-9]+)+)" platform_version "${def}")
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" version "${platform_version}")
if(NOT version STREQUAL "9999" AND version VERSION_GREATER "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_DEPLOYMENT_VERSION}")
string(REGEX REPLACE ":.*" ":${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_AVAILABILITY_NAME} ${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_DEPLOYMENT_VERSION}" current "${current}")
endif()
endif()
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-Xfrontend" "-define-availability" "-Xfrontend" "${current}")
endif()
endforeach() endforeach()
# Enable -target-min-inlining-version # Enable -target-min-inlining-version

View File

@@ -43,7 +43,7 @@ enum CoreFoundation {
// .. Main Executor ............................................................ // .. Main Executor ............................................................
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable { public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable {
override public func run() throws { override public func run() throws {
@@ -58,7 +58,7 @@ public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable {
// .. Task Executor ............................................................ // .. Task Executor ............................................................
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public final class CFTaskExecutor: DispatchGlobalTaskExecutor, public final class CFTaskExecutor: DispatchGlobalTaskExecutor,
@unchecked Sendable { @unchecked Sendable {

View File

@@ -30,7 +30,7 @@ import Swift
/// ///
/// For more information about specific clocks see `ContinuousClock` and /// For more information about specific clocks see `ContinuousClock` and
/// `SuspendingClock`. /// `SuspendingClock`.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public protocol Clock<Duration>: Sendable { public protocol Clock<Duration>: Sendable {
associatedtype Duration associatedtype Duration
associatedtype Instant: InstantProtocol where Instant.Duration == Duration associatedtype Instant: InstantProtocol where Instant.Duration == Duration
@@ -43,7 +43,7 @@ public protocol Clock<Duration>: Sendable {
#endif #endif
/// The traits associated with this clock instance. /// The traits associated with this clock instance.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
var traits: ClockTraits { get } var traits: ClockTraits { get }
/// Convert a Clock-specific Duration to a Swift Duration /// Convert a Clock-specific Duration to a Swift Duration
@@ -59,7 +59,7 @@ public protocol Clock<Duration>: Sendable {
/// ///
/// Returns: A `Swift.Duration` representing the equivalent duration, or /// Returns: A `Swift.Duration` representing the equivalent duration, or
/// `nil` if this function is not supported. /// `nil` if this function is not supported.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
func convert(from duration: Duration) -> Swift.Duration? func convert(from duration: Duration) -> Swift.Duration?
/// Convert a Swift Duration to a Clock-specific Duration /// Convert a Swift Duration to a Clock-specific Duration
@@ -70,7 +70,7 @@ public protocol Clock<Duration>: Sendable {
/// ///
/// Returns: A `Duration` representing the equivalent duration, or /// Returns: A `Duration` representing the equivalent duration, or
/// `nil` if this function is not supported. /// `nil` if this function is not supported.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
func convert(from duration: Swift.Duration) -> Duration? func convert(from duration: Swift.Duration) -> Duration?
/// Convert an `Instant` from some other clock's `Instant` /// Convert an `Instant` from some other clock's `Instant`
@@ -82,12 +82,12 @@ public protocol Clock<Duration>: Sendable {
/// ///
/// Returns: An `Instant` representing the equivalent instant, or /// Returns: An `Instant` representing the equivalent instant, or
/// `nil` if this function is not supported. /// `nil` if this function is not supported.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
func convert<OtherClock: Clock>(instant: OtherClock.Instant, func convert<OtherClock: Clock>(instant: OtherClock.Instant,
from clock: OtherClock) -> Instant? from clock: OtherClock) -> Instant?
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Clock { extension Clock {
/// Measure the elapsed time to execute a closure. /// Measure the elapsed time to execute a closure.
/// ///
@@ -95,7 +95,7 @@ extension Clock {
/// let elapsed = clock.measure { /// let elapsed = clock.measure {
/// someWork() /// someWork()
/// } /// }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public func measure(_ work: () throws -> Void) rethrows -> Instant.Duration { public func measure(_ work: () throws -> Void) rethrows -> Instant.Duration {
let start = now let start = now
try work() try work()
@@ -109,7 +109,7 @@ extension Clock {
/// let elapsed = await clock.measure { /// let elapsed = await clock.measure {
/// await someWork() /// await someWork()
/// } /// }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_alwaysEmitIntoClient @_alwaysEmitIntoClient
public func measure( public func measure(
isolation: isolated (any Actor)? = #isolation, isolation: isolated (any Actor)? = #isolation,
@@ -127,7 +127,7 @@ extension Clock {
// //
// This function also doubles as an ABI-compatibility shim predating the // This function also doubles as an ABI-compatibility shim predating the
// introduction of #isolation. // introduction of #isolation.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_silgen_name("$ss5ClockPsE7measurey8DurationQzyyYaKXEYaKF") @_silgen_name("$ss5ClockPsE7measurey8DurationQzyyYaKXEYaKF")
@_unsafeInheritExecutor // for ABI compatibility @_unsafeInheritExecutor // for ABI compatibility
public func _unsafeInheritExecutor_measure( public func _unsafeInheritExecutor_measure(
@@ -140,7 +140,7 @@ extension Clock {
} }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension Clock { extension Clock {
// For compatibility, return `nil` if this is not implemented // For compatibility, return `nil` if this is not implemented
public func convert(from duration: Duration) -> Swift.Duration? { public func convert(from duration: Duration) -> Swift.Duration? {
@@ -171,7 +171,7 @@ extension Clock {
} }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension Clock where Duration == Swift.Duration { extension Clock where Duration == Swift.Duration {
public func convert(from duration: Duration) -> Duration? { public func convert(from duration: Duration) -> Duration? {
return duration return duration
@@ -179,13 +179,13 @@ extension Clock where Duration == Swift.Duration {
} }
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Clock { extension Clock {
/// Suspends for the given duration. /// Suspends for the given duration.
/// ///
/// Prefer to use the `sleep(until:tolerance:)` method on `Clock` if you have /// Prefer to use the `sleep(until:tolerance:)` method on `Clock` if you have
/// access to an absolute instant. /// access to an absolute instant.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_alwaysEmitIntoClient @_alwaysEmitIntoClient
public func sleep( public func sleep(
for duration: Instant.Duration, for duration: Instant.Duration,
@@ -207,7 +207,7 @@ extension Clock {
/// clocks best matches the clock that the user is trying to specify a /// clocks best matches the clock that the user is trying to specify a
/// time or delay in. Executors are expected to do this on a best effort /// time or delay in. Executors are expected to do this on a best effort
/// basis. /// basis.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public struct ClockTraits: OptionSet { public struct ClockTraits: OptionSet {
public let rawValue: UInt32 public let rawValue: UInt32
@@ -225,10 +225,10 @@ public struct ClockTraits: OptionSet {
public static let wallTime = ClockTraits(rawValue: 1 << 2) public static let wallTime = ClockTraits(rawValue: 1 << 2)
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension Clock { extension Clock {
/// The traits associated with this clock instance. /// The traits associated with this clock instance.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public var traits: ClockTraits { public var traits: ClockTraits {
return [] return []
} }
@@ -239,21 +239,21 @@ enum _ClockID: Int32 {
case suspending = 2 case suspending = 2
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_silgen_name("swift_get_time") @_silgen_name("swift_get_time")
internal func _getTime( internal func _getTime(
seconds: UnsafeMutablePointer<Int64>, seconds: UnsafeMutablePointer<Int64>,
nanoseconds: UnsafeMutablePointer<Int64>, nanoseconds: UnsafeMutablePointer<Int64>,
clock: CInt) clock: CInt)
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_silgen_name("swift_get_clock_res") @_silgen_name("swift_get_clock_res")
internal func _getClockRes( internal func _getClockRes(
seconds: UnsafeMutablePointer<Int64>, seconds: UnsafeMutablePointer<Int64>,
nanoseconds: UnsafeMutablePointer<Int64>, nanoseconds: UnsafeMutablePointer<Int64>,
clock: CInt) clock: CInt)
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_sleep") @_silgen_name("swift_sleep")
internal func _sleep( internal func _sleep(
seconds: Int64, seconds: Int64,

View File

@@ -20,7 +20,7 @@ import Swift
/// only comparable locally during the execution of a program. /// only comparable locally during the execution of a program.
/// ///
/// This clock is suitable for high resolution measurements of execution. /// This clock is suitable for high resolution measurements of execution.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
public struct ContinuousClock: Sendable { public struct ContinuousClock: Sendable {
/// A continuous point in time used for `ContinuousClock`. /// A continuous point in time used for `ContinuousClock`.
@@ -36,12 +36,12 @@ public struct ContinuousClock: Sendable {
} }
#if !$Embedded #if !$Embedded
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension ContinuousClock.Instant: Codable { extension ContinuousClock.Instant: Codable {
} }
#endif #endif
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Duration { extension Duration {
internal init(_seconds s: Int64, nanoseconds n: Int64) { internal init(_seconds s: Int64, nanoseconds n: Int64) {
let (secHi, secLo) = s.multipliedFullWidth(by: 1_000_000_000_000_000_000) let (secHi, secLo) = s.multipliedFullWidth(by: 1_000_000_000_000_000_000)
@@ -56,7 +56,7 @@ extension Duration {
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
extension Clock where Self == ContinuousClock { extension Clock where Self == ContinuousClock {
/// A clock that measures time that always increments but does not stop /// A clock that measures time that always increments but does not stop
@@ -64,11 +64,11 @@ extension Clock where Self == ContinuousClock {
/// ///
/// try await Task.sleep(until: .now + .seconds(3), clock: .continuous) /// try await Task.sleep(until: .now + .seconds(3), clock: .continuous)
/// ///
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static var continuous: ContinuousClock { return ContinuousClock() } public static var continuous: ContinuousClock { return ContinuousClock() }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
extension ContinuousClock: Clock { extension ContinuousClock: Clock {
/// The current continuous instant. /// The current continuous instant.
@@ -101,7 +101,7 @@ extension ContinuousClock: Clock {
} }
/// The continuous clock is continuous and monotonic /// The continuous clock is continuous and monotonic
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public var traits: ClockTraits { public var traits: ClockTraits {
return [.continuous, .monotonic] return [.continuous, .monotonic]
} }
@@ -119,17 +119,16 @@ extension ContinuousClock: Clock {
public func sleep( public func sleep(
until deadline: Instant, tolerance: Swift.Duration? = nil until deadline: Instant, tolerance: Swift.Duration? = nil
) async throws { ) async throws {
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
try await Task._sleep(until: deadline, try await Task._sleep(until: deadline,
tolerance: tolerance, tolerance: tolerance,
clock: self) clock: self)
} else { } else {
// Should never see this fatalError("we should never get here; if we have, availability is broken")
Builtin.unreachable()
} }
} }
#else #else
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") @available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
public func sleep( public func sleep(
until deadline: Instant, tolerance: Swift.Duration? = nil until deadline: Instant, tolerance: Swift.Duration? = nil
@@ -139,7 +138,7 @@ extension ContinuousClock: Clock {
#endif #endif
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
extension ContinuousClock { extension ContinuousClock {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlib 5.7, *)

View File

@@ -17,7 +17,7 @@ import Swift
// Store the Timestamp in the executor private data, if it will fit; otherwise, // Store the Timestamp in the executor private data, if it will fit; otherwise,
// use the allocator to allocate space for it and stash a pointer in the private // use the allocator to allocate space for it and stash a pointer in the private
// data area. // data area.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension ExecutorJob { extension ExecutorJob {
fileprivate var cooperativeExecutorTimestampIsIndirect: Bool { fileprivate var cooperativeExecutorTimestampIsIndirect: Bool {
return MemoryLayout<(Int, Int)>.size return MemoryLayout<(Int, Int)>.size
@@ -99,7 +99,7 @@ extension ExecutorJob {
/// A co-operative executor that can be used as the main executor or as a /// A co-operative executor that can be used as the main executor or as a
/// task executor. /// task executor.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
class CooperativeExecutor: Executor, @unchecked Sendable { class CooperativeExecutor: Executor, @unchecked Sendable {
var runQueue: PriorityQueue<UnownedJob> var runQueue: PriorityQueue<UnownedJob>
var waitQueue: PriorityQueue<UnownedJob> var waitQueue: PriorityQueue<UnownedJob>
@@ -179,7 +179,7 @@ class CooperativeExecutor: Executor, @unchecked Sendable {
public var asSchedulable: any SchedulableExecutor { self } public var asSchedulable: any SchedulableExecutor { self }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension CooperativeExecutor: SchedulableExecutor { extension CooperativeExecutor: SchedulableExecutor {
var currentTime: Timestamp { var currentTime: Timestamp {
var now: Timestamp = .zero var now: Timestamp = .zero
@@ -202,7 +202,7 @@ extension CooperativeExecutor: SchedulableExecutor {
} }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension CooperativeExecutor: RunLoopExecutor { extension CooperativeExecutor: RunLoopExecutor {
public func run() throws { public func run() throws {
try runUntil { false } try runUntil { false }
@@ -249,13 +249,13 @@ extension CooperativeExecutor: RunLoopExecutor {
} }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension CooperativeExecutor: SerialExecutor {} extension CooperativeExecutor: SerialExecutor {}
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension CooperativeExecutor: TaskExecutor {} extension CooperativeExecutor: TaskExecutor {}
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension CooperativeExecutor: MainExecutor {} extension CooperativeExecutor: MainExecutor {}
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY

View File

@@ -23,7 +23,7 @@ import Swift
// .. Main Executor ............................................................ // .. Main Executor ............................................................
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public class DispatchMainExecutor: RunLoopExecutor, @unchecked Sendable { public class DispatchMainExecutor: RunLoopExecutor, @unchecked Sendable {
var threaded = false var threaded = false
@@ -43,7 +43,7 @@ public class DispatchMainExecutor: RunLoopExecutor, @unchecked Sendable {
} }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension DispatchMainExecutor: SerialExecutor { extension DispatchMainExecutor: SerialExecutor {
public func enqueue(_ job: consuming ExecutorJob) { public func enqueue(_ job: consuming ExecutorJob) {
@@ -57,7 +57,7 @@ extension DispatchMainExecutor: SerialExecutor {
} }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension DispatchMainExecutor: SchedulableExecutor { extension DispatchMainExecutor: SchedulableExecutor {
public var asSchedulable: SchedulableExecutor? { public var asSchedulable: SchedulableExecutor? {
return self return self
@@ -85,12 +85,12 @@ extension DispatchMainExecutor: SchedulableExecutor {
} }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension DispatchMainExecutor: MainExecutor {} extension DispatchMainExecutor: MainExecutor {}
// .. Task Executor ............................................................ // .. Task Executor ............................................................
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulableExecutor, public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulableExecutor,
@unchecked Sendable { @unchecked Sendable {
public init() {} public init() {}
@@ -130,7 +130,7 @@ public class DispatchGlobalTaskExecutor: TaskExecutor, SchedulableExecutor,
/// ///
/// It is used to help convert instants and durations from arbitrary `Clock`s /// It is used to help convert instants and durations from arbitrary `Clock`s
/// to Dispatch's time base. /// to Dispatch's time base.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
protocol DispatchExecutorProtocol: Executor { protocol DispatchExecutorProtocol: Executor {
/// Convert an `Instant` from the specified clock to a tuple identifying /// Convert an `Instant` from the specified clock to a tuple identifying
@@ -158,7 +158,7 @@ enum DispatchClockID: CInt {
case suspending = 2 case suspending = 2
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension DispatchExecutorProtocol { extension DispatchExecutorProtocol {
func clamp(_ components: (seconds: Int64, attoseconds: Int64)) func clamp(_ components: (seconds: Int64, attoseconds: Int64))
@@ -201,11 +201,11 @@ extension DispatchExecutorProtocol {
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension DispatchGlobalTaskExecutor: DispatchExecutorProtocol { extension DispatchGlobalTaskExecutor: DispatchExecutorProtocol {
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension DispatchMainExecutor: DispatchExecutorProtocol { extension DispatchMainExecutor: DispatchExecutorProtocol {
} }

View File

@@ -26,24 +26,24 @@ public protocol Executor: AnyObject, Sendable {
// Cannot introduce these methods in SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY // Cannot introduce these methods in SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
// since it lacks move-only type support. // since it lacks move-only type support.
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
@available(*, deprecated, message: "Implement 'enqueue(_: consuming ExecutorJob)' instead") @available(*, deprecated, message: "Implement 'enqueue(_: consuming ExecutorJob)' instead")
func enqueue(_ job: consuming Job) func enqueue(_ job: consuming Job)
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
func enqueue(_ job: consuming ExecutorJob) func enqueue(_ job: consuming ExecutorJob)
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
#if !$Embedded #if !$Embedded
/// `true` if this is the main executor. /// `true` if this is the main executor.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
var isMainExecutor: Bool { get } var isMainExecutor: Bool { get }
#endif #endif
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public protocol SchedulableExecutor: Executor { public protocol SchedulableExecutor: Executor {
#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@@ -63,7 +63,7 @@ public protocol SchedulableExecutor: Executor {
/// - tolerance: The maximum additional delay permissible before the /// - tolerance: The maximum additional delay permissible before the
/// job is executed. `nil` means no limit. /// job is executed. `nil` means no limit.
/// - clock: The clock used for the delay. /// - clock: The clock used for the delay.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
func enqueue<C: Clock>(_ job: consuming ExecutorJob, func enqueue<C: Clock>(_ job: consuming ExecutorJob,
after delay: C.Duration, after delay: C.Duration,
tolerance: C.Duration?, tolerance: C.Duration?,
@@ -83,7 +83,7 @@ public protocol SchedulableExecutor: Executor {
/// - tolerance: The maximum additional delay permissible before the /// - tolerance: The maximum additional delay permissible before the
/// job is executed. `nil` means no limit. /// job is executed. `nil` means no limit.
/// - clock: The clock used for the delay.. /// - clock: The clock used for the delay..
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
func enqueue<C: Clock>(_ job: consuming ExecutorJob, func enqueue<C: Clock>(_ job: consuming ExecutorJob,
at instant: C.Instant, at instant: C.Instant,
tolerance: C.Duration?, tolerance: C.Duration?,
@@ -125,7 +125,7 @@ extension Executor {
/// Executors that implement SchedulableExecutor should provide their /// Executors that implement SchedulableExecutor should provide their
/// own copy of this method, which will allow the compiler to avoid a /// own copy of this method, which will allow the compiler to avoid a
/// potentially expensive runtime cast. /// potentially expensive runtime cast.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
var asSchedulable: SchedulableExecutor? { var asSchedulable: SchedulableExecutor? {
return self as? SchedulableExecutor return self as? SchedulableExecutor
} }
@@ -148,19 +148,19 @@ extension Executor {
#if !$Embedded #if !$Embedded
// This defaults to `false` so that existing third-party Executor // This defaults to `false` so that existing third-party Executor
// implementations will work as expected. // implementations will work as expected.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public var isMainExecutor: Bool { false } public var isMainExecutor: Bool { false }
#endif #endif
} }
// Delay support // Delay support
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension SchedulableExecutor { extension SchedulableExecutor {
#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public func enqueue<C: Clock>(_ job: consuming ExecutorJob, public func enqueue<C: Clock>(_ job: consuming ExecutorJob,
after delay: C.Duration, after delay: C.Duration,
tolerance: C.Duration? = nil, tolerance: C.Duration? = nil,
@@ -171,7 +171,7 @@ extension SchedulableExecutor {
tolerance: tolerance, clock: clock) tolerance: tolerance, clock: clock)
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public func enqueue<C: Clock>(_ job: consuming ExecutorJob, public func enqueue<C: Clock>(_ job: consuming ExecutorJob,
at instant: C.Instant, at instant: C.Instant,
tolerance: C.Duration? = nil, tolerance: C.Duration? = nil,
@@ -275,7 +275,7 @@ public protocol SerialExecutor: Executor {
// avoid drilling down to the base conformance just for the basic // avoid drilling down to the base conformance just for the basic
// work-scheduling operation. // work-scheduling operation.
@_nonoverride @_nonoverride
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
@available(*, deprecated, message: "Implement 'enqueue(_: consuming ExecutorJob)' instead") @available(*, deprecated, message: "Implement 'enqueue(_: consuming ExecutorJob)' instead")
func enqueue(_ job: consuming Job) func enqueue(_ job: consuming Job)
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@@ -286,7 +286,7 @@ public protocol SerialExecutor: Executor {
// avoid drilling down to the base conformance just for the basic // avoid drilling down to the base conformance just for the basic
// work-scheduling operation. // work-scheduling operation.
@_nonoverride @_nonoverride
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
func enqueue(_ job: consuming ExecutorJob) func enqueue(_ job: consuming ExecutorJob)
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@@ -317,7 +317,7 @@ public protocol SerialExecutor: Executor {
/// - Returns: `true`, if `self` and the `other` executor actually are /// - Returns: `true`, if `self` and the `other` executor actually are
/// mutually exclusive and it is safefrom a concurrency /// mutually exclusive and it is safefrom a concurrency
/// perspectiveto execute code assuming one on the other. /// perspectiveto execute code assuming one on the other.
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
func isSameExclusiveExecutionContext(other: Self) -> Bool func isSameExclusiveExecutionContext(other: Self) -> Bool
/// Last resort "fallback" isolation check, called when the concurrency runtime /// Last resort "fallback" isolation check, called when the concurrency runtime
@@ -340,7 +340,7 @@ public protocol SerialExecutor: Executor {
/// ///
/// - Warning: This method must crash and halt program execution if unable /// - Warning: This method must crash and halt program execution if unable
/// to prove the isolation of the calling context. /// to prove the isolation of the calling context.
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
func checkIsolated() func checkIsolated()
/// Checks if the current execution context is isolated by this executor. /// Checks if the current execution context is isolated by this executor.
@@ -360,20 +360,20 @@ public protocol SerialExecutor: Executor {
/// The default implementation returns `nil` is used to indicate that it is "unknown" if the current context is /// The default implementation returns `nil` is used to indicate that it is "unknown" if the current context is
/// isolated by this serial executor. The runtime then _may_ proceed to invoke `checkIsolated()` as a last-resort /// isolated by this serial executor. The runtime then _may_ proceed to invoke `checkIsolated()` as a last-resort
/// attempt to verify the isolation of the current context. /// attempt to verify the isolation of the current context.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
func isIsolatingCurrentContext() -> Bool? func isIsolatingCurrentContext() -> Bool?
} }
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
extension SerialExecutor { extension SerialExecutor {
#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public var isMainExecutor: Bool { return MainActor.executor._isSameExecutor(self) } public var isMainExecutor: Bool { return MainActor.executor._isSameExecutor(self) }
#endif #endif
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
public func checkIsolated() { public func checkIsolated() {
#if !$Embedded #if !$Embedded
fatalError("Unexpected isolation context, expected to be executing on \(Self.self)") fatalError("Unexpected isolation context, expected to be executing on \(Self.self)")
@@ -383,13 +383,13 @@ extension SerialExecutor {
} }
#if SWIFT_CONCURRENCY_USES_DISPATCH #if SWIFT_CONCURRENCY_USES_DISPATCH
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
private var _dispatchQueue: OpaquePointer? { private var _dispatchQueue: OpaquePointer? {
return _getDispatchQueueForExecutor(self.asUnownedSerialExecutor()) return _getDispatchQueueForExecutor(self.asUnownedSerialExecutor())
} }
#endif #endif
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
internal func _isSameExecutor(_ rhs: some SerialExecutor) -> Bool { internal func _isSameExecutor(_ rhs: some SerialExecutor) -> Bool {
if rhs === self { if rhs === self {
return true return true
@@ -409,10 +409,10 @@ extension SerialExecutor {
} }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension SerialExecutor { extension SerialExecutor {
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public func isIsolatingCurrentContext() -> Bool? { public func isIsolatingCurrentContext() -> Bool? {
return nil return nil
} }
@@ -435,7 +435,7 @@ extension SerialExecutor {
/// the provided task executor. /// the provided task executor.
/// ///
/// Unstructured tasks do not inherit the task executor. /// Unstructured tasks do not inherit the task executor.
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
public protocol TaskExecutor: Executor { public protocol TaskExecutor: Executor {
// This requirement is repeated here as a non-override so that we // This requirement is repeated here as a non-override so that we
// get a redundant witness-table entry for it. This allows us to // get a redundant witness-table entry for it. This allows us to
@@ -466,7 +466,7 @@ public protocol TaskExecutor: Executor {
func asUnownedTaskExecutor() -> UnownedTaskExecutor func asUnownedTaskExecutor() -> UnownedTaskExecutor
} }
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
extension TaskExecutor { extension TaskExecutor {
public func asUnownedTaskExecutor() -> UnownedTaskExecutor { public func asUnownedTaskExecutor() -> UnownedTaskExecutor {
unsafe UnownedTaskExecutor(ordinary: self) unsafe UnownedTaskExecutor(ordinary: self)
@@ -474,7 +474,7 @@ extension TaskExecutor {
} }
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
extension Executor { extension Executor {
// Delegation goes like this: // Delegation goes like this:
@@ -494,28 +494,28 @@ extension Executor {
} }
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
extension SerialExecutor { extension SerialExecutor {
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
public func asUnownedSerialExecutor() -> UnownedSerialExecutor { public func asUnownedSerialExecutor() -> UnownedSerialExecutor {
unsafe UnownedSerialExecutor(ordinary: self) unsafe UnownedSerialExecutor(ordinary: self)
} }
} }
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
extension SerialExecutor { extension SerialExecutor {
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
public func isSameExclusiveExecutionContext(other: Self) -> Bool { public func isSameExclusiveExecutionContext(other: Self) -> Bool {
return self === other return self === other
} }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension SerialExecutor where Self: Equatable { extension SerialExecutor where Self: Equatable {
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public func isSameExclusiveExecutionContext(other: Self) -> Bool { public func isSameExclusiveExecutionContext(other: Self) -> Bool {
return self == other return self == other
} }
@@ -527,7 +527,7 @@ extension SerialExecutor where Self: Equatable {
/// The idea here is that some executors may work by running a loop /// The idea here is that some executors may work by running a loop
/// that processes events of some sort; we want a way to enter that loop, /// that processes events of some sort; we want a way to enter that loop,
/// and we would also like a way to trigger the loop to exit. /// and we would also like a way to trigger the loop to exit.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public protocol RunLoopExecutor: Executor { public protocol RunLoopExecutor: Executor {
/// Run the executor's run loop. /// Run the executor's run loop.
/// ///
@@ -558,7 +558,7 @@ public protocol RunLoopExecutor: Executor {
func stop() func stop()
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension RunLoopExecutor { extension RunLoopExecutor {
public func runUntil(_ condition: () -> Bool) throws { public func runUntil(_ condition: () -> Bool) throws {
@@ -570,14 +570,14 @@ extension RunLoopExecutor {
/// The main executor must conform to these three protocols; we have to /// The main executor must conform to these three protocols; we have to
/// make this a protocol for compatibility with Embedded Swift. /// make this a protocol for compatibility with Embedded Swift.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public protocol MainExecutor: RunLoopExecutor, SerialExecutor { public protocol MainExecutor: RunLoopExecutor, SerialExecutor {
} }
/// An ExecutorFactory is used to create the default main and task /// An ExecutorFactory is used to create the default main and task
/// executors. /// executors.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public protocol ExecutorFactory { public protocol ExecutorFactory {
#if !$Embedded #if !$Embedded
/// Constructs and returns the main executor, which is started implicitly /// Constructs and returns the main executor, which is started implicitly
@@ -590,10 +590,10 @@ public protocol ExecutorFactory {
static var defaultExecutor: any TaskExecutor { get } static var defaultExecutor: any TaskExecutor { get }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
typealias DefaultExecutorFactory = PlatformExecutorFactory typealias DefaultExecutorFactory = PlatformExecutorFactory
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_createExecutors") @_silgen_name("swift_createExecutors")
public func _createExecutors<F: ExecutorFactory>(factory: F.Type) { public func _createExecutors<F: ExecutorFactory>(factory: F.Type) {
#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@@ -612,7 +612,7 @@ func _createDefaultExecutors() {
#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
extension MainActor { extension MainActor {
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
static var _executor: (any MainExecutor)? = nil static var _executor: (any MainExecutor)? = nil
/// The main executor, which is started implicitly by the `async main` /// The main executor, which is started implicitly by the `async main`
@@ -620,7 +620,7 @@ extension MainActor {
/// ///
/// Attempting to set this after the first `enqueue` on the main /// Attempting to set this after the first `enqueue` on the main
/// executor is a fatal error. /// executor is a fatal error.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public static var executor: any MainExecutor { public static var executor: any MainExecutor {
// It would be good if there was a Swift way to do this // It would be good if there was a Swift way to do this
_createDefaultExecutorsOnce() _createDefaultExecutorsOnce()
@@ -630,7 +630,7 @@ extension MainActor {
#endif // !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #endif // !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
extension Task where Success == Never, Failure == Never { extension Task where Success == Never, Failure == Never {
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
static var _defaultExecutor: (any TaskExecutor)? = nil static var _defaultExecutor: (any TaskExecutor)? = nil
/// The default or global executor, which is the default place in which /// The default or global executor, which is the default place in which
@@ -638,7 +638,7 @@ extension Task where Success == Never, Failure == Never {
/// ///
/// Attempting to set this after the first `enqueue` on the global /// Attempting to set this after the first `enqueue` on the global
/// executor is a fatal error. /// executor is a fatal error.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public static var defaultExecutor: any TaskExecutor { public static var defaultExecutor: any TaskExecutor {
// It would be good if there was a Swift way to do this // It would be good if there was a Swift way to do this
_createDefaultExecutorsOnce() _createDefaultExecutorsOnce()
@@ -658,7 +658,7 @@ extension Task where Success == Never, Failure == Never {
/// 3. The task executor for the current thread /// 3. The task executor for the current thread
/// ///
/// If none of these exist, returns the default executor. /// If none of these exist, returns the default executor.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_unavailableInEmbedded @_unavailableInEmbedded
public static var currentExecutor: any Executor { public static var currentExecutor: any Executor {
if let activeExecutor = unsafe _getActiveExecutor().asSerialExecutor() { if let activeExecutor = unsafe _getActiveExecutor().asSerialExecutor() {
@@ -672,7 +672,7 @@ extension Task where Success == Never, Failure == Never {
} }
/// Get the preferred executor for the current `Task`, if any. /// Get the preferred executor for the current `Task`, if any.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public static var preferredExecutor: (any TaskExecutor)? { public static var preferredExecutor: (any TaskExecutor)? {
if let taskExecutor = unsafe _getPreferredTaskExecutor().asTaskExecutor() { if let taskExecutor = unsafe _getPreferredTaskExecutor().asTaskExecutor() {
return taskExecutor return taskExecutor
@@ -684,7 +684,7 @@ extension Task where Success == Never, Failure == Never {
/// ///
/// This follows the same logic as `currentExecutor`, except that it ignores /// This follows the same logic as `currentExecutor`, except that it ignores
/// any executor that isn't a `SchedulableExecutor`. /// any executor that isn't a `SchedulableExecutor`.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_unavailableInEmbedded @_unavailableInEmbedded
public static var currentSchedulableExecutor: (any SchedulableExecutor)? { public static var currentSchedulableExecutor: (any SchedulableExecutor)? {
if let activeExecutor = unsafe _getActiveExecutor().asSerialExecutor(), if let activeExecutor = unsafe _getActiveExecutor().asSerialExecutor(),
@@ -776,14 +776,14 @@ public struct UnownedSerialExecutor: Sendable {
unsafe _executor_isComplexEquality(self) unsafe _executor_isComplexEquality(self)
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public func asSerialExecutor() -> (any SerialExecutor)? { public func asSerialExecutor() -> (any SerialExecutor)? {
return unsafe unsafeBitCast(executor, to: (any SerialExecutor)?.self) return unsafe unsafeBitCast(executor, to: (any SerialExecutor)?.self)
} }
} }
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
@unsafe @unsafe
@frozen @frozen
public struct UnownedTaskExecutor: Sendable { public struct UnownedTaskExecutor: Sendable {
@@ -813,7 +813,7 @@ public struct UnownedTaskExecutor: Sendable {
unsafe self.executor = Builtin.buildOrdinaryTaskExecutorRef(executor) unsafe self.executor = Builtin.buildOrdinaryTaskExecutorRef(executor)
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public func asTaskExecutor() -> (any TaskExecutor)? { public func asTaskExecutor() -> (any TaskExecutor)? {
return unsafe unsafeBitCast(executor, to: (any TaskExecutor)?.self) return unsafe unsafeBitCast(executor, to: (any TaskExecutor)?.self)
} }
@@ -876,7 +876,7 @@ func _checkExpectedExecutor(_filenameStart: Builtin.RawPointer,
/// otherwise returns only the job's 32bit Id. /// otherwise returns only the job's 32bit Id.
/// ///
/// - Returns: the Id stored in this ExecutorJob or Task, for purposes of debug printing /// - Returns: the Id stored in this ExecutorJob or Task, for purposes of debug printing
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
@_silgen_name("swift_task_getJobTaskId") @_silgen_name("swift_task_getJobTaskId")
internal func _getJobTaskId(_ job: UnownedJob) -> UInt64 internal func _getJobTaskId(_ job: UnownedJob) -> UInt64
@@ -930,10 +930,10 @@ internal func _task_taskExecutor_getTaskExecutorRef<E>(_ taskExecutor: E) -> Bui
internal func _enqueueOnExecutor<E>(job unownedJob: UnownedJob, executor: E) internal func _enqueueOnExecutor<E>(job unownedJob: UnownedJob, executor: E)
where E: SerialExecutor { where E: SerialExecutor {
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
if #available(SwiftStdlib 5.9, *) { if #available(SwiftStdlibCurrentOS 5.9, *) {
executor.enqueue(ExecutorJob(context: unownedJob._context)) executor.enqueue(ExecutorJob(context: unownedJob._context))
} else { } else {
executor.enqueue(unownedJob) fatalError("we shouldn't get here; if we have, availability is broken")
} }
#else // SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #else // SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
executor.enqueue(unownedJob) executor.enqueue(unownedJob)

View File

@@ -17,19 +17,19 @@
import Swift import Swift
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("_swift_exit") @_silgen_name("_swift_exit")
internal func _exit(result: CInt) internal func _exit(result: CInt)
#if !$Embedded #if !$Embedded
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("_swift_task_isMainExecutorSwift") @_silgen_name("_swift_task_isMainExecutorSwift")
internal func _isMainExecutor<E>(_ executor: E) -> Bool where E: SerialExecutor { internal func _isMainExecutor<E>(_ executor: E) -> Bool where E: SerialExecutor {
return executor.isMainExecutor return executor.isMainExecutor
} }
#endif #endif
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("_swift_task_checkIsolatedSwift") @_silgen_name("_swift_task_checkIsolatedSwift")
internal func checkIsolated<E>(executor: E) where E: SerialExecutor { internal func checkIsolated<E>(executor: E) where E: SerialExecutor {
executor.checkIsolated() executor.checkIsolated()
@@ -40,7 +40,7 @@ internal func checkIsolated<E>(executor: E) where E: SerialExecutor {
/// -1: unknown /// -1: unknown
/// 0: not isolated /// 0: not isolated
/// 1: isolated /// 1: isolated
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("_swift_task_isIsolatingCurrentContextSwift") @_silgen_name("_swift_task_isIsolatingCurrentContextSwift")
internal func isIsolatingCurrentContext<E>(executor: E) -> Int8 internal func isIsolatingCurrentContext<E>(executor: E) -> Int8
where E: SerialExecutor { where E: SerialExecutor {
@@ -51,37 +51,37 @@ internal func isIsolatingCurrentContext<E>(executor: E) -> Int8
} }
} }
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("_swift_getActiveExecutor") @_silgen_name("_swift_getActiveExecutor")
internal func _getActiveExecutor() -> UnownedSerialExecutor internal func _getActiveExecutor() -> UnownedSerialExecutor
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("_swift_getCurrentTaskExecutor") @_silgen_name("_swift_getCurrentTaskExecutor")
internal func _getCurrentTaskExecutor() -> UnownedTaskExecutor internal func _getCurrentTaskExecutor() -> UnownedTaskExecutor
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("_swift_getPreferredTaskExecutor") @_silgen_name("_swift_getPreferredTaskExecutor")
internal func _getPreferredTaskExecutor() -> UnownedTaskExecutor internal func _getPreferredTaskExecutor() -> UnownedTaskExecutor
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_job_allocate") @_silgen_name("swift_job_allocate")
internal func _jobAllocate(_ job: Builtin.Job, internal func _jobAllocate(_ job: Builtin.Job,
_ capacity: Int) -> UnsafeMutableRawPointer _ capacity: Int) -> UnsafeMutableRawPointer
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_job_deallocate") @_silgen_name("swift_job_deallocate")
internal func _jobDeallocate(_ job: Builtin.Job, internal func _jobDeallocate(_ job: Builtin.Job,
_ address: UnsafeMutableRawPointer) _ address: UnsafeMutableRawPointer)
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_job_getPriority") @_silgen_name("swift_job_getPriority")
internal func _jobGetPriority(_ job: Builtin.Job) -> UInt8 internal func _jobGetPriority(_ job: Builtin.Job) -> UInt8
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_job_getKind") @_silgen_name("swift_job_getKind")
internal func _jobGetKind(_ job: Builtin.Job) -> UInt8 internal func _jobGetKind(_ job: Builtin.Job) -> UInt8
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_job_getExecutorPrivateData") @_silgen_name("swift_job_getExecutorPrivateData")
internal func _jobGetExecutorPrivateData( internal func _jobGetExecutorPrivateData(
_ job: Builtin.Job _ job: Builtin.Job
@@ -89,32 +89,32 @@ internal func _jobGetExecutorPrivateData(
#if !$Embedded #if !$Embedded
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_getMainExecutor") @_silgen_name("swift_getMainExecutor")
internal func _getMainExecutor() -> any SerialExecutor { internal func _getMainExecutor() -> any SerialExecutor {
return MainActor.executor return MainActor.executor
} }
#else #else
// For task-to-thread model, this is implemented in C++ // For task-to-thread model, this is implemented in C++
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_getMainExecutor") @_silgen_name("swift_getMainExecutor")
internal func _getMainExecutor() -> any SerialExecutor internal func _getMainExecutor() -> any SerialExecutor
#endif // SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #endif // SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
#endif // !$Embedded #endif // !$Embedded
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_dispatchMain") @_silgen_name("swift_dispatchMain")
internal func _dispatchMain() internal func _dispatchMain()
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_dispatchEnqueueMain") @_silgen_name("swift_dispatchEnqueueMain")
internal func _dispatchEnqueueMain(_ job: UnownedJob) internal func _dispatchEnqueueMain(_ job: UnownedJob)
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_dispatchEnqueueGlobal") @_silgen_name("swift_dispatchEnqueueGlobal")
internal func _dispatchEnqueueGlobal(_ job: UnownedJob) internal func _dispatchEnqueueGlobal(_ job: UnownedJob)
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_dispatchEnqueueWithDeadline") @_silgen_name("swift_dispatchEnqueueWithDeadline")
internal func _dispatchEnqueueWithDeadline(_ global: CBool, internal func _dispatchEnqueueWithDeadline(_ global: CBool,
_ sec: CLongLong, _ sec: CLongLong,
@@ -124,7 +124,7 @@ internal func _dispatchEnqueueWithDeadline(_ global: CBool,
_ clock: CInt, _ clock: CInt,
_ job: UnownedJob) _ job: UnownedJob)
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@_silgen_name("swift_dispatchAssertMainQueue") @_silgen_name("swift_dispatchAssertMainQueue")
internal func _dispatchAssertMainQueue() internal func _dispatchAssertMainQueue()

View File

@@ -35,10 +35,10 @@ import Swift
@_unavailableInEmbedded @_unavailableInEmbedded
public var globalConcurrentExecutor: any TaskExecutor { public var globalConcurrentExecutor: any TaskExecutor {
get { get {
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
return Task.defaultExecutor return Task.defaultExecutor
} else { } else {
return _DefaultGlobalConcurrentExecutor.shared fatalError("we shouldn't get here; if we have, availability is broken")
} }
} }
} }

View File

@@ -33,14 +33,14 @@ internal func _swiftJobRun(_ job: UnownedJob,
_ executor: UnownedSerialExecutor) -> () _ executor: UnownedSerialExecutor) -> ()
@_unavailableInEmbedded @_unavailableInEmbedded
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
@_silgen_name("swift_job_run_on_task_executor") @_silgen_name("swift_job_run_on_task_executor")
@usableFromInline @usableFromInline
internal func _swiftJobRunOnTaskExecutor(_ job: UnownedJob, internal func _swiftJobRunOnTaskExecutor(_ job: UnownedJob,
_ executor: UnownedTaskExecutor) -> () _ executor: UnownedTaskExecutor) -> ()
@_unavailableInEmbedded @_unavailableInEmbedded
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
@_silgen_name("swift_job_run_on_serial_and_task_executor") @_silgen_name("swift_job_run_on_serial_and_task_executor")
@usableFromInline @usableFromInline
internal func _swiftJobRunOnTaskExecutor(_ job: UnownedJob, internal func _swiftJobRunOnTaskExecutor(_ job: UnownedJob,
@@ -63,14 +63,14 @@ public struct UnownedJob: Sendable {
private var context: Builtin.Job private var context: Builtin.Job
@usableFromInline @usableFromInline
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
internal init(context: Builtin.Job) { internal init(context: Builtin.Job) {
self.context = context self.context = context
} }
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
/// Create an `UnownedJob` whose lifetime must be managed carefully until it is run exactly once. /// Create an `UnownedJob` whose lifetime must be managed carefully until it is run exactly once.
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
public init(_ job: __owned Job) { // must remain '__owned' in order to not break ABI public init(_ job: __owned Job) { // must remain '__owned' in order to not break ABI
self.context = job.context self.context = job.context
} }
@@ -78,27 +78,25 @@ public struct UnownedJob: Sendable {
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
/// Create an `UnownedJob` whose lifetime must be managed carefully until it is run exactly once. /// Create an `UnownedJob` whose lifetime must be managed carefully until it is run exactly once.
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
public init(_ job: __owned ExecutorJob) { // must remain '__owned' in order to not break ABI public init(_ job: __owned ExecutorJob) { // must remain '__owned' in order to not break ABI
self.context = job.context self.context = job.context
} }
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
/// The priority of this job. /// The priority of this job.
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
public var priority: JobPriority { public var priority: JobPriority {
let raw: UInt8 let raw: UInt8
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
raw = _jobGetPriority(context) raw = _jobGetPriority(context)
} else { } else {
// Since we're building the new version of the stdlib, we should fatalError("we shouldn't get here; if we have, availability is broken")
// never get here.
Builtin.unreachable()
} }
return JobPriority(rawValue: raw) return JobPriority(rawValue: raw)
} }
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
internal var _context: Builtin.Job { internal var _context: Builtin.Job {
context context
} }
@@ -145,7 +143,7 @@ public struct UnownedJob: Sendable {
/// ///
/// - SeeAlso: ``runSynchronously(isolatedTo:taskExecutor:)`` /// - SeeAlso: ``runSynchronously(isolatedTo:taskExecutor:)``
@_unavailableInEmbedded @_unavailableInEmbedded
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
@_alwaysEmitIntoClient @_alwaysEmitIntoClient
@inlinable @inlinable
public func runSynchronously(on executor: UnownedTaskExecutor) { public func runSynchronously(on executor: UnownedTaskExecutor) {
@@ -173,7 +171,7 @@ public struct UnownedJob: Sendable {
/// ///
/// - SeeAlso: ``runSynchronously(on:)`` /// - SeeAlso: ``runSynchronously(on:)``
@_unavailableInEmbedded @_unavailableInEmbedded
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
@_alwaysEmitIntoClient @_alwaysEmitIntoClient
@inlinable @inlinable
public func runSynchronously(isolatedTo serialExecutor: UnownedSerialExecutor, public func runSynchronously(isolatedTo serialExecutor: UnownedSerialExecutor,
@@ -208,7 +206,7 @@ extension UnownedJob: CustomStringConvertible {
/// ///
/// Unless you're implementing a scheduler, /// Unless you're implementing a scheduler,
/// you don't generally interact with jobs directly. /// you don't generally interact with jobs directly.
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
@available(*, deprecated, renamed: "ExecutorJob") @available(*, deprecated, renamed: "ExecutorJob")
@frozen @frozen
public struct Job: Sendable, ~Copyable { public struct Job: Sendable, ~Copyable {
@@ -229,12 +227,10 @@ public struct Job: Sendable, ~Copyable {
public var priority: JobPriority { public var priority: JobPriority {
let raw: UInt8 let raw: UInt8
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
raw = _jobGetPriority(self.context) raw = _jobGetPriority(self.context)
} else { } else {
// We are building the new version of the code, so we should never fatalError("we shouldn't get here; if we have, availability is broken")
// get here.
Builtin.unreachable()
} }
return JobPriority(rawValue: raw) return JobPriority(rawValue: raw)
} }
@@ -284,7 +280,7 @@ extension Job {
/// ///
/// Unless you're implementing a scheduler, /// Unless you're implementing a scheduler,
/// you don't generally interact with jobs directly. /// you don't generally interact with jobs directly.
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
@frozen @frozen
public struct ExecutorJob: Sendable, ~Copyable { public struct ExecutorJob: Sendable, ~Copyable {
internal var context: Builtin.Job internal var context: Builtin.Job
@@ -304,12 +300,10 @@ public struct ExecutorJob: Sendable, ~Copyable {
public var priority: JobPriority { public var priority: JobPriority {
let raw: UInt8 let raw: UInt8
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
raw = _jobGetPriority(self.context) raw = _jobGetPriority(self.context)
} else { } else {
// We are building the new version of the code, so we should never fatalError("we shouldn't get here; if we have, availability is broken")
// get here.
Builtin.unreachable()
} }
return JobPriority(rawValue: raw) return JobPriority(rawValue: raw)
} }
@@ -322,7 +316,7 @@ public struct ExecutorJob: Sendable, ~Copyable {
/// - body: The closure to execute. /// - body: The closure to execute.
/// ///
/// Returns the result of executing the closure. /// Returns the result of executing the closure.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public func withUnsafeExecutorPrivateData<R, E>(body: (UnsafeMutableRawBufferPointer) throws(E) -> R) throws(E) -> R { public func withUnsafeExecutorPrivateData<R, E>(body: (UnsafeMutableRawBufferPointer) throws(E) -> R) throws(E) -> R {
let base = _jobGetExecutorPrivateData(self.context) let base = _jobGetExecutorPrivateData(self.context)
let size = unsafe 2 * MemoryLayout<OpaquePointer>.stride let size = unsafe 2 * MemoryLayout<OpaquePointer>.stride
@@ -331,7 +325,7 @@ public struct ExecutorJob: Sendable, ~Copyable {
} }
/// Kinds of schedulable jobs /// Kinds of schedulable jobs
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
@frozen @frozen
public struct Kind: Sendable, RawRepresentable { public struct Kind: Sendable, RawRepresentable {
public typealias RawValue = UInt8 public typealias RawValue = UInt8
@@ -352,7 +346,7 @@ public struct ExecutorJob: Sendable, ~Copyable {
} }
/// What kind of job this is. /// What kind of job this is.
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public var kind: Kind { public var kind: Kind {
return Kind(rawValue: _jobGetKind(self.context))! return Kind(rawValue: _jobGetKind(self.context))!
} }
@@ -373,7 +367,7 @@ public struct ExecutorJob: Sendable, ~Copyable {
} }
} }
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
extension ExecutorJob { extension ExecutorJob {
/// Run this job on the passed in executor. /// Run this job on the passed in executor.
@@ -415,7 +409,7 @@ extension ExecutorJob {
/// ///
/// - SeeAlso: ``runSynchronously(isolatedTo:taskExecutor:)`` /// - SeeAlso: ``runSynchronously(isolatedTo:taskExecutor:)``
@_unavailableInEmbedded @_unavailableInEmbedded
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
@_alwaysEmitIntoClient @_alwaysEmitIntoClient
@inlinable @inlinable
__consuming public func runSynchronously(on executor: UnownedTaskExecutor) { __consuming public func runSynchronously(on executor: UnownedTaskExecutor) {
@@ -438,7 +432,7 @@ extension ExecutorJob {
/// ///
/// - SeeAlso: ``runSynchronously(on:)`` /// - SeeAlso: ``runSynchronously(on:)``
@_unavailableInEmbedded @_unavailableInEmbedded
@available(SwiftStdlib 6.0, *) @available(SwiftStdlibCurrentOS 6.0, *)
@_alwaysEmitIntoClient @_alwaysEmitIntoClient
@inlinable @inlinable
__consuming public func runSynchronously(isolatedTo serialExecutor: UnownedSerialExecutor, __consuming public func runSynchronously(isolatedTo serialExecutor: UnownedSerialExecutor,
@@ -448,7 +442,7 @@ extension ExecutorJob {
} }
// Stack-disciplined job-local allocator support // Stack-disciplined job-local allocator support
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
extension ExecutorJob { extension ExecutorJob {
/// Obtain a stack-disciplined job-local allocator. /// Obtain a stack-disciplined job-local allocator.
@@ -539,7 +533,7 @@ extension ExecutorJob {
/// however, since not all jobs are tasks, represented as separate type. /// however, since not all jobs are tasks, represented as separate type.
/// ///
/// Conversions between the two priorities are available as initializers on the respective types. /// Conversions between the two priorities are available as initializers on the respective types.
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
@frozen @frozen
public struct JobPriority: Sendable { public struct JobPriority: Sendable {
public typealias RawValue = UInt8 public typealias RawValue = UInt8
@@ -563,7 +557,7 @@ extension TaskPriority {
} }
} }
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
extension JobPriority: Equatable { extension JobPriority: Equatable {
public static func == (lhs: JobPriority, rhs: JobPriority) -> Bool { public static func == (lhs: JobPriority, rhs: JobPriority) -> Bool {
lhs.rawValue == rhs.rawValue lhs.rawValue == rhs.rawValue
@@ -574,7 +568,7 @@ extension JobPriority: Equatable {
} }
} }
@available(SwiftStdlib 5.9, *) @available(SwiftStdlibCurrentOS 5.9, *)
extension JobPriority: Comparable { extension JobPriority: Comparable {
public static func < (lhs: JobPriority, rhs: JobPriority) -> Bool { public static func < (lhs: JobPriority, rhs: JobPriority) -> Bool {
lhs.rawValue < rhs.rawValue lhs.rawValue < rhs.rawValue

View File

@@ -13,7 +13,7 @@
import Swift import Swift
// This platform uses a single, global, CooperativeExecutor // This platform uses a single, global, CooperativeExecutor
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public struct PlatformExecutorFactory: ExecutorFactory { public struct PlatformExecutorFactory: ExecutorFactory {
static let executor = CooperativeExecutor() static let executor = CooperativeExecutor()
public static var mainExecutor: any MainExecutor { executor } public static var mainExecutor: any MainExecutor { executor }

View File

@@ -14,7 +14,7 @@
import Swift import Swift
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public struct PlatformExecutorFactory: ExecutorFactory { public struct PlatformExecutorFactory: ExecutorFactory {
public static var mainExecutor: any MainExecutor { public static var mainExecutor: any MainExecutor {
if CoreFoundation.isPresent { if CoreFoundation.isPresent {

View File

@@ -15,7 +15,7 @@
import Swift import Swift
// The default executors for now are Dispatch-based // The default executors for now are Dispatch-based
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public struct PlatformExecutorFactory: ExecutorFactory { public struct PlatformExecutorFactory: ExecutorFactory {
public static let mainExecutor: any MainExecutor = DispatchMainExecutor() public static let mainExecutor: any MainExecutor = DispatchMainExecutor()
public static let defaultExecutor: any TaskExecutor public static let defaultExecutor: any TaskExecutor

View File

@@ -12,7 +12,7 @@
import Swift import Swift
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public struct PlatformExecutorFactory: ExecutorFactory { public struct PlatformExecutorFactory: ExecutorFactory {
public static let mainExecutor: any MainExecutor = DummyMainExecutor() public static let mainExecutor: any MainExecutor = DummyMainExecutor()
public static let defaultExecutor: any TaskExecutor = DummyTaskExecutor() public static let defaultExecutor: any TaskExecutor = DummyTaskExecutor()

View File

@@ -15,7 +15,7 @@
import Swift import Swift
// The default executors for now are Dispatch-based // The default executors for now are Dispatch-based
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public struct PlatformExecutorFactory: ExecutorFactory { public struct PlatformExecutorFactory: ExecutorFactory {
public static let mainExecutor: any MainExecutor = DispatchMainExecutor() public static let mainExecutor: any MainExecutor = DispatchMainExecutor()
public static let defaultExecutor: any TaskExecutor = public static let defaultExecutor: any TaskExecutor =

View File

@@ -20,7 +20,7 @@ import Swift
/// only comparable on the same machine in the same booted session. /// only comparable on the same machine in the same booted session.
/// ///
/// This clock is suitable for high resolution measurements of execution. /// This clock is suitable for high resolution measurements of execution.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
public struct SuspendingClock: Sendable { public struct SuspendingClock: Sendable {
public struct Instant: Sendable { public struct Instant: Sendable {
@@ -35,12 +35,12 @@ public struct SuspendingClock: Sendable {
} }
#if !$Embedded #if !$Embedded
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension SuspendingClock.Instant: Codable { extension SuspendingClock.Instant: Codable {
} }
#endif #endif
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
extension Clock where Self == SuspendingClock { extension Clock where Self == SuspendingClock {
/// A clock that measures time that always increments but stops incrementing /// A clock that measures time that always increments but stops incrementing
@@ -48,21 +48,21 @@ extension Clock where Self == SuspendingClock {
/// ///
/// try await Task.sleep(until: .now + .seconds(3), clock: .suspending) /// try await Task.sleep(until: .now + .seconds(3), clock: .suspending)
/// ///
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static var suspending: SuspendingClock { return SuspendingClock() } public static var suspending: SuspendingClock { return SuspendingClock() }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
extension SuspendingClock: Clock { extension SuspendingClock: Clock {
/// The current instant accounting for machine suspension. /// The current instant accounting for machine suspension.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public var now: SuspendingClock.Instant { public var now: SuspendingClock.Instant {
SuspendingClock.now SuspendingClock.now
} }
/// The current instant accounting for machine suspension. /// The current instant accounting for machine suspension.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static var now: SuspendingClock.Instant { public static var now: SuspendingClock.Instant {
var seconds = Int64(0) var seconds = Int64(0)
var nanoseconds = Int64(0) var nanoseconds = Int64(0)
@@ -76,7 +76,7 @@ extension SuspendingClock: Clock {
} }
/// The minimum non-zero resolution between any two calls to `now`. /// The minimum non-zero resolution between any two calls to `now`.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public var minimumResolution: Swift.Duration { public var minimumResolution: Swift.Duration {
var seconds = Int64(0) var seconds = Int64(0)
var nanoseconds = Int64(0) var nanoseconds = Int64(0)
@@ -88,7 +88,7 @@ extension SuspendingClock: Clock {
} }
/// The suspending clock is monotonic /// The suspending clock is monotonic
@available(SwiftStdlib 6.2, *) @available(SwiftStdlibCurrentOS 6.2, *)
public var traits: ClockTraits { public var traits: ClockTraits {
return [.monotonic] return [.monotonic]
} }
@@ -103,21 +103,20 @@ extension SuspendingClock: Clock {
/// `CancellationError`. /// `CancellationError`.
/// ///
/// This function doesn't block the underlying thread. /// This function doesn't block the underlying thread.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public func sleep( public func sleep(
until deadline: Instant, tolerance: Swift.Duration? = nil until deadline: Instant, tolerance: Swift.Duration? = nil
) async throws { ) async throws {
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
try await Task._sleep(until: deadline, try await Task._sleep(until: deadline,
tolerance: tolerance, tolerance: tolerance,
clock: self) clock: self)
} else { } else {
// Should never see this fatalError("we shouldn't get here; if we have, availability is broken")
Builtin.unreachable()
} }
} }
#else #else
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model") @available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
public func sleep( public func sleep(
until deadline: Instant, tolerance: Swift.Duration? = nil until deadline: Instant, tolerance: Swift.Duration? = nil
@@ -127,7 +126,7 @@ extension SuspendingClock: Clock {
#endif #endif
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
extension SuspendingClock { extension SuspendingClock {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlib 5.7, *)
@@ -138,67 +137,56 @@ extension SuspendingClock {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlib 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
extension SuspendingClock.Instant: InstantProtocol { extension SuspendingClock.Instant: InstantProtocol {
@available(SwiftStdlib 5.7, *)
public static var now: SuspendingClock.Instant { SuspendingClock().now } public static var now: SuspendingClock.Instant { SuspendingClock().now }
@available(SwiftStdlib 5.7, *)
public func advanced(by duration: Swift.Duration) -> SuspendingClock.Instant { public func advanced(by duration: Swift.Duration) -> SuspendingClock.Instant {
SuspendingClock.Instant(_value: _value + duration) SuspendingClock.Instant(_value: _value + duration)
} }
@available(SwiftStdlib 5.7, *)
public func duration(to other: SuspendingClock.Instant) -> Swift.Duration { public func duration(to other: SuspendingClock.Instant) -> Swift.Duration {
other._value - _value other._value - _value
} }
@available(SwiftStdlib 5.7, *)
public func hash(into hasher: inout Hasher) { public func hash(into hasher: inout Hasher) {
hasher.combine(_value) hasher.combine(_value)
} }
@available(SwiftStdlib 5.7, *)
public static func == ( public static func == (
_ lhs: SuspendingClock.Instant, _ rhs: SuspendingClock.Instant _ lhs: SuspendingClock.Instant, _ rhs: SuspendingClock.Instant
) -> Bool { ) -> Bool {
return lhs._value == rhs._value return lhs._value == rhs._value
} }
@available(SwiftStdlib 5.7, *)
public static func < ( public static func < (
_ lhs: SuspendingClock.Instant, _ rhs: SuspendingClock.Instant _ lhs: SuspendingClock.Instant, _ rhs: SuspendingClock.Instant
) -> Bool { ) -> Bool {
return lhs._value < rhs._value return lhs._value < rhs._value
} }
@available(SwiftStdlib 5.7, *)
public static func + ( public static func + (
_ lhs: SuspendingClock.Instant, _ rhs: Swift.Duration _ lhs: SuspendingClock.Instant, _ rhs: Swift.Duration
) -> SuspendingClock.Instant { ) -> SuspendingClock.Instant {
lhs.advanced(by: rhs) lhs.advanced(by: rhs)
} }
@available(SwiftStdlib 5.7, *)
public static func += ( public static func += (
_ lhs: inout SuspendingClock.Instant, _ rhs: Swift.Duration _ lhs: inout SuspendingClock.Instant, _ rhs: Swift.Duration
) { ) {
lhs = lhs.advanced(by: rhs) lhs = lhs.advanced(by: rhs)
} }
@available(SwiftStdlib 5.7, *)
public static func - ( public static func - (
_ lhs: SuspendingClock.Instant, _ rhs: Swift.Duration _ lhs: SuspendingClock.Instant, _ rhs: Swift.Duration
) -> SuspendingClock.Instant { ) -> SuspendingClock.Instant {
lhs.advanced(by: .zero - rhs) lhs.advanced(by: .zero - rhs)
} }
@available(SwiftStdlib 5.7, *)
public static func -= ( public static func -= (
_ lhs: inout SuspendingClock.Instant, _ rhs: Swift.Duration _ lhs: inout SuspendingClock.Instant, _ rhs: Swift.Duration
) { ) {
lhs = lhs.advanced(by: .zero - rhs) lhs = lhs.advanced(by: .zero - rhs)
} }
@available(SwiftStdlib 5.7, *)
public static func - ( public static func - (
_ lhs: SuspendingClock.Instant, _ rhs: SuspendingClock.Instant _ lhs: SuspendingClock.Instant, _ rhs: SuspendingClock.Instant
) -> Swift.Duration { ) -> Swift.Duration {

View File

@@ -1254,12 +1254,12 @@ extension Task where Success == Never, Failure == Never {
continuation: continuation) continuation: continuation)
#if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !$Embedded && !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
let executor = Task.currentExecutor let executor = Task.currentExecutor
executor.enqueue(ExecutorJob(context: job)) executor.enqueue(ExecutorJob(context: job))
} else { } else {
_enqueueJobGlobal(job) fatalError("we shouldn't get here; if we have, availability is broken")
} }
#else #else
_enqueueJobGlobal(job) _enqueueJobGlobal(job)
@@ -1439,7 +1439,7 @@ func _enqueueJobGlobalWithDelay(_ delay: UInt64, _ task: UnownedJob) {
return _enqueueJobGlobalWithDelay(delay, task._context) return _enqueueJobGlobalWithDelay(delay, task._context)
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_silgen_name("swift_task_enqueueGlobalWithDeadline") @_silgen_name("swift_task_enqueueGlobalWithDeadline")
@usableFromInline @usableFromInline
func _enqueueJobGlobalWithDeadline(_ seconds: Int64, _ nanoseconds: Int64, func _enqueueJobGlobalWithDeadline(_ seconds: Int64, _ nanoseconds: Int64,
@@ -1515,10 +1515,10 @@ internal func _runAsyncMain(_ asyncFun: @Sendable @escaping () async throws -> (
} }
let job = Builtin.convertTaskToJob(theTask) let job = Builtin.convertTaskToJob(theTask)
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
MainActor.executor.enqueue(ExecutorJob(context: job)) MainActor.executor.enqueue(ExecutorJob(context: job))
} else { } else {
Builtin.unreachable() fatalError("we shouldn't get here; if we have, availability is broken")
} }
_asyncMainDrainQueue() _asyncMainDrainQueue()

View File

@@ -28,7 +28,7 @@ extension Task where Success == Never, Failure == Never {
priority: Int(Task.currentPriority.rawValue), priority: Int(Task.currentPriority.rawValue),
continuation: continuation) continuation: continuation)
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
#if !$Embedded #if !$Embedded
if let executor = Task.currentSchedulableExecutor { if let executor = Task.currentSchedulableExecutor {
executor.enqueue(ExecutorJob(context: job), executor.enqueue(ExecutorJob(context: job),
@@ -272,7 +272,7 @@ extension Task where Success == Never, Failure == Never {
let job = Builtin.convertTaskToJob(sleepTask) let job = Builtin.convertTaskToJob(sleepTask)
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
#if !$Embedded #if !$Embedded
if let executor = Task.currentSchedulableExecutor { if let executor = Task.currentSchedulableExecutor {
executor.enqueue(ExecutorJob(context: job), executor.enqueue(ExecutorJob(context: job),

View File

@@ -13,18 +13,18 @@
import Swift import Swift
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY #if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
fileprivate func timestamp<C: Clock>(for instant: C.Instant, clock: C) fileprivate func timestamp<C: Clock>(for instant: C.Instant, clock: C)
-> (clockID: _ClockID, seconds: Int64, nanoseconds: Int64) { -> (clockID: _ClockID, seconds: Int64, nanoseconds: Int64) {
var clockID: _ClockID var clockID: _ClockID
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
if clock.traits.contains(.continuous) { if clock.traits.contains(.continuous) {
clockID = .continuous clockID = .continuous
} else { } else {
clockID = .suspending clockID = .suspending
} }
} else { } else {
Builtin.unreachable() fatalError("we shouldn't get here; if we have, availability is broken")
} }
var seconds: Int64 = 0 var seconds: Int64 = 0
@@ -34,10 +34,10 @@ fileprivate func timestamp<C: Clock>(for instant: C.Instant, clock: C)
clock: clockID.rawValue) clock: clockID.rawValue)
let delta: Swift.Duration let delta: Swift.Duration
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
delta = clock.convert(from: clock.now.duration(to: instant))! delta = clock.convert(from: clock.now.duration(to: instant))!
} else { } else {
Builtin.unreachable() fatalError("we shouldn't get here; if we have, availability is broken")
} }
let (deltaSeconds, deltaAttoseconds) = delta.components let (deltaSeconds, deltaAttoseconds) = delta.components
@@ -54,10 +54,10 @@ fileprivate func timestamp<C: Clock>(for instant: C.Instant, clock: C)
nanoseconds: Int64(nanoseconds)) nanoseconds: Int64(nanoseconds))
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
extension Task where Success == Never, Failure == Never { extension Task where Success == Never, Failure == Never {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
internal static func _sleep<C: Clock>( internal static func _sleep<C: Clock>(
until instant: C.Instant, until instant: C.Instant,
tolerance: C.Duration?, tolerance: C.Duration?,
@@ -97,7 +97,7 @@ extension Task where Success == Never, Failure == Never {
let job = Builtin.convertTaskToJob(sleepTask) let job = Builtin.convertTaskToJob(sleepTask)
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
#if !$Embedded #if !$Embedded
if let executor = Task.currentSchedulableExecutor { if let executor = Task.currentSchedulableExecutor {
executor.enqueue(ExecutorJob(context: job), executor.enqueue(ExecutorJob(context: job),
@@ -108,7 +108,7 @@ extension Task where Success == Never, Failure == Never {
} }
#endif #endif
} else { } else {
Builtin.unreachable() fatalError("we shouldn't get here; if we have, availability is broken")
} }
// If there is no current schedulable executor, fall back to // If there is no current schedulable executor, fall back to
@@ -117,7 +117,7 @@ extension Task where Success == Never, Failure == Never {
clock: clock) clock: clock)
let toleranceSeconds: Int64 let toleranceSeconds: Int64
let toleranceNanoseconds: Int64 let toleranceNanoseconds: Int64
if #available(SwiftStdlib 6.2, *) { if #available(SwiftStdlibCurrentOS 6.2, *) {
if let tolerance = tolerance, if let tolerance = tolerance,
let components = clock.convert(from: tolerance)?.components { let components = clock.convert(from: tolerance)?.components {
toleranceSeconds = components.seconds toleranceSeconds = components.seconds
@@ -127,16 +127,16 @@ extension Task where Success == Never, Failure == Never {
toleranceNanoseconds = -1 toleranceNanoseconds = -1
} }
} else { } else {
Builtin.unreachable() fatalError("we shouldn't get here; if we have, availability is broken")
} }
if #available(SwiftStdlib 5.9, *) { if #available(SwiftStdlibCurrentOS 5.9, *) {
_enqueueJobGlobalWithDeadline( _enqueueJobGlobalWithDeadline(
seconds, nanoseconds, seconds, nanoseconds,
toleranceSeconds, toleranceNanoseconds, toleranceSeconds, toleranceNanoseconds,
clockID.rawValue, UnownedJob(context: job)) clockID.rawValue, UnownedJob(context: job))
} else { } else {
Builtin.unreachable() fatalError("we shouldn't get here; if we have, availability is broken")
} }
return return

View File

@@ -163,7 +163,7 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
if("${arch}" MATCHES "avr") if("${arch}" MATCHES "avr")
continue() continue()
endif() endif()
set(SWIFT_SDK_embedded_ARCH_${arch}_MODULE "${mod}") set(SWIFT_SDK_embedded_ARCH_${arch}_MODULE "${mod}")
set(SWIFT_SDK_embedded_LIB_SUBDIR "embedded") set(SWIFT_SDK_embedded_LIB_SUBDIR "embedded")
set(SWIFT_SDK_embedded_ARCH_${arch}_TRIPLE "${triple}") set(SWIFT_SDK_embedded_ARCH_${arch}_TRIPLE "${triple}")

View File

@@ -40,7 +40,7 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
IS_SDK_OVERLAY IS_FRAGILE IS_SDK_OVERLAY IS_FRAGILE
Volatile.swift Volatile.swift
SWIFT_COMPILE_FLAGS SWIFT_COMPILE_FLAGS
-Xcc -ffreestanding -enable-experimental-feature Embedded -Xcc -ffreestanding -enable-experimental-feature Embedded
-parse-stdlib -parse-stdlib

View File

@@ -31,7 +31,7 @@
/// temporal measurement component; specifically leap seconds should be /// temporal measurement component; specifically leap seconds should be
/// represented as an additional accessor since that is specific only to certain /// represented as an additional accessor since that is specific only to certain
/// clock implementations. /// clock implementations.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@frozen @frozen
public struct Duration: Sendable { public struct Duration: Sendable {
/// The low 64 bits of a 128-bit signed integer value counting attoseconds. /// The low 64 bits of a 128-bit signed integer value counting attoseconds.
@@ -86,13 +86,13 @@ public struct Duration: Sendable {
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Duration { extension Duration {
/// The composite components of the `Duration`. /// The composite components of the `Duration`.
/// ///
/// This is intended for facilitating conversions to existing time types. The /// This is intended for facilitating conversions to existing time types. The
/// attoseconds value will not exceed 1e18 or be lower than -1e18. /// attoseconds value will not exceed 1e18 or be lower than -1e18.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public var components: (seconds: Int64, attoseconds: Int64) { public var components: (seconds: Int64, attoseconds: Int64) {
let (seconds, attoseconds) = _attoseconds.dividedBy1e18() let (seconds, attoseconds) = _attoseconds.dividedBy1e18()
return (Int64(seconds), Int64(attoseconds)) return (Int64(seconds), Int64(attoseconds))
@@ -129,7 +129,7 @@ extension Duration {
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Duration { extension Duration {
/// Construct a `Duration` given a number of seconds represented as a /// Construct a `Duration` given a number of seconds represented as a
/// `BinaryInteger`. /// `BinaryInteger`.
@@ -137,7 +137,7 @@ extension Duration {
/// let d: Duration = .seconds(77) /// let d: Duration = .seconds(77)
/// ///
/// - Returns: A `Duration` representing a given number of seconds. /// - Returns: A `Duration` representing a given number of seconds.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@inlinable @inlinable
public static func seconds<T: BinaryInteger>(_ seconds: T) -> Duration { public static func seconds<T: BinaryInteger>(_ seconds: T) -> Duration {
guard let high = Int64(exactly: seconds >> 64) else { fatalError() } guard let high = Int64(exactly: seconds >> 64) else { fatalError() }
@@ -170,7 +170,7 @@ extension Duration {
/// let d: Duration = .seconds(22.93) /// let d: Duration = .seconds(22.93)
/// ///
/// - Returns: A `Duration` representing a given number of seconds. /// - Returns: A `Duration` representing a given number of seconds.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func seconds(_ seconds: Double) -> Duration { public static func seconds(_ seconds: Double) -> Duration {
Duration(seconds, scale: 1_000_000_000_000_000_000) Duration(seconds, scale: 1_000_000_000_000_000_000)
} }
@@ -181,7 +181,7 @@ extension Duration {
/// let d: Duration = .milliseconds(645) /// let d: Duration = .milliseconds(645)
/// ///
/// - Returns: A `Duration` representing a given number of milliseconds. /// - Returns: A `Duration` representing a given number of milliseconds.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@inlinable @inlinable
public static func milliseconds<T: BinaryInteger>( public static func milliseconds<T: BinaryInteger>(
_ milliseconds: T _ milliseconds: T
@@ -199,7 +199,7 @@ extension Duration {
/// let d: Duration = .milliseconds(88.3) /// let d: Duration = .milliseconds(88.3)
/// ///
/// - Returns: A `Duration` representing a given number of milliseconds. /// - Returns: A `Duration` representing a given number of milliseconds.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func milliseconds(_ milliseconds: Double) -> Duration { public static func milliseconds(_ milliseconds: Double) -> Duration {
Duration(milliseconds, scale: 1_000_000_000_000_000) Duration(milliseconds, scale: 1_000_000_000_000_000)
} }
@@ -210,7 +210,7 @@ extension Duration {
/// let d: Duration = .microseconds(12) /// let d: Duration = .microseconds(12)
/// ///
/// - Returns: A `Duration` representing a given number of microseconds. /// - Returns: A `Duration` representing a given number of microseconds.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@inlinable @inlinable
public static func microseconds<T: BinaryInteger>( public static func microseconds<T: BinaryInteger>(
_ microseconds: T _ microseconds: T
@@ -228,7 +228,7 @@ extension Duration {
/// let d: Duration = .microseconds(382.9) /// let d: Duration = .microseconds(382.9)
/// ///
/// - Returns: A `Duration` representing a given number of microseconds. /// - Returns: A `Duration` representing a given number of microseconds.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func microseconds(_ microseconds: Double) -> Duration { public static func microseconds(_ microseconds: Double) -> Duration {
Duration(microseconds, scale: 1_000_000_000_000) Duration(microseconds, scale: 1_000_000_000_000)
} }
@@ -239,7 +239,7 @@ extension Duration {
/// let d: Duration = .nanoseconds(1929) /// let d: Duration = .nanoseconds(1929)
/// ///
/// - Returns: A `Duration` representing a given number of nanoseconds. /// - Returns: A `Duration` representing a given number of nanoseconds.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@inlinable @inlinable
public static func nanoseconds<T: BinaryInteger>( public static func nanoseconds<T: BinaryInteger>(
_ nanoseconds: T _ nanoseconds: T
@@ -263,10 +263,10 @@ extension Duration {
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
extension Duration: Codable { extension Duration: Codable {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public init(from decoder: Decoder) throws { public init(from decoder: Decoder) throws {
var container = try decoder.unkeyedContainer() var container = try decoder.unkeyedContainer()
let high = try container.decode(Int64.self) let high = try container.decode(Int64.self)
@@ -274,7 +274,7 @@ extension Duration: Codable {
self.init(_high: high, low: low) self.init(_high: high, low: low)
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.unkeyedContainer() var container = encoder.unkeyedContainer()
try container.encode(_high) try container.encode(_high)
@@ -282,112 +282,112 @@ extension Duration: Codable {
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Duration: Hashable { extension Duration: Hashable {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public func hash(into hasher: inout Hasher) { public func hash(into hasher: inout Hasher) {
hasher.combine(_attoseconds) hasher.combine(_attoseconds)
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Duration: Equatable { extension Duration: Equatable {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func == (_ lhs: Duration, _ rhs: Duration) -> Bool { public static func == (_ lhs: Duration, _ rhs: Duration) -> Bool {
return lhs._attoseconds == rhs._attoseconds return lhs._attoseconds == rhs._attoseconds
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Duration: Comparable { extension Duration: Comparable {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func < (_ lhs: Duration, _ rhs: Duration) -> Bool { public static func < (_ lhs: Duration, _ rhs: Duration) -> Bool {
return lhs._attoseconds < rhs._attoseconds return lhs._attoseconds < rhs._attoseconds
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Duration: AdditiveArithmetic { extension Duration: AdditiveArithmetic {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static var zero: Duration { Duration(_attoseconds: 0) } public static var zero: Duration { Duration(_attoseconds: 0) }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func + (_ lhs: Duration, _ rhs: Duration) -> Duration { public static func + (_ lhs: Duration, _ rhs: Duration) -> Duration {
return Duration(_attoseconds: lhs._attoseconds + rhs._attoseconds) return Duration(_attoseconds: lhs._attoseconds + rhs._attoseconds)
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func - (_ lhs: Duration, _ rhs: Duration) -> Duration { public static func - (_ lhs: Duration, _ rhs: Duration) -> Duration {
return Duration(_attoseconds: lhs._attoseconds - rhs._attoseconds) return Duration(_attoseconds: lhs._attoseconds - rhs._attoseconds)
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func += (_ lhs: inout Duration, _ rhs: Duration) { public static func += (_ lhs: inout Duration, _ rhs: Duration) {
lhs = lhs + rhs lhs = lhs + rhs
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func -= (_ lhs: inout Duration, _ rhs: Duration) { public static func -= (_ lhs: inout Duration, _ rhs: Duration) {
lhs = lhs - rhs lhs = lhs - rhs
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Duration { extension Duration {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func / (_ lhs: Duration, _ rhs: Double) -> Duration { public static func / (_ lhs: Duration, _ rhs: Double) -> Duration {
return Duration(_attoseconds: return Duration(_attoseconds:
_Int128(Double(lhs._attoseconds) / rhs)) _Int128(Double(lhs._attoseconds) / rhs))
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func /= (_ lhs: inout Duration, _ rhs: Double) { public static func /= (_ lhs: inout Duration, _ rhs: Double) {
lhs = lhs / rhs lhs = lhs / rhs
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func / <T: BinaryInteger>( public static func / <T: BinaryInteger>(
_ lhs: Duration, _ rhs: T _ lhs: Duration, _ rhs: T
) -> Duration { ) -> Duration {
Duration(_attoseconds: lhs._attoseconds / _Int128(rhs)) Duration(_attoseconds: lhs._attoseconds / _Int128(rhs))
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func /= <T: BinaryInteger>(_ lhs: inout Duration, _ rhs: T) { public static func /= <T: BinaryInteger>(_ lhs: inout Duration, _ rhs: T) {
lhs = lhs / rhs lhs = lhs / rhs
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func / (_ lhs: Duration, _ rhs: Duration) -> Double { public static func / (_ lhs: Duration, _ rhs: Duration) -> Double {
Double(lhs._attoseconds) / Double(rhs._attoseconds) Double(lhs._attoseconds) / Double(rhs._attoseconds)
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func * (_ lhs: Duration, _ rhs: Double) -> Duration { public static func * (_ lhs: Duration, _ rhs: Double) -> Duration {
Duration(_attoseconds: _Int128(Double(lhs._attoseconds) * rhs)) Duration(_attoseconds: _Int128(Double(lhs._attoseconds) * rhs))
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func * <T: BinaryInteger>( public static func * <T: BinaryInteger>(
_ lhs: Duration, _ rhs: T _ lhs: Duration, _ rhs: T
) -> Duration { ) -> Duration {
Duration(_attoseconds: lhs._attoseconds * _Int128(rhs)) Duration(_attoseconds: lhs._attoseconds * _Int128(rhs))
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func *= <T: BinaryInteger>(_ lhs: inout Duration, _ rhs: T) { public static func *= <T: BinaryInteger>(_ lhs: inout Duration, _ rhs: T) {
lhs = lhs * rhs lhs = lhs * rhs
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
@_unavailableInEmbedded @_unavailableInEmbedded
extension Duration: CustomStringConvertible { extension Duration: CustomStringConvertible {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public var description: String { public var description: String {
return (Double(_attoseconds) / 1e18).description + " seconds" return (Double(_attoseconds) / 1e18).description + " seconds"
} }
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension Duration: DurationProtocol { } extension Duration: DurationProtocol { }

View File

@@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// A type that defines a duration for a given `InstantProtocol` type. /// A type that defines a duration for a given `InstantProtocol` type.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public protocol DurationProtocol: Comparable, AdditiveArithmetic, Sendable { public protocol DurationProtocol: Comparable, AdditiveArithmetic, Sendable {
static func / (_ lhs: Self, _ rhs: Int) -> Self static func / (_ lhs: Self, _ rhs: Int) -> Self
static func /= (_ lhs: inout Self, _ rhs: Int) static func /= (_ lhs: inout Self, _ rhs: Int)
@@ -21,14 +21,14 @@ public protocol DurationProtocol: Comparable, AdditiveArithmetic, Sendable {
static func / (_ lhs: Self, _ rhs: Self) -> Double static func / (_ lhs: Self, _ rhs: Self) -> Double
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
extension DurationProtocol { extension DurationProtocol {
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func /= (_ lhs: inout Self, _ rhs: Int) { public static func /= (_ lhs: inout Self, _ rhs: Int) {
lhs = lhs / rhs lhs = lhs / rhs
} }
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public static func *= (_ lhs: inout Self, _ rhs: Int) { public static func *= (_ lhs: inout Self, _ rhs: Int) {
lhs = lhs * rhs lhs = lhs * rhs
} }

View File

@@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// A type that defines a specific point in time for a given `Clock`. // A type that defines a specific point in time for a given `Clock`.
@available(SwiftStdlib 5.7, *) @available(SwiftStdlibCurrentOS 5.7, *)
public protocol InstantProtocol<Duration>: Comparable, Hashable, Sendable { public protocol InstantProtocol<Duration>: Comparable, Hashable, Sendable {
associatedtype Duration: DurationProtocol associatedtype Duration: DurationProtocol
func advanced(by duration: Duration) -> Self func advanced(by duration: Duration) -> Self

View File

@@ -26,10 +26,12 @@ final class OldExecutorOldStdlib: SerialExecutor {
/// availability, since in this case the UnownedJob version needs to exist. /// availability, since in this case the UnownedJob version needs to exist.
@available(SwiftStdlib 5.1, *) @available(SwiftStdlib 5.1, *)
final class BothExecutorOldStdlib: SerialExecutor { final class BothExecutorOldStdlib: SerialExecutor {
func enqueue(_ job: UnownedJob) {} // expected-note{{'enqueue' declared here}} func enqueue(_ job: UnownedJob) {}
// This no longer warns, because of the use of SwiftStdlibCurrentOS in the
// runtime.
@available(SwiftStdlib 5.9, *) @available(SwiftStdlib 5.9, *)
func enqueue(_ job: __owned ExecutorJob) {} // expected-warning{{'Executor.enqueue(ExecutorJob)' will never be used, due to the presence of 'enqueue(UnownedJob)'}} func enqueue(_ job: __owned ExecutorJob) {}
func asUnownedSerialExecutor() -> UnownedSerialExecutor { func asUnownedSerialExecutor() -> UnownedSerialExecutor {
UnownedSerialExecutor(ordinary: self) UnownedSerialExecutor(ordinary: self)

View File

@@ -530,11 +530,59 @@ def availability_macro_to_swift_abi_target_triple(macro):
return stdlib_vers, '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os, return stdlib_vers, '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os,
os_vers, run_environment) os_vers, run_environment)
# Compare two version numbers
def version_gt(a, b):
a_int = list(map(int, a.split(".")))
b_int = list(map(int, b.split(".")))
vlen = max(len(a_int), len(b_int))
if len(a_int) < vlen:
a_int += [0] * (vlen - len(a_int))
if len(b_int) < vlen:
b_int += [0] * (vlen - len(b_int))
return a_int > b_int
# Returns a SwiftStdlibCurrentOS macro given a SwiftStdlib macro
def availability_macro_to_current(macro):
matches = re.search(r'^\s*SwiftStdlib\s+([0-9\.]*)\s*:\s*(.*)', macro)
if not matches:
return None
stdlib_vers = matches.group(1)
orig_spec = matches.group(2)
vers_by_platform = {}
for platform_vers in orig_spec.split(', '):
components = platform_vers.split(' ')
vers_by_platform[components[0]] = components[1]
platform_name = {
'macosx': 'macOS',
'ios': 'iOS',
'maccatalyst': 'iOS',
'tvos': 'tvOS',
'watchos': 'watchOS'
}.get(run_os)
orig_vers = vers_by_platform.get(platform_name)
if orig_vers is not None and orig_vers != "9999":
ver = platform.mac_ver()[0]
if version_gt(orig_vers, ver):
return f"SwiftStdlibCurrentOS {stdlib_vers}:{platform_name} {ver}"
return f"SwiftStdlibCurrentOS {stdlib_vers}:{orig_spec}"
# Add availability macros to the default frontend/driver flags and create target # Add availability macros to the default frontend/driver flags and create target
# triple substitutions for each stdlib version. # triple substitutions for each stdlib version.
for macro in load_availability_macros(): for macro in load_availability_macros():
config.swift_frontend_test_options += " -define-availability '{0}'".format(macro) config.swift_frontend_test_options += " -define-availability '{0}'".format(macro)
config.swift_driver_test_options += " -Xfrontend -define-availability -Xfrontend '{0}'".format(macro) config.swift_driver_test_options += " -Xfrontend -define-availability -Xfrontend '{0}'".format(macro)
current_macro = availability_macro_to_current(macro)
if current_macro:
config.swift_frontend_test_options += " -define-availability '{0}'".format(current_macro)
config.swift_driver_test_options += " -Xfrontend -define-availability -Xfrontend '{0}'".format(current_macro)
(stdlib_vers, triple) = availability_macro_to_swift_abi_target_triple(macro) (stdlib_vers, triple) = availability_macro_to_swift_abi_target_triple(macro)
config.substitutions.append(('%target-swift-{}-abi-triple'.format(stdlib_vers), triple)) config.substitutions.append(('%target-swift-{}-abi-triple'.format(stdlib_vers), triple))

View File

@@ -15,6 +15,15 @@
# Each of the remaining lines must define an availability macro in the same # Each of the remaining lines must define an availability macro in the same
# format used by the `-define-availability` frontend command line option. # format used by the `-define-availability` frontend command line option.
# NOTE: The build system will define another macro, SwiftStdlibCurrentOS,
# for each SwiftStdlib macro defined in this file. The difference
# between the two is the the CurrentOS macro will never be set to a
# higher version than the machine on which we are building.
#
# This is to allow for use of new functions and types within the
# standard libraries, in such a way that these usages will work on
# our CI machines.
# 9999 is the generic unknown future Swift release. It always needs to resolve # 9999 is the generic unknown future Swift release. It always needs to resolve
# to the special placeholder version numbers 9999. # to the special placeholder version numbers 9999.

View File

@@ -216,6 +216,7 @@ KNOWN_SETTINGS=(
swift-runtime-enable-leak-checker "0" "Enable leaks checking routines in the runtime" swift-runtime-enable-leak-checker "0" "Enable leaks checking routines in the runtime"
swift-stdlib-enable-assertions "1" "enable assertions in Swift" swift-stdlib-enable-assertions "1" "enable assertions in Swift"
swift-stdlib-enable-debug-preconditions-in-release "0" "Enable _debugPrecondition checks in the stdlib in Release configurations" swift-stdlib-enable-debug-preconditions-in-release "0" "Enable _debugPrecondition checks in the stdlib in Release configurations"
swift-stdlib-enable-strict-availability "0" "enable strict availability checking in the stdlib"
swift-tools-enable-lto "" "enable LTO compilation of Swift tools. *NOTE* This does not include the swift standard library and runtime. Must be set to one of 'thin' or 'full'" swift-tools-enable-lto "" "enable LTO compilation of Swift tools. *NOTE* This does not include the swift standard library and runtime. Must be set to one of 'thin' or 'full'"
extra-swift-args "" "Extra arguments to pass to swift modules which match regex. Assumed to be a flattened cmake list consisting of [module_regexp, args, module_regexp, args, ...]" extra-swift-args "" "Extra arguments to pass to swift modules which match regex. Assumed to be a flattened cmake list consisting of [module_regexp, args, module_regexp, args, ...]"
report-statistics "0" "set to 1 to generate compilation statistics files for swift libraries" report-statistics "0" "set to 1 to generate compilation statistics files for swift libraries"
@@ -1738,6 +1739,7 @@ for host in "${ALL_HOSTS[@]}"; do
-DSWIFT_STDLIB_BUILD_TYPE:STRING="${SWIFT_STDLIB_BUILD_TYPE}" -DSWIFT_STDLIB_BUILD_TYPE:STRING="${SWIFT_STDLIB_BUILD_TYPE}"
-DSWIFT_STDLIB_ASSERTIONS:BOOL=$(true_false "${SWIFT_STDLIB_ENABLE_ASSERTIONS}") -DSWIFT_STDLIB_ASSERTIONS:BOOL=$(true_false "${SWIFT_STDLIB_ENABLE_ASSERTIONS}")
-DSWIFT_STDLIB_ENABLE_DEBUG_PRECONDITIONS_IN_RELEASE=$(true_false "${SWIFT_STDLIB_ENABLE_DEBUG_PRECONDITIONS_IN_RELEASE}") -DSWIFT_STDLIB_ENABLE_DEBUG_PRECONDITIONS_IN_RELEASE=$(true_false "${SWIFT_STDLIB_ENABLE_DEBUG_PRECONDITIONS_IN_RELEASE}")
-DSWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY:BOOL=$(true_false "${SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY}")
-DSWIFT_ENABLE_DISPATCH:BOOL=$(true_false "${SWIFT_ENABLE_DISPATCH}") -DSWIFT_ENABLE_DISPATCH:BOOL=$(true_false "${SWIFT_ENABLE_DISPATCH}")
-DSWIFT_IMPLICIT_CONCURRENCY_IMPORT:BOOL=$(true_false "${SWIFT_IMPLICIT_CONCURRENCY_IMPORT}") -DSWIFT_IMPLICIT_CONCURRENCY_IMPORT:BOOL=$(true_false "${SWIFT_IMPLICIT_CONCURRENCY_IMPORT}")
-DSWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT:BOOL=$(true_false "${SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT}") -DSWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT:BOOL=$(true_false "${SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT}")
@@ -1923,6 +1925,13 @@ for host in "${ALL_HOSTS[@]}"; do
) )
fi fi
if [ "${SWIFT_FREESTANDING_AVAILABILITY_NAME}" ] ; then
cmake_options=(
"${cmake_options[@]}"
-DSWIFT_FREESTANDING_TRIPLE_NAME:STRING="${SWIFT_FREESTANDING_TRIPLE_NAME}"
)
fi
if [ "${SWIFT_FREESTANDING_MODULE_NAME}" ] ; then if [ "${SWIFT_FREESTANDING_MODULE_NAME}" ] ; then
cmake_options=( cmake_options=(
"${cmake_options[@]}" "${cmake_options[@]}"

View File

@@ -129,6 +129,9 @@ def _apply_default_arguments(args):
if args.lldb_assertions is None: if args.lldb_assertions is None:
args.lldb_assertions = args.assertions args.lldb_assertions = args.assertions
if args.swift_stdlib_strict_availability is None:
args.swift_stdlib_strict_availability = False
# --ios-all etc are not supported by open-source Swift. # --ios-all etc are not supported by open-source Swift.
if args.ios_all: if args.ios_all:
raise ValueError('error: --ios-all is unavailable in open-source ' raise ValueError('error: --ios-all is unavailable in open-source '
@@ -1029,6 +1032,14 @@ def create_argument_parser():
const=False, const=False,
help='disable assertions in llbuild') help='disable assertions in llbuild')
option('--swift-stdlib-strict-availability', store,
const=True,
help='enable strict availability checking in the Swift standard library (you want this OFF for CI or at-desk builds)')
option('--no-swift-stdlib-strict-availability',
store('swift_stdlib_strict_availability'),
const=False,
help='disable strict availability checking in the Swift standard library (you want this OFF for CI or at-desk builds)')
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
in_group('Select the CMake generator') in_group('Select the CMake generator')

View File

@@ -515,6 +515,10 @@ class TestDriverArgumentParser(
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
self.parse_default_args(['--watchos-all']) self.parse_default_args(['--watchos-all'])
def test_swift_stdlib_strict_availability(self):
self.parse_default_args('--swift-stdlib-strict-availability')
self.parse_default_args('--no-swift-stdlib-strict-availability')
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Implied defaults tests # Implied defaults tests

View File

@@ -271,6 +271,7 @@ EXPECTED_DEFAULTS = {
'swift_profile_instr_use': None, 'swift_profile_instr_use': None,
'swift_runtime_fixed_backtracer_path': None, 'swift_runtime_fixed_backtracer_path': None,
'swift_stdlib_assertions': True, 'swift_stdlib_assertions': True,
'swift_stdlib_strict_availability': False,
'swift_stdlib_build_variant': 'Debug', 'swift_stdlib_build_variant': 'Debug',
'swift_tools_ld64_lto_codegen_only_for_supporting_targets': False, 'swift_tools_ld64_lto_codegen_only_for_supporting_targets': False,
'swift_tools_max_parallel_lto_link_jobs': 'swift_tools_max_parallel_lto_link_jobs':
@@ -550,6 +551,10 @@ EXPECTED_OPTIONS = [
SetOption('--skip-test-early-swift-driver', SetOption('--skip-test-early-swift-driver',
dest='test_early_swift_driver', value=False), dest='test_early_swift_driver', value=False),
SetOption('--swift-stdlib-strict-availability', value=True),
SetOption('--no-swift-stdlib-strict-availability',
dest='swift_stdlib_strict_availability', value=False),
SetFalseOption('--no-llvm-include-tests', dest='llvm_include_tests'), SetFalseOption('--no-llvm-include-tests', dest='llvm_include_tests'),
SetTrueOption('--install-back-deploy-concurrency', SetTrueOption('--install-back-deploy-concurrency',

View File

@@ -108,6 +108,8 @@ class BuildScriptInvocation(object):
"--swift-enable-assertions", str(args.swift_assertions).lower(), "--swift-enable-assertions", str(args.swift_assertions).lower(),
"--swift-stdlib-enable-assertions", str( "--swift-stdlib-enable-assertions", str(
args.swift_stdlib_assertions).lower(), args.swift_stdlib_assertions).lower(),
"--swift-stdlib-enable-strict-availability", str(
args.swift_stdlib_strict_availability).lower(),
"--swift-analyze-code-coverage", str( "--swift-analyze-code-coverage", str(
args.swift_analyze_code_coverage).lower(), args.swift_analyze_code_coverage).lower(),
"--llbuild-enable-assertions", str( "--llbuild-enable-assertions", str(

View File

@@ -69,6 +69,8 @@ class MinimalStdlib(cmake_product.CMakeProduct):
self.cmake_options.define('SWIFT_FREESTANDING_SDK:STRING', 'macosx') self.cmake_options.define('SWIFT_FREESTANDING_SDK:STRING', 'macosx')
self.cmake_options.define( self.cmake_options.define(
'SWIFT_FREESTANDING_TRIPLE_NAME:STRING', 'macosx11.0') 'SWIFT_FREESTANDING_TRIPLE_NAME:STRING', 'macosx11.0')
self.cmake_options.define(
'SWIFT_FREESTANDING_AVAILABILITY_NAME:STRING', 'macOS')
self.cmake_options.define( self.cmake_options.define(
'SWIFT_PRIMARY_VARIANT_ARCH:STRING', 'x86_64') 'SWIFT_PRIMARY_VARIANT_ARCH:STRING', 'x86_64')
self.cmake_options.define( self.cmake_options.define(