[embedded] Add basics of module serialization, importing and validation in embedded Swift.

- Add a flag to the serialized module (IsEmbeddedSwiftModule)
- Check on import that the mode matches (don't allow importing non-embedded module in embedded mode and vice versa)
- Drop TBD support, it's not expected to work in embedded Swift for now
- Drop auto-linking backdeploy libraries, it's not expected to backdeploy embedded Swift for now
- Drop prespecializations, not expected to work in embedded Swift for now
- Use CMO to serialize everything when emitting an embedded Swift module
- Change SILLinker to deserialize/import everything when importing an embedded Swift module
- Add an IR test for importing modules
- Add a deserialization validation test
This commit is contained in:
Kuba Mracek
2023-09-02 11:55:17 -07:00
parent 74e22dc450
commit 25eb997a28
25 changed files with 188 additions and 21 deletions

View File

@@ -0,0 +1,46 @@
// RUN: %empty-directory(%t)
// RUN: %{python} %utils/split_file.py -o %t %s
// RUN: %target-swift-frontend -swift-version 5 -emit-module -o %t/MyModule.swiftmodule %t/MyModule.swift -parse-stdlib -enable-experimental-feature Embedded
// RUN: %target-swift-frontend -swift-version 5 -emit-ir -I %t %t/Main.swift -parse-stdlib -enable-experimental-feature Embedded | %FileCheck %s
// TODO: investigate why windows is generating more metadata.
// XFAIL: OS=windows-msvc
// BEGIN MyModule.swift
public struct Bool {}
public protocol Player {
func play()
var canPlay: Bool { get }
}
public struct Concrete : Player {
public init() { }
public func play() { }
public var canPlay: Bool { Bool() }
}
public func start(p: some Player) {
p.play()
}
public func moduleMain() {
start(p: Concrete())
}
// BEGIN Main.swift
import MyModule
public func main() {
moduleMain()
}
// CHECK: define {{.*}}@main{{.*}} {
// CHECK: define {{.*}}void @"$s4Main4mainyyF"{{.*}} {
// CHECK: define {{.*}}void @"$s8MyModule10moduleMainyyF"{{.*}} {
// CHECK: define {{.*}}void @"$s8MyModule8ConcreteVACycfC"{{.*}} {
// CHECK: define {{.*}}void @"$s8MyModule5start1pyx_tAA6PlayerRzlFAA8ConcreteV_Tg5"{{.*}} {
// CHECK: define {{.*}}void @"$s8MyModule8ConcreteV4playyyF"{{.*}} {