Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
"${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
"Use the host compiler and not the internal clang to build the swift runtime"
FALSE)
Expand Down Expand Up @@ -1404,8 +1408,9 @@ endif()

if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
message(STATUS "Building Swift standard library and overlays for SDKs: ${SWIFT_SDKS}")
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
message(STATUS " Strict availability: ${SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY}")
message(STATUS "")

message(STATUS "Building Swift runtime with:")
Expand Down
3 changes: 2 additions & 1 deletion Runtimes/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ set(SwiftCore_VENDOR_MODULE_DIR "${SwiftCore_CMAKE_MODULES_DIR}/vendor"
include(GNUInstallDirs)
include(CheckSymbolExists)
include(CheckIncludeFileCXX)
include(AvailabilityMacros)
include(CompilerSettings)
include(DefaultSettings)
include(EmitSwiftInterface)
include(PlatformInfo)
include(gyb)
include(ResourceEmbedding)
include(CatalystSupport)
include(AvailabilityMacros)

check_symbol_exists("asl_log" "asl.h" SwiftCore_HAS_ASL)
check_symbol_exists("dladdr" "dlfcn.h" SwiftCore_HAS_DLADDR)
Expand Down Expand Up @@ -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_option(SwiftCore_ENABLE_FATALERROR_BACKTRACE "Build stdlib fatalError with backtrace output")
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_RUNTIME_LEAK_CHECKER "" OFF)
Expand Down
2 changes: 2 additions & 0 deletions Runtimes/Core/cmake/caches/Vendors/Apple/apple-common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ set(SwiftCore_ENABLE_VECTOR_TYPES ON CACHE BOOL "")
set(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS ON CACHE BOOL "")
set(SwiftCore_ENABLE_BACKDEPLOYMENT_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_INSTALL_NESTED_SUBDIR OFF CACHE BOOL "")
Expand Down
28 changes: 28 additions & 0 deletions Runtimes/Core/cmake/modules/AvailabilityMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,32 @@ file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/availability-macros.def" availability_
list(FILTER availability_defs EXCLUDE REGEX "^\\s*(#.*)?$")
foreach(def ${availability_defs})
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${def}\">")

if("${def}" MATCHES "SwiftStdlib .*")
# For each SwiftStdlib x.y, also define SwiftStdlibCurrentOS 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)
if(SwiftCore_SWIFT_AVAILABILITY_PLATFORM STREQUAL "macOS" and SwiftCore_VARIANT_AVAILABILITY_PLATFORM STREQUAL "iOS")
string(REGEX MATCH "iOS ([0-9]+(\.[0-9]+)+)" ios_platform_version "${def}")
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" ios_version "${ios_platform_version}")
string(REGEX MATCH "macOS ([0-9]+(\.[0-9]+)+)" macos_platform_version "${def}")
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" macos_version "${macos_platform_version}")
if((NOT macos_version STREQUAL "9999" OR NOT ios_version STREQUAL "9999") AND (macos_version VERSION_GREATER CMAKE_OSX_DEPLOYMENT_TARGET OR ios_version VERSION_GREATER SwiftCore_VARIANT_DEPLOYMENT_VERSION))
string(REGEX REPLACE ":.*" ": macOS ${CMAKE_OSX_DEPLOYMENT_VERSION}, iOS ${SwiftCore_VARIANT_DEPLOYMENT_VERSION}" current "${current}")
endif()
else()
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()
endif()
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${current}\">")
endif()
endforeach()
7 changes: 7 additions & 0 deletions Runtimes/Core/cmake/modules/CatalystSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,12 @@ if(SwiftCore_COMPILER_VARIANT_TARGET)
set(SwiftCore_VARIANT_MODULE_TRIPLE "${module_triple}" CACHE STRING "Triple used for installed swift{module,interface} files for the target variant")
mark_as_advanced(SwiftCore_VARIANT_MODULE_TRIPLE)
message(CONFIGURE_LOG "Swift target variant module triple: ${module_triple}")

string(JSON triple GET "${target_info_json}" "target" "triple")
if(triple MATCHES "apple-([a-zA-Z]+)([0-9]+[.0-9]*)-macabi")
set(SwiftCore_VARIANT_DEPLOYMENT_VERSION "${CMAKE_MATCH_2}")
mark_as_advanced(SwiftCore_VARIANT_DEPLOYMENT_VERSION)
message(CONFIGURE_LOG "Swift target variant deployment version: ${SwiftCore_VARIANT_DEPLOYMENT_VERSION}")
endif()
endif()
endif()
4 changes: 3 additions & 1 deletion Runtimes/Core/cmake/modules/DefaultSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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_TYPE_PRINTING_default ON)

set(SwiftCore_ENABLE_STRICT_AVAILABILITY_default OFF)

