mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
46
test/embedded/basic-modules-no-stdlib.swift
Normal file
46
test/embedded/basic-modules-no-stdlib.swift
Normal 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"{{.*}} {
|
||||
Reference in New Issue
Block a user