mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The central thrust of this patch is to get these metadata initializations off of `swift_once` and onto the metadata-request system where we can properly detect and resolve dependencies. We do this by first introducing runtime support for resolving metadata requests for "in-place" initializations (committed previously) and then teaching IRGen to actually generate code to use them (this patch). A non-trivial amount of this patch is just renaming and refactoring some of existing infrastructure that was being used for in-place initializations to try to avoid unnecessary confusion. The remaining cases that are still using `swift_once` resolution of metadata initialization are: - non-generic classes that can't statically fill their superclass or have resilient internal layout - foreign type metadata Classes require more work because I'd like to switch at least the resilient-superclass case over to using a pattern much more like what we do with generic class instantiation. That is, I'd like in-place initialization to be reserved for classes that actually don't need relocation. Foreign metadata should also be updated to the request/dependency scheme before we declare ABI stability. I'm not sure why foreign metadata would ever require a type to be resolved, but let's assume it's possible. Fixes part of SR-7876.
29 lines
883 B
Swift
29 lines
883 B
Swift
// RUN: %empty-directory(%t)
|
|
|
|
// RUN: %target-build-swift-dylib(%t/libresilient_struct.%target-dylib-extension) -Xfrontend -enable-resilience %S/../Inputs/resilient_struct.swift -emit-module -emit-module-path %t/resilient_struct.swiftmodule -module-name resilient_struct
|
|
// RUN: %target-codesign %t/libresilient_struct.%target-dylib-extension
|
|
|
|
// RUN: %target-build-swift %s -L %t -I %t -lresilient_struct -o %t/main -Xlinker -rpath -Xlinker %t
|
|
|
|
// RUN: %target-run %t/main %t/libresilient_struct.%target-dylib-extension
|
|
|
|
import StdlibUnittest
|
|
|
|
import resilient_struct
|
|
|
|
var ResilientMetadataCycleTests = TestSuite("Resilient metadata cycle tests")
|
|
|
|
// SR-7876
|
|
enum test0_Node {
|
|
case link(size: Size, children: [test0_Node])
|
|
|
|
static func test() -> [test0_Node] {
|
|
return []
|
|
}
|
|
}
|
|
ResilientMetadataCycleTests.test("SR-7876") {
|
|
_ = test0_Node.test()
|
|
}
|
|
|
|
runAllTests()
|