Skip to content

Commit ebd7b49

Browse files
committed
Build compiler, other libraries, and tests for back-deployed concurrency.
When build-script is given `--back-deploy-concurrency`, also use that to build other parts of Swift with the back-deployed versions: * The compiler allows async and actors to be defined with the back-deployed availability, e.g., the same as `-Xfrontend -enable-experimental-back-deploy-concurrency`. (The latter will go away soon) * The standard library unit testing framework and distributed actors library are build with the older OS versions. * The tests use the older OS versions, with some adjustments to make them agnostic to the back-deployment setting.
1 parent 602937d commit ebd7b49

File tree

11 files changed

+57
-22
lines changed

11 files changed

+57
-22
lines changed

stdlib/private/StdlibUnittest/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ if (SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED)
2020
list(APPEND swift_stdlib_unittest_link_libraries "swift_Distributed")
2121
endif()
2222

23+
if (SWIFT_ALLOW_BACK_DEPLOY_CONCURRENCY)
24+
set(swift_concurrency_availability "macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0")
25+
else()
26+
set(swift_concurrency_availability "macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0")
27+
endif()
28+
2329
add_swift_target_library(swiftStdlibUnittest ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
2430
# This file should be listed the first. Module name is inferred from the
2531
# filename.
@@ -55,7 +61,7 @@ add_swift_target_library(swiftStdlibUnittest ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES}
5561
SWIFT_MODULE_DEPENDS_WINDOWS CRT WinSDK
5662
SWIFT_COMPILE_FLAGS ${swift_stdlib_unittest_compile_flags} ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
5763
-Xfrontend -define-availability
58-
-Xfrontend \"SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0\"
64+
-Xfrontend "SwiftStdlib 5.5:${swift_concurrency_availability}"
5965
INSTALL_IN_COMPONENT stdlib-experimental
6066
DARWIN_INSTALL_NAME_DIR "${SWIFT_DARWIN_STDLIB_PRIVATE_INSTALL_NAME_DIR}"
6167
LINK_LIBRARIES ${swift_stdlib_unittest_link_libraries})

stdlib/public/BackDeployConcurrency/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ endforeach()
3838

3939
# Build the concurrency library for back deployment.
4040
add_compile_definitions(SWIFT_CONCURRENCY_BACK_DEPLOYMENT)
41-
set(swift_concurrency_swift_flags -Xfrontend -enable-experimental-back-deploy-concurrency)
4241
set(swift_concurrency_install_component back-deployment)
4342
set(swift_concurrency_options BACK_DEPLOYMENT_LIBRARY 5.5)
4443

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
9999
-Dswift_Concurrency_EXPORTS
100100
SWIFT_COMPILE_FLAGS
101101
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
102-
${swift_concurrency_swift_flags}
103102
-parse-stdlib
104103
-Xfrontend -enable-experimental-concurrency
105104
-Xfrontend -define-availability

stdlib/public/Distributed/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
set(swift_distributed_link_libraries
1414
swiftCore)
1515

16+
17+
if (SWIFT_ALLOW_BACK_DEPLOY_CONCURRENCY)
18+
set(swift_concurrency_availability "macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0")
19+
else()
20+
set(swift_concurrency_availability "macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0")
21+
endif()
22+
1623
add_swift_target_library(swift_Distributed ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
1724
AssertDistributed.swift
1825
ActorTransport.swift
@@ -34,7 +41,7 @@ add_swift_target_library(swift_Distributed ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
3441
-parse-stdlib
3542
-Xfrontend -enable-experimental-distributed
3643
-Xfrontend -define-availability
37-
-Xfrontend \"SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0\"
44+
-Xfrontend "SwiftStdlib 5.5:${swift_concurrency_availability}"
3845
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
3946

4047
SWIFT_MODULE_DEPENDS _Concurrency

test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ normalize_boolean_spelling(SWIFT_BUILD_SYNTAXPARSERLIB)
181181
normalize_boolean_spelling(SWIFT_ENABLE_SOURCEKIT_TESTS)
182182
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING)
183183
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)
184+
normalize_boolean_spelling(SWIFT_ALLOW_BACK_DEPLOY_CONCURRENCY)
184185
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED)
185186
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" SWIFT_OPTIMIZED)
186187

@@ -358,6 +359,10 @@ foreach(SDK ${SWIFT_SDKS})
358359
list(APPEND LIT_ARGS "--param" "concurrency")
359360
endif()
360361

362+
if(SWIFT_ALLOW_BACK_DEPLOY_CONCURRENCY)
363+
list(APPEND LIT_ARGS "--param" "back_deploy_concurrency")
364+
endif()
365+
361366
if(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED)
362367
list(APPEND LIT_ARGS "--param" "distributed")
363368
endif()

test/Concurrency/concurrency_availability.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -parse-stdlib -target x86_64-apple-macosx10.15 -typecheck -verify %s
1+
// RUN: %target-swift-frontend -parse-stdlib -target x86_64-apple-macosx10.14 -typecheck -verify %s
22
// RUN: %target-swift-frontend -parse-stdlib -target x86_64-apple-macosx12 -typecheck %s
33
// REQUIRES: OS=macosx
44

