|
| 1 | +// RUN: %empty-directory(%t/src) |
| 2 | +// RUN: split-file %s %t/src |
| 3 | + |
| 4 | +/// Build the fake actor systems lib |
| 5 | +// RUN: %target-build-swift \ |
| 6 | +// RUN: -target %target-swift-6.0-abi-triple \ |
| 7 | +// RUN: -parse-as-library -emit-library \ |
| 8 | +// RUN: -emit-module-path %t/FakeDistributedActorSystems.swiftmodule \ |
| 9 | +// RUN: -module-name FakeDistributedActorSystems \ |
| 10 | +// RUN: %S/../Inputs/FakeDistributedActorSystems.swift \ |
| 11 | +// RUN: -enable-library-evolution \ |
| 12 | +// RUN: -o %t/%target-library-name(FakeDistributedActorSystems) |
| 13 | + |
| 14 | +/// Build the Lib |
| 15 | +// RUN: %target-build-swift \ |
| 16 | +// RUN: -target %target-swift-6.0-abi-triple \ |
| 17 | +// RUN: -parse-as-library -emit-library \ |
| 18 | +// RUN: -emit-module-path %t/ResilientAPILib.swiftmodule \ |
| 19 | +// RUN: -module-name ResilientAPILib \ |
| 20 | +// RUN: -I %t \ |
| 21 | +// RUN: -L %t \ |
| 22 | +// RUN: -plugin-path %swift-plugin-dir \ |
| 23 | +// RUN: %t/src/ResilientAPILib.swift \ |
| 24 | +// RUN: -lFakeDistributedActorSystems \ |
| 25 | +// RUN: -enable-library-evolution \ |
| 26 | +// RUN: -o %t/%target-library-name(ResilientAPILib) |
| 27 | + |
| 28 | +/// Build the ActorLib |
| 29 | +// RUN: %target-build-swift \ |
| 30 | +// RUN: -target %target-swift-6.0-abi-triple \ |
| 31 | +// RUN: -parse-as-library -emit-library \ |
| 32 | +// RUN: -emit-module-path %t/ResilientImplLib.swiftmodule \ |
| 33 | +// RUN: -module-name ResilientImplLib \ |
| 34 | +// RUN: -I %t \ |
| 35 | +// RUN: -L %t \ |
| 36 | +// RUN: %t/src/ResilientImplLib.swift \ |
| 37 | +// RUN: -lFakeDistributedActorSystems \ |
| 38 | +// RUN: -lResilientAPILib \ |
| 39 | +// RUN: -enable-library-evolution \ |
| 40 | +// RUN: -o %t/%target-library-name(ResilientImplLib) |
| 41 | + |
| 42 | +/// Build the client |
| 43 | +// RUN: %target-build-swift \ |
| 44 | +// RUN: -target %target-swift-6.0-abi-triple \ |
| 45 | +// RUN: -parse-as-library \ |
| 46 | +// RUN: -lFakeDistributedActorSystems \ |
| 47 | +// RUN: -lResilientAPILib \ |
| 48 | +// RUN: -lResilientImplLib \ |
| 49 | +// RUN: -module-name main \ |
| 50 | +// RUN: -I %t \ |
| 51 | +// RUN: -L %t \ |
| 52 | +// RUN: %s \ |
| 53 | +// RUN: -enable-library-evolution \ |
| 54 | +// RUN: -o %t/a.out |
| 55 | + |
| 56 | +// Sign the main binary and all libraries |
| 57 | +// RUN: %target-codesign %t/a.out |
| 58 | +// RUN: %target-codesign %t/%target-library-name(FakeDistributedActorSystems) |
| 59 | +// RUN: %target-codesign %t/%target-library-name(ResilientAPILib) |
| 60 | +// RUN: %target-codesign %t/%target-library-name(ResilientImplLib) |
| 61 | + |
| 62 | +// Run and verify output |
| 63 | +// RUN: %env-SWIFT_DUMP_ACCESSIBLE_FUNCTIONS=true %target-run %t/a.out \ |
| 64 | +// RUN: %t/%target-library-name(FakeDistributedActorSystems) \ |
| 65 | +// RUN: %t/%target-library-name(ResilientAPILib) \ |
| 66 | +// RUN: %t/%target-library-name(ResilientImplLib) \ |
| 67 | +// RUN: 2>&1 \ |
| 68 | +// RUN: | %FileCheck %s --color --dump-input=always |
| 69 | + |
| 70 | +// REQUIRES: executable_test |
| 71 | +// REQUIRES: concurrency |
| 72 | +// REQUIRES: distributed |
| 73 | + |
| 74 | +// Locating the built libraries failed on Linux (construction of test case), |
| 75 | +// but we primarily care about macOS in this test |
| 76 | +// UNSUPPORTED: OS=linux-gnu |
| 77 | + |
| 78 | +// %env does not seem to work on Windows |
| 79 | +// UNSUPPORTED: OS=windows-msvc |
| 80 | + |
| 81 | +// UNSUPPORTED: use_os_stdlib |
| 82 | +// UNSUPPORTED: back_deployment_runtime |
| 83 | +// UNSUPPORTED: remote_run || device_run |
| 84 | + |
| 85 | + |
| 86 | +// FIXME: Also reproduces the following issue rdar://128284016 |
| 87 | +//<unknown>:0: error: symbol '$s15ResilientAPILib30ServiceProtocolP8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTj' (dispatch thunk of ResilientAPILib.ServiceProtocol.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ResilientAPILib.Response>) is in generated IR file, but not in TBD file |
| 88 | + |
| 89 | +//<unknown>:0: error: symbol '$s15ResilientAPILib30ServiceProtocolP8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTjTu' (async function pointer to dispatch thunk of ResilientAPILib.ServiceProtocol.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ResilientAPILib.Response>) is in generated IR file, but not in TBD file |
| 90 | + |
| 91 | +//--- ResilientAPILib.swift |
| 92 | + |
| 93 | +import Distributed |
| 94 | +import FakeDistributedActorSystems |
| 95 | + |
| 96 | +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) |
| 97 | +public struct Response: Codable {} |
| 98 | + |
| 99 | +@Resolvable |
| 100 | +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) |
| 101 | +public protocol ServiceProtocol: DistributedActor where ActorSystem == FakeRoundtripActorSystem { |
| 102 | + distributed func getArray(a1: [Int], a2: String?) -> [Response] |
| 103 | +} |
| 104 | + |
| 105 | +//--- ResilientImplLib.swift |
| 106 | + |
| 107 | +import ResilientAPILib |
| 108 | + |
| 109 | +import Distributed |
| 110 | +import FakeDistributedActorSystems |
| 111 | + |
| 112 | +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) |
| 113 | +public distributed actor ServiceImpl: ServiceProtocol { |
| 114 | + public typealias ActorSystem = FakeRoundtripActorSystem |
| 115 | + |
| 116 | + public distributed func getArray(a1: [Int], a2: String?) -> [Response] { |
| 117 | + [] |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +//--- Main.swift |
| 122 | + |
| 123 | +import ResilientAPILib |
| 124 | +import ResilientImplLib |
| 125 | + |
| 126 | +import Distributed |
| 127 | +import FakeDistributedActorSystems |
| 128 | + |
| 129 | +@main |
| 130 | +struct Main { |
| 131 | + static func main() async throws { |
| 132 | + if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) { |
| 133 | + let system = FakeRoundtripActorSystem() |
| 134 | + |
| 135 | + let real: any ServiceProtocol = ServiceImpl(actorSystem: system) |
| 136 | + |
| 137 | + let proxy: any ServiceProtocol = |
| 138 | + try $ServiceProtocol.resolve(id: real.id, using: system) |
| 139 | + |
| 140 | + // just in order to see if we crash and trigger the accessible funcs printout |
| 141 | + _ = try await proxy.getArray(a1: [], a2: "") |
| 142 | + |
| 143 | + // === We expect records for accessible functions from other modules as well, |
| 144 | + // and especially we want to see records for the `$` macro generated stubs, |
| 145 | + // including |
| 146 | + |
| 147 | + // CHECK: ==== Accessible Function Records ==== |
| 148 | + // CHECK: Record name: $s16ResilientImplLib07ServiceB0C8getArray2a12a2Say0A6APILib8ResponseVGSaySiG_SSSgtYaKFTE |
| 149 | + // CHECK: Demangled: distributed thunk ResilientImplLib.ServiceImpl.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ResilientAPILib.Response> |
| 150 | + |
| 151 | + // CHECK: Record name: $s15ResilientAPILib15ServiceProtocolPAA11Distributed01_E9ActorStubRzrlE8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE |
| 152 | + // CHECK: Demangled: distributed thunk (extension in ResilientAPILib):ResilientAPILib.ServiceProtocol< where A: Distributed._DistributedActorStub>.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ResilientAPILib.Response> |
| 153 | + |
| 154 | + // CHECK: Record name: $s15ResilientAPILib16$ServiceProtocolC8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE |
| 155 | + // CHECK: Demangled: distributed thunk ResilientAPILib.$ServiceProtocol.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<ResilientAPILib.Response> |
| 156 | + |
| 157 | + // CHECK: Record name: $s4main15ServiceProtocolPAA11Distributed01_D9ActorStubRzrlE8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE |
| 158 | + // CHECK: Demangled: distributed thunk (extension in main):main.ServiceProtocol< where A: Distributed._DistributedActorStub>.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<main.Response> |
| 159 | + |
| 160 | + // CHECK: Record name: $s4main11ServiceImplC8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE |
| 161 | + // CHECK: Demangled: distributed thunk main.ServiceImpl.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<main.Response> |
| 162 | + |
| 163 | + // CHECK: Record name: $s4main16$ServiceProtocolC8getArray2a12a2SayAA8ResponseVGSaySiG_SSSgtYaKFTE |
| 164 | + // CHECK: Demangled: distributed thunk main.$ServiceProtocol.getArray(a1: Swift.Array<Swift.Int>, a2: Swift.Optional<Swift.String>) async throws -> Swift.Array<main.Response> |
| 165 | + |
| 166 | + // We expect these to be the exact records we get, no other ones: |
| 167 | + // CHECK: Record count: 6 |
| 168 | + |
| 169 | + // CHECK: ==== End of Accessible Function Records ==== |
| 170 | + |
| 171 | + print("DONE") // CHECK: DONE |
| 172 | + } |
| 173 | + } |
| 174 | +} |
0 commit comments