Skip to content

[embedded] Make stdlib APIs automatically available on older Darwin versions in Embedded Swift #78263

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

Merged
merged 2 commits into from
Dec 20, 2024
Merged
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: 9 additions & 0 deletions stdlib/public/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP OFF)
set(SWIFT_STDLIB_ENABLE_VECTOR_TYPES OFF)

# Under Embedded Swift, all stdlib APIs should be available always. Replace
# all availability macros with very very old OS versions.
set(SWIFT_STDLIB_AVAILABILITY_DEFINITIONS_EMBEDDED)
foreach(def ${SWIFT_STDLIB_AVAILABILITY_DEFINITIONS})
string(REGEX REPLACE ":.*" ":macOS 10.9, iOS 7.0, watchOS 2.0, tvOS 9.0, visionOS 1.0" replaced "${def}")
list(APPEND SWIFT_STDLIB_AVAILABILITY_DEFINITIONS_EMBEDDED "${replaced}")
endforeach()
set(SWIFT_STDLIB_AVAILABILITY_DEFINITIONS "${SWIFT_STDLIB_AVAILABILITY_DEFINITIONS_EMBEDDED}")

foreach(entry ${EMBEDDED_STDLIB_TARGET_TRIPLES})
string(REGEX REPLACE "[ \t]+" ";" list "${entry}")
list(GET list 0 arch)
Expand Down
13 changes: 13 additions & 0 deletions test/embedded/availability-macos.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Checks that in Embedded Swift, we allow using stdlib types even when they
// have declared availability to be higher than our macOS deployment target.

// RUN: %target-typecheck-verify-swift -target arm64-apple-macos14 -enable-experimental-feature Embedded -enable-experimental-feature Span
// RUN: %target-typecheck-verify-swift -target arm64-apple-macos15 -enable-experimental-feature Embedded -enable-experimental-feature Span

// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_Embedded
// REQUIRES: swift_feature_Span
// REQUIRES: OS=macosx

func f(_: Span<Int>) { } // Span is @available(SwiftStdlib 6.1, *)
func g(_: Int128) { } // Int128 is @available(SwiftStdlib 6.0, *)