Skip to content

Commit e0ccd1b

Browse files
authored
Merge pull request #78263 from kubamracek/embedded-stdlib-all-available
[embedded] Make stdlib APIs automatically available on older Darwin versions in Embedded Swift
2 parents 1dd1925 + 0545277 commit e0ccd1b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

stdlib/public/core/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,15 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
434434
set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP OFF)
435435
set(SWIFT_STDLIB_ENABLE_VECTOR_TYPES OFF)
436436

437+
# Under Embedded Swift, all stdlib APIs should be available always. Replace
438+
# all availability macros with very very old OS versions.
439+
set(SWIFT_STDLIB_AVAILABILITY_DEFINITIONS_EMBEDDED)
440+
foreach(def ${SWIFT_STDLIB_AVAILABILITY_DEFINITIONS})
441+
string(REGEX REPLACE ":.*" ":macOS 10.9, iOS 7.0, watchOS 2.0, tvOS 9.0, visionOS 1.0" replaced "${def}")
442+
list(APPEND SWIFT_STDLIB_AVAILABILITY_DEFINITIONS_EMBEDDED "${replaced}")
443+
endforeach()
444+
set(SWIFT_STDLIB_AVAILABILITY_DEFINITIONS "${SWIFT_STDLIB_AVAILABILITY_DEFINITIONS_EMBEDDED}")
445+
437446
foreach(entry ${EMBEDDED_STDLIB_TARGET_TRIPLES})
438447
string(REGEX REPLACE "[ \t]+" ";" list "${entry}")
439448
list(GET list 0 arch)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Checks that in Embedded Swift, we allow using stdlib types even when they
2+
// have declared availability to be higher than our macOS deployment target.
3+
4+
// RUN: %target-typecheck-verify-swift -target arm64-apple-macos14 -enable-experimental-feature Embedded -enable-experimental-feature Span
5+
// RUN: %target-typecheck-verify-swift -target arm64-apple-macos15 -enable-experimental-feature Embedded -enable-experimental-feature Span
6+
7+
// REQUIRES: swift_in_compiler
8+
// REQUIRES: swift_feature_Embedded
9+
// REQUIRES: swift_feature_Span
10+
// REQUIRES: OS=macosx
11+
12+
func f(_: Span<Int>) { } // Span is @available(SwiftStdlib 6.1, *)
13+
func g(_: Int128) { } // Int128 is @available(SwiftStdlib 6.0, *)

0 commit comments

Comments
 (0)