[embedded] Build an initial embedded Swift standard library

This isn't a "complete" port of the standard library for embedded Swift, but
something that should serve as a starting point for further iterations on the
stdlib.

- General CMake logic for building a library as ".swiftmodule only" (ONLY_SWIFTMODULE).
- CMake logic in stdlib/public/core/CMakeLists.txt to start building the embedded stdlib for a handful of hardcoded target triples.
- Lots of annotations throughout the standard library to make types, functions, protocols unavailable in embedded Swift (@_unavailableInEmbedded).
- Mainly this is about stdlib functionality that relies on existentials, type erasure, metatypes, reflection, string interpolations.
- We rely on function body removal of unavailable functions to eliminate the actual problematic SIL code (existentials).
- Many .swift files are not included in the compilation of embedded stdlib at all, to simplify the scope of the annotations.
- EmbeddedStubs.swift is used to stub out (as unavailable and fatalError'd) the missing functionality.
This commit is contained in:
Kuba Mracek
2023-09-13 20:32:53 -07:00
parent 7014fcf12a
commit ae2e903574
61 changed files with 1365 additions and 252 deletions

View File

@@ -1,9 +1,9 @@
// RUN: not %target-swift-frontend -emit-ir %s -parse-stdlib -enable-experimental-feature Embedded -wmo 2>&1 | %FileCheck %s
// RUN: %target-swift-frontend -emit-ir -verify %s -parse-stdlib -enable-experimental-feature Embedded -wmo
public protocol Player {}
struct Concrete: Player {}
// CHECK: error: existential can cause metadata allocation or locks
public func test() -> any Player {
Concrete()
Concrete() // expected-error {{existential can cause metadata allocation or locks}}
// expected-note@-1 {{called from here}}
}