test/IRGen/async/weak_availability.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -enable-implicit-dynamic -target %target-cpu-apple-macosx11 -Onone -emit-ir %s | %FileCheck --check-prefix=MAYBE-AVAILABLE %s
1+
// RUN: %target-swift-frontend -enable-implicit-dynamic -target %target-cpu-apple-macosx10.14 -Onone -emit-ir %s | %FileCheck --check-prefix=MAYBE-AVAILABLE %s
22
// REQUIRES: OS=macosx && CPU=x86_64
33

44
@available(macOS 12.0, *)

test/ModuleInterface/actor_isolation.swift

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,70 +11,84 @@
1111
// REQUIRES: concurrency
1212

1313
// CHECK: public actor SomeActor
14-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
14+
15+
@available(SwiftStdlib 5.5, *)
1516
public actor SomeActor {
1617
nonisolated func maine() { }
1718
}
1819

1920
// CHECK: @globalActor public struct SomeGlobalActor
20-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
21+
22+
@available(SwiftStdlib 5.5, *)
2123
@globalActor
2224
public struct SomeGlobalActor {
2325
public static let shared = SomeActor()
2426
}
2527

2628
// CHECK: @{{(Test.)?}}SomeGlobalActor public protocol P1
2729
// CHECK-NEXT: @{{(Test.)?}}SomeGlobalActor func method()
28-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
30+
31+
@available(SwiftStdlib 5.5, *)
2932
@SomeGlobalActor
3033
public protocol P1 {
3134
func method()
3235
}
3336

3437
// CHECK: class C1
3538
// CHECK-NEXT: @{{(Test.)?}}SomeGlobalActor public func method()
36-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
39+
40+
@available(SwiftStdlib 5.5, *)
3741
public class C1: P1 {
3842
public func method() { }
3943
}
4044

41-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
45+
46+
@available(SwiftStdlib 5.5, *)
4247
@SomeGlobalActor
4348
public class C2 { }
4449

4550
// CHECK: @{{(Test.)?}}SomeGlobalActor public class C2
46-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
51+
52+
@available(SwiftStdlib 5.5, *)
4753
public class C3: C2 { }
4854

4955
// CHECK: public class C4 : Swift.UnsafeSendable
50-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
56+
57+
@available(SwiftStdlib 5.5, *)
5158
public class C4: UnsafeSendable { }
5259

5360
// CHECK: public class C5 : @unchecked Swift.Sendable
54-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
61+
62+
@available(SwiftStdlib 5.5, *)
5563
public class C5: @unchecked Sendable { }
5664

57-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
65+
66+
@available(SwiftStdlib 5.5, *)
5867
public class C6 { }
5968

6069
// CHECK: extension {{(Test.)?}}C6 : @unchecked Swift.Sendable
61-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
70+
71+
@available(SwiftStdlib 5.5, *)
6272
extension C6: @unchecked Sendable { }
6373

64-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
74+
75+
@available(SwiftStdlib 5.5, *)
6576
public class C7 { }
6677

6778
// CHECK: extension {{(Test.)?}}C7 : Swift.UnsafeSendable
68-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
79+
80+
@available(SwiftStdlib 5.5, *)
6981
extension C7: UnsafeSendable { }
7082

71-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
83+
84+
@available(SwiftStdlib 5.5, *)
7285
public protocol P2 {
7386
@SomeGlobalActor func method()
7487
}
7588

76-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
89+
7790
// CHECK: class {{(Test.)?}}C8 : {{(Test.)?}}P2 {
91+
@available(SwiftStdlib 5.5, *)
7892
public class C8 : P2 {
7993
// CHECK: @{{(Test.)?}}SomeGlobalActor public func method()
8094
public func method() {}

test/ModuleInterface/actor_objc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ import Foundation
1515
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers
1616
// CHECK: public actor SomeActor : ObjectiveC.NSObject {
1717
// CHECK: @objc override public init()
18-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
18+
@available(SwiftStdlib 5.5, *)
1919
public actor SomeActor: NSObject {
2020
}

test/lit.cfg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,10 @@ config.swift_test_options = '-swift-version ' + swift_version
408408

409409
# Define a macro for the next release OS version.
410410
# This macro can be used in code as `@available(SwiftStdlib 5.5, *)`.
411-
swift_stdlib_macro = '\'SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0\''
411+
if 'back_deploy_concurrency' in lit_config.params:
412+
swift_stdlib_macro = '\'SwiftStdlib 5.5:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0\''
413+
else:
414+
swift_stdlib_macro = '\'SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0\''
412415
config.swift_frontend_test_options += ' -define-availability ' + swift_stdlib_macro
413416
config.swift_driver_test_options += ' -Xfrontend -define-availability -Xfrontend ' + swift_stdlib_macro
414417

test/lit.site.cfg.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ if "@SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING@" == "TRUE":
134134
config.available_features.add('differentiable_programming')
135135
if "@SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY@" == "TRUE":
136136
config.available_features.add('concurrency')
137+
if "@SWIFT_ALLOW_BACK_DEPLOY_CONCURRENCY@" == "TRUE":
138+
config.available_features.add('back_deploy_concurrency')
137139
if "@SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED@" == "TRUE":
138140
config.available_features.add('distributed')
139141

0 commit comments

Comments
 (0)