set(SwiftCore_BACKTRACER_PATH_default "")

# Provide a boolean option that a user can optionally enable.
Expand All @@ -20,7 +22,7 @@ macro(defaulted_option variable helptext)
if(NOT DEFINED ${variable}_default)
set(${variable}_default OFF)
endif()
option(${variable} ${helptext} ${${variable}_default})
option(${variable} "${helptext}" ${${variable}_default})
endmacro()

# Create a defaulted cache entry
Expand Down
37 changes: 37 additions & 0 deletions Runtimes/Core/cmake/modules/PlatformInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,40 @@ if(NOT SwiftCore_ARCH_SUBDIR)

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

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(NOT SwiftCore_SWIFT_AVAILABILITY_PLATFORM)
if(SwiftCore_SWIFT_MODULE_TRIPLE MATCHES ".*-([^-]+)-simulator$")
set(platform "${CMAKE_MATCH_1}")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should be able to get this information from the platform entry in the target info without needing to regex it out of the module triple.

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

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()

if(SwiftCore_VARIANT_MODULE_TRIPLE)
if(SwiftCore_VARIANT_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_VARIANT_AVAILABILITY_PLATFORM "${availability_platform_${platform}}")
else()
message(ERROR "Unknown platform ${platform} for variant availability")
endif()
endif()
23 changes: 13 additions & 10 deletions cmake/modules/DarwinSDKs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ is_sdk_requested(OSX swift_build_osx)
if(swift_build_osx)
configure_sdk_darwin(
OSX "OS X" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX}"
macosx macosx macos "${SUPPORTED_OSX_ARCHS}")
macosx macosx macos macOS "${SUPPORTED_OSX_ARCHS}")
configure_target_variant(OSX-DA "OS X Debug+Asserts" OSX DA "Debug+Asserts")
configure_target_variant(OSX-RA "OS X Release+Asserts" OSX RA "Release+Asserts")
configure_target_variant(OSX-R "OS X Release" OSX R "Release")
Expand All @@ -26,12 +26,15 @@ if(swift_build_freestanding AND (SWIFT_FREESTANDING_FLAVOR STREQUAL "apple"))
"Which triple name (e.g. 'none-macho') to use when building the FREESTANDING stdlib")
set(SWIFT_FREESTANDING_MODULE_NAME "" CACHE STRING
"Which .swiftmodule name (e.g. 'freestanding') to use when building the FREESTANDING stdlib")
set(SWIFT_FREESTANDING_AVAILABILITY_NAME "" CACHE STRING
"Which @availability name (e.g. 'macOS') to use when building the FREESTANDING stdlib")
set(SWIFT_FREESTANDING_ARCHS "" CACHE STRING
"Which architectures to build when building the FREESTANDING stdlib")
configure_sdk_darwin(
FREESTANDING "FREESTANDING" ""
"${SWIFT_FREESTANDING_SDK}"
"${SWIFT_FREESTANDING_TRIPLE_NAME}" "${SWIFT_FREESTANDING_MODULE_NAME}" "${SWIFT_FREESTANDING_ARCHS}")
"${SWIFT_FREESTANDING_TRIPLE_NAME}" "${SWIFT_FREESTANDING_MODULE_NAME}"
"${SWIFT_FREESTANDING_AVAILABILITY_NAME}" "${SWIFT_FREESTANDING_ARCHS}")
set(SWIFT_SDK_FREESTANDING_LIB_SUBDIR "freestanding")
configure_target_variant(FREESTANDING-DA "FREESTANDING Debug+Asserts" FREESTANDING DA "Debug+Asserts")
configure_target_variant(FREESTANDING-RA "FREESTANDING Release+Asserts" FREESTANDING RA "Release+Asserts")
Expand All @@ -53,7 +56,7 @@ is_sdk_requested(IOS swift_build_ios)
if(swift_build_ios)
configure_sdk_darwin(
IOS "iOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
iphoneos ios ios "${SUPPORTED_IOS_ARCHS}")
iphoneos ios ios iOS "${SUPPORTED_IOS_ARCHS}")
configure_target_variant(IOS-DA "iOS Debug+Asserts" IOS DA "Debug+Asserts")
configure_target_variant(IOS-RA "iOS Release+Asserts" IOS RA "Release+Asserts")
configure_target_variant(IOS-R "iOS Release" IOS R "Release")
Expand All @@ -63,7 +66,7 @@ is_sdk_requested(IOS_SIMULATOR swift_build_ios_simulator)
if(swift_build_ios_simulator)
configure_sdk_darwin(
IOS_SIMULATOR "iOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
iphonesimulator ios ios-simulator
iphonesimulator ios ios-simulator iOS
"${SUPPORTED_IOS_SIMULATOR_ARCHS}")
configure_target_variant(
IOS_SIMULATOR-DA "iOS Debug+Asserts" IOS_SIMULATOR DA "Debug+Asserts")
Expand All @@ -77,7 +80,7 @@ is_sdk_requested(TVOS swift_build_tvos)
if(swift_build_tvos)
configure_sdk_darwin(
TVOS "tvOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvos tvos tvos "${SUPPORTED_TVOS_ARCHS}")
appletvos tvos tvos tvOS "${SUPPORTED_TVOS_ARCHS}")
configure_target_variant(TVOS-DA "tvOS Debug+Asserts" TVOS DA "Debug+Asserts")
configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts")
configure_target_variant(TVOS-R "tvOS Release" TVOS R "Release")
Expand All @@ -87,7 +90,7 @@ is_sdk_requested(TVOS_SIMULATOR swift_build_tvos_simulator)
if(swift_build_tvos_simulator)
configure_sdk_darwin(
TVOS_SIMULATOR "tvOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
appletvsimulator tvos tvos-simulator
appletvsimulator tvos tvos-simulator tvOS
"${SUPPORTED_TVOS_SIMULATOR_ARCHS}")
configure_target_variant(
TVOS_SIMULATOR-DA "tvOS Debug+Asserts" TVOS_SIMULATOR DA "Debug+Asserts")
Expand All @@ -101,7 +104,7 @@ is_sdk_requested(WATCHOS swift_build_watchos)
if(swift_build_watchos)
configure_sdk_darwin(
WATCHOS "watchOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
watchos watchos watchos "${SUPPORTED_WATCHOS_ARCHS}")
watchos watchos watchos watchOS "${SUPPORTED_WATCHOS_ARCHS}")
configure_target_variant(WATCHOS-DA "watchOS Debug+Asserts" WATCHOS DA "Debug+Asserts")
configure_target_variant(WATCHOS-RA "watchOS Release+Asserts" WATCHOS RA "Release+Asserts")
configure_target_variant(WATCHOS-R "watchOS Release" WATCHOS R "Release")
Expand All @@ -111,7 +114,7 @@ is_sdk_requested(WATCHOS_SIMULATOR swift_build_watchos_simulator)
if(swift_build_watchos_simulator)
configure_sdk_darwin(
WATCHOS_SIMULATOR "watchOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
watchsimulator watchos watchos-simulator
watchsimulator watchos watchos-simulator watchOS
"${SUPPORTED_WATCHOS_SIMULATOR_ARCHS}")
configure_target_variant(WATCHOS_SIMULATOR-DA "watchOS Debug+Asserts" WATCHOS_SIMULATOR DA "Debug+Asserts")
configure_target_variant(WATCHOS_SIMULATOR-RA "watchOS Release+Asserts" WATCHOS_SIMULATOR RA "Release+Asserts")
Expand All @@ -122,7 +125,7 @@ is_sdk_requested(XROS swift_build_xros)
if(swift_build_xros)
configure_sdk_darwin(
XROS "xrOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}"
xros xros xros "${SUPPORTED_XROS_ARCHS}")
xros xros xros visionOS "${SUPPORTED_XROS_ARCHS}")
configure_target_variant(XROS-DA "xrOS Debug+Asserts" XROS DA "Debug+Asserts")
configure_target_variant(XROS-RA "xrOS Release+Asserts" XROS RA "Release+Asserts")
configure_target_variant(XROS-R "xrOS Release" XROS R "Release")
Expand All @@ -132,7 +135,7 @@ is_sdk_requested(XROS_SIMULATOR swift_build_xros_simulator)
if(swift_build_xros_simulator)
configure_sdk_darwin(
XROS_SIMULATOR "xrOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}"
xrsimulator xros xros-simulator
xrsimulator xros xros-simulator visionOS
"${SUPPORTED_XROS_SIMULATOR_ARCHS}")

configure_target_variant(
Expand Down
6 changes: 5 additions & 1 deletion cmake/modules/SwiftConfigureSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ endfunction()
# deployment_version # Deployment version
# xcrun_name # SDK name to use with xcrun
# triple_name # The name used in Swift's -triple
# availability_name # The name used in Swift's @availability
# architectures # A list of architectures this SDK supports
# )
#
Expand Down Expand Up @@ -165,9 +166,11 @@ endfunction()
# SWIFT_SDK_${prefix}_ARCH_${ARCH}_TRIPLE Triple name
# SWIFT_SDK_${prefix}_ARCH_${ARCH}_MODULE Module triple name for this SDK
# SWIFT_SDK_${prefix}_USE_BUILD_ID Whether to pass --build-id to the linker
# SWIFT_SDK_${prefix}_AVAILABILITY_NAME Name to use in @availability
#
macro(configure_sdk_darwin
prefix name deployment_version xcrun_name
triple_name module_name architectures)
triple_name module_name availability_name architectures)
# Note: this has to be implemented as a macro because it sets global
# variables.

Expand Down Expand Up @@ -201,6 +204,7 @@ macro(configure_sdk_darwin
set(SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION "${deployment_version}")
set(SWIFT_SDK_${prefix}_LIB_SUBDIR "${xcrun_name}")
set(SWIFT_SDK_${prefix}_TRIPLE_NAME "${triple_name}")
set(SWIFT_SDK_${prefix}_AVAILABILITY_NAME "${availability_name}")
set(SWIFT_SDK_${prefix}_OBJECT_FORMAT "MACHO")
set(SWIFT_SDK_${prefix}_USE_ISYSROOT TRUE)
set(SWIFT_SDK_${prefix}_SHARED_LIBRARY_PREFIX "lib")
Expand Down
35 changes: 35 additions & 0 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,41 @@ function(add_swift_target_library_single target name)
# Define availability macros.
foreach(def ${SWIFT_STDLIB_AVAILABILITY_DEFINITIONS})
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-Xfrontend" "-define-availability" "-Xfrontend" "${def}")

if("${def}" MATCHES "SwiftStdlib .*")
# For each SwiftStdlib x.y, also define SwiftStdlibCurrentOS 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)
if(SWIFTLIB_SINGLE_SDK STREQUAL "OSX" AND SWIFTLIB_SINGLE_MACCATALYST_BUILD_FLAVOR STREQUAL "ios-like")
string(REGEX MATCH "iOS ([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_DARWIN_DEPLOYMENT_VERSION_MACCATALYST}")
string(REGEX REPLACE ":.*" ":iOS ${SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST}" current "${current}")
endif()
elseif(SWIFTLIB_SINGLE_SDK STREQUAL "OSX" AND SWIFTLIB_SINGLE_MACCATALYST_BUILD_FLAVOR STREQUAL "zippered")
string(REGEX MATCH "iOS ([0-9]+(\.[0-9]+)+)" ios_platform_version "${def}")
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" ios_version "${ios_platform_version}")
string(REGEX MATCH "macOS ([0-9]+(\.[0-9]+)+)" macos_platform_version "${def}")
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" macos_version "${macos_platform_version}")
if((NOT macos_version STREQUAL "9999" OR NOT ios_version STREQUAL "9999") AND (macos_version VERSION_GREATER "${SWIFT_SDK_OSX_DEPLOYMENT_VERSION}" OR ios_version VERSION_GREATER "${SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST}"))
string(REGEX REPLACE ":.*" ": macOS ${SWIFT_SDK_OSX_DEPLOYMENT_VERSION}, iOS ${SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST}" current "${current}")
endif()
else()
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()
endif()

list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-Xfrontend" "-define-availability" "-Xfrontend" "${current}")
endif()
endforeach()

# Enable -target-min-inlining-version
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/Concurrency/CFExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ enum CoreFoundation {

// .. Main Executor ............................................................

@available(SwiftStdlib 6.2, *)
@available(SwiftStdlibCurrentOS 6.2, *)
public final class CFMainExecutor: DispatchMainExecutor, @unchecked Sendable {

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

// .. Task Executor ............................................................

@available(SwiftStdlib 6.2, *)
@available(SwiftStdlibCurrentOS 6.2, *)
public final class CFTaskExecutor: DispatchGlobalTaskExecutor,
@unchecked Sendable {

Expand Down
9 changes: 9 additions & 0 deletions stdlib/public/Concurrency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ if((SWIFT_BUILD_CLANG_OVERLAYS
set(SWIFT_CONCURRENCY_DEPENDENCIES _Builtin_float)
endif()

# Build with a minimum deployment target of 10.15
if(SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX VERSION_LESS "10.15")
set(osx_deployment_target "10.15")
else()
set(osx_deployment_target "${SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX}")
endif()

add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
${SWIFT_RUNTIME_CONCURRENCY_C_SOURCES}
${SWIFT_RUNTIME_CONCURRENCY_EXECUTOR_SOURCES}
Expand All @@ -240,6 +247,8 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
${swift_concurrency_incorporate_object_libraries_so}
LINK_LIBRARIES ${swift_concurrency_link_libraries}

DEPLOYMENT_VERSION_OSX ${osx_deployment_target}

C_COMPILE_FLAGS
-Dswift_Concurrency_EXPORTS ${SWIFT_RUNTIME_CONCURRENCY_C_FLAGS}
-I${SWIFT_SOURCE_DIR}/stdlib/include
Expand Down
Loading