[Distributed] Correct tbd handling for distributed thunks (#74935)

This commit is contained in:
Konrad `ktoso` Malawski
2024-07-26 16:52:18 +09:00
committed by GitHub
parent 2f1f3abff1
commit eb675c222e
12 changed files with 264 additions and 60 deletions

View File

@@ -1608,6 +1608,7 @@ public:
bool isTypeMetadataAccessFunction() const {
return getKind() == Kind::TypeMetadataAccessFunction;
}
bool isDistributedThunk() const;
bool isDispatchThunk() const {
return getKind() == Kind::DispatchThunk ||
getKind() == Kind::DispatchThunkInitializer ||

View File

@@ -187,7 +187,7 @@ struct SILDeclRef {
/// True if this references a foreign entry point for the referenced decl.
unsigned isForeign : 1;
/// True if this references a distributed function.
unsigned isDistributed : 1;
unsigned distributedThunk : 1;
/// True if this references a distributed function, but it is known to be local
unsigned isKnownToBeLocal : 1;
/// True is this reference to function that could be looked up via a special
@@ -231,7 +231,7 @@ struct SILDeclRef {
/// Produces a null SILDeclRef.
SILDeclRef()
: loc(), kind(Kind::Func), isForeign(0), isDistributed(0),
: loc(), kind(Kind::Func), isForeign(0), distributedThunk(0),
isKnownToBeLocal(0), isRuntimeAccessible(0),
backDeploymentKind(BackDeploymentKind::None), defaultArgIndex(0),
isAsyncLetClosure(0) {}
@@ -406,13 +406,13 @@ struct SILDeclRef {
friend llvm::hash_code hash_value(const SILDeclRef &ref) {
return llvm::hash_combine(
ref.loc.getOpaqueValue(), static_cast<int>(ref.kind), ref.isForeign,
ref.isDistributed, ref.defaultArgIndex, ref.isAsyncLetClosure);
ref.distributedThunk, ref.defaultArgIndex, ref.isAsyncLetClosure);
}
bool operator==(SILDeclRef rhs) const {
return loc.getOpaqueValue() == rhs.loc.getOpaqueValue() &&
kind == rhs.kind && isForeign == rhs.isForeign &&
isDistributed == rhs.isDistributed &&
distributedThunk == rhs.distributedThunk &&
backDeploymentKind == rhs.backDeploymentKind &&
defaultArgIndex == rhs.defaultArgIndex && pointer == rhs.pointer &&
isAsyncLetClosure == rhs.isAsyncLetClosure;
@@ -468,7 +468,7 @@ struct SILDeclRef {
/// Returns a copy of the decl with the given back deployment kind.
SILDeclRef asBackDeploymentKind(BackDeploymentKind backDeploymentKind) const {
return SILDeclRef(loc.getOpaqueValue(), kind, isForeign, isDistributed,
return SILDeclRef(loc.getOpaqueValue(), kind, isForeign, distributedThunk,
isKnownToBeLocal, isRuntimeAccessible, backDeploymentKind,
defaultArgIndex, isAsyncLetClosure,
pointer.get<AutoDiffDerivativeFunctionIdentifier *>());
@@ -511,6 +511,9 @@ struct SILDeclRef {
/// True if the decl ref references a thunk handling potentially distributed actor functions
bool isDistributedThunk() const;
/// True if the decl references a 'distributed' function.
bool isDistributed() const;
/// True if the decl ref references a thunk handling a call to a function that
/// supports back deployment.
bool isBackDeploymentThunk() const;
@@ -605,13 +608,13 @@ private:
friend struct llvm::DenseMapInfo<swift::SILDeclRef>;
/// Produces a SILDeclRef from an opaque value.
explicit SILDeclRef(void *opaqueLoc, Kind kind, bool isForeign,
bool isDistributed, bool isKnownToBeLocal,
bool isDistributedThunk, bool isKnownToBeLocal,
bool isRuntimeAccessible,
BackDeploymentKind backDeploymentKind,
unsigned defaultArgIndex, bool isAsyncLetClosure,
AutoDiffDerivativeFunctionIdentifier *derivativeId)
: loc(Loc::getFromOpaqueValue(opaqueLoc)), kind(kind),
isForeign(isForeign), isDistributed(isDistributed),
isForeign(isForeign), distributedThunk(isDistributedThunk),
isKnownToBeLocal(isKnownToBeLocal),
isRuntimeAccessible(isRuntimeAccessible),
backDeploymentKind(backDeploymentKind),
@@ -655,7 +658,7 @@ template<> struct DenseMapInfo<swift::SILDeclRef> {
: 0;
unsigned h4 = UnsignedInfo::getHashValue(Val.isForeign);
unsigned h5 = PointerInfo::getHashValue(Val.pointer.getOpaqueValue());
unsigned h6 = UnsignedInfo::getHashValue(Val.isDistributed);
unsigned h6 = UnsignedInfo::getHashValue(Val.distributedThunk);
unsigned h7 = UnsignedInfo::getHashValue(unsigned(Val.backDeploymentKind));
unsigned h8 = UnsignedInfo::getHashValue(Val.isKnownToBeLocal);
unsigned h9 = UnsignedInfo::getHashValue(Val.isRuntimeAccessible);

View File

@@ -942,8 +942,12 @@ namespace {
SILDeclRef func(entry.getFunction());
// Emit the dispatch thunk.
if (Resilient || IGM.getOptions().WitnessMethodElimination)
auto shouldEmitDispatchThunk =
(Resilient || IGM.getOptions().WitnessMethodElimination) &&
!func.isDistributed();
if (shouldEmitDispatchThunk) {
IGM.emitDispatchThunk(func);
}
{
auto *requirement = cast<AbstractFunctionDecl>(func.getDecl());
@@ -1009,10 +1013,23 @@ namespace {
}
for (auto &entry : pi.getWitnessEntries()) {
if (entry.isFunction() &&
entry.getFunction().getDecl()->isDistributedGetAccessor()) {
// We avoid emitting _distributed_get accessors, as they cannot be
// referred to anyway
continue;
}
if (Resilient) {
if (entry.isFunction()) {
// Define the method descriptor.
SILDeclRef func(entry.getFunction());
/// Distributed thunks don't need resilience.
if (func.isDistributedThunk()) {
continue;
}
auto *descriptor =
B.getAddrOfCurrentPosition(
IGM.ProtocolRequirementStructTy);
@@ -1021,13 +1038,6 @@ namespace {
}
}
if (entry.isFunction() &&
entry.getFunction().getDecl()->isDistributedGetAccessor()) {
// We avoid emitting _distributed_get accessors, as they cannot be
// referred to anyway
continue;
}
if (entry.isAssociatedType()) {
auto assocType = entry.getAssociatedType();
// Define the associated type descriptor to point to the current

View File

@@ -2215,6 +2215,12 @@ namespace {
LinkEntity::forBaseConformanceDescriptor(requirement));
B.addRelativeAddress(baseConformanceDescriptor);
} else if (entry.getKind() == SILWitnessTable::Method) {
// distributed thunks don't need resilience
if (entry.getMethodWitness().Requirement.isDistributedThunk()) {
witnesses = witnesses.drop_back();
continue;
}
// Method descriptor.
auto declRef = entry.getMethodWitness().Requirement;
auto requirement =

View File

@@ -103,6 +103,15 @@ public:
void addDispatchThunk(SILDeclRef declRef) override {
auto entity = LinkEntity::forDispatchThunk(declRef);
// TODO: explain why
if (declRef.isDistributedThunk()) {
auto afd = declRef.getAbstractFunctionDecl();
if (afd && isa<ProtocolDecl>(afd->getDeclContext())) {
return;
}
}
addLinkEntity(entity);
if (declRef.getAbstractFunctionDecl()->hasAsync())
@@ -147,6 +156,14 @@ public:
}
void addMethodDescriptor(SILDeclRef declRef) override {
if (declRef.isDistributedThunk()) {
auto afd = declRef.getAbstractFunctionDecl();
auto DC = afd->getDeclContext();
if (isa<ProtocolDecl>(DC)) {
return;
}
}
addLinkEntity(LinkEntity::forMethodDescriptor(declRef));
}

View File

@@ -1304,6 +1304,18 @@ bool LinkEntity::isText() const {
}
}
bool LinkEntity::isDistributedThunk() const {
if (!hasDecl())
return false;
auto value = getDecl();
if (auto afd = dyn_cast<AbstractFunctionDecl>(value)) {
return afd->isDistributedThunk();
}
return false;
}
bool LinkEntity::isWeakImported(ModuleDecl *module) const {
switch (getKind()) {
case Kind::SILGlobalVariable:

View File

@@ -124,11 +124,11 @@ bool swift::requiresForeignEntryPoint(ValueDecl *vd) {
}
SILDeclRef::SILDeclRef(ValueDecl *vd, SILDeclRef::Kind kind, bool isForeign,
bool isDistributed, bool isKnownToBeLocal,
bool isDistributedThunk, bool isKnownToBeLocal,
bool isRuntimeAccessible,
SILDeclRef::BackDeploymentKind backDeploymentKind,
AutoDiffDerivativeFunctionIdentifier *derivativeId)
: loc(vd), kind(kind), isForeign(isForeign), isDistributed(isDistributed),
: loc(vd), kind(kind), isForeign(isForeign), distributedThunk(isDistributedThunk),
isKnownToBeLocal(isKnownToBeLocal),
isRuntimeAccessible(isRuntimeAccessible),
backDeploymentKind(backDeploymentKind), defaultArgIndex(0),
@@ -186,7 +186,7 @@ SILDeclRef::SILDeclRef(SILDeclRef::Loc baseLoc, bool asForeign,
}
isForeign = asForeign;
isDistributed = asDistributed;
distributedThunk = asDistributed;
isKnownToBeLocal = asDistributedKnownToBeLocal;
}
@@ -1072,10 +1072,20 @@ bool SILDeclRef::isNativeToForeignThunk() const {
}
bool SILDeclRef::isDistributedThunk() const {
if (!isDistributed)
if (!distributedThunk)
return false;
return kind == Kind::Func;
}
bool SILDeclRef::isDistributed() const {
if (!hasFuncDecl())
return false;
if (auto decl = getFuncDecl()) {
return decl->isDistributed();
}
return false;
}
bool SILDeclRef::isBackDeploymentFallback() const {
if (backDeploymentKind != BackDeploymentKind::Fallback)

View File

@@ -811,6 +811,7 @@ public:
V.Ctx.getOpts().WitnessMethodElimination} {}
void addMethod(SILDeclRef declRef) {
// TODO: alternatively maybe prevent adding distributed thunk here rather than inside those?
if (Resilient || WitnessMethodElimination) {
Visitor.addDispatchThunk(declRef);
Visitor.addMethodDescriptor(declRef);

View File

@@ -401,14 +401,6 @@ template<typename T> class SILGenWitnessTable : public SILWitnessVisitor<T> {
public:
void addMethod(SILDeclRef requirementRef) {
// TODO: here the requirement is thunk_decl of the protocol; it is a FUNC
// detect here that it is a func dec + thunk.
// walk up to DC, and find storage.
// e requirementRef->getDecl()->dump()
//(func_decl implicit "distributedVariable()" interface type="<Self where Self : WorkerProtocol> (Self) -> () async throws -> String" access=internal nonisolated distributed_thunk
// (parameter "self")
// (parameter_list))
auto reqDecl = requirementRef.getDecl();
// Static functions can be witnessed by enum cases with payload
@@ -473,7 +465,6 @@ public:
// Here we notice a `distributed var` thunk requirement,
// and witness it with the distributed thunk -- the "getter thunk".
if (requirementRef.isDistributedThunk()) {
return addMethodImplementation(
requirementRef, getWitnessRef(requirementRef, witnessStorage->getDistributedThunk()),
witness);

View File

@@ -0,0 +1,117 @@
// RUN: %empty-directory(%t/src)
// RUN: split-file %s %t/src
/// Build the fake actor systems lib
// RUN: %target-build-swift \
// RUN: -Xfrontend -disable-availability-checking \
// RUN: -parse-as-library -emit-library \
// RUN: -emit-module-path %t/FakeDistributedActorSystems.swiftmodule \
// RUN: -module-name FakeDistributedActorSystems \
// RUN: %S/../Inputs/FakeDistributedActorSystems.swift \
// RUN: -enable-library-evolution \
// RUN: -o %t/%target-library-name(FakeDistributedActorSystems)
/// Build the Lib
// RUN: %target-build-swift \
// RUN: -Xfrontend -disable-availability-checking \
// RUN: -parse-as-library -emit-library \
// RUN: -emit-module-path %t/ResilientLib.swiftmodule \
// RUN: -module-name ResilientLib \
// RUN: -I %t \
// RUN: -L %t \
// RUN: %t/src/ResilientLib.swift \
// RUN: -enable-library-evolution \
// RUN: -o %t/%target-library-name(ResilientLib)
/// Build the ActorLib
// RUN: %target-build-swift \
// RUN: -Xfrontend -disable-availability-checking \
// RUN: -parse-as-library -emit-library \
// RUN: -emit-module-path %t/ResilientActorLib.swiftmodule \
// RUN: -module-name ResilientActorLib \
// RUN: -I %t \
// RUN: -L %t \
// RUN: %t/src/ResilientActorLib.swift \
// RUN: -lFakeDistributedActorSystems \
// RUN: -lResilientLib \
// RUN: -enable-library-evolution \
// RUN: -o %t/%target-library-name(ResilientActorLib)
/// Build the client
// RUN: %target-build-swift \
// RUN: -Xfrontend -disable-availability-checking \
// RUN: -parse-as-library \
// RUN: -lFakeDistributedActorSystems \
// RUN: -lResilientLib \
// RUN: -lResilientActorLib \
// RUN: -module-name main \
// RUN: -I %t \
// RUN: -L %t \
// RUN: %s \
// RUN: -enable-library-evolution \
// RUN: -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: concurrency
// REQUIRES: distributed
// Locating the built libraries failed on Linux (construction of test case),
// but we primarily care about macOS in this test
// UNSUPPORTED: OS=linux-gnu
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: back_deployment_runtime
//--- ResilientLib.swift
import Distributed
public protocol SomeProtocol {
func function() async throws -> String
}
//--- ResilientActorLib.swift
import ResilientLib
import Distributed
import FakeDistributedActorSystems
public distributed actor Impl: SomeProtocol {
public typealias ActorSystem = FakeRoundtripActorSystem
public distributed func function() async throws -> String {
"Success!"
}
}
//--- Main.swift
import ResilientLib
import ResilientActorLib
import Distributed
import FakeDistributedActorSystems
@main struct Main {
static func main() async {
let system = FakeRoundtripActorSystem()
print("start")
let impl = Impl(actorSystem: system)
let anyAct: any SomeProtocol = impl
let anyReply = try! await anyAct.function()
print("any reply = \(anyReply)") // CHECK: any reply = Success!
let proxy: any SomeProtocol = try! Impl.resolve(id: impl.id, using: system)
let proxyReply = try! await proxy.function()
print("proxy reply = \(proxyReply)") // CHECK: proxy reply = Success!
print("done")
}
}

View File

@@ -47,34 +47,3 @@ public func g<DA: DistributedActor>(_ t: isolated DA) -> any Actor {
}
// CHECK: OK: hello
/*
/Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/bin/swift-frontend -frontend -c -primary-file /Users/ktoso/code/swift-project/swift/test/Distributed/Runtime/distributed_actor_to_actor.swift /Users/ktoso/code/swift-project/swift/test/Distributed/Runtime/../Inputs/FakeDistributedActorSystems.swift -emit-module-path /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/distributed_actor_to_actor-93d4b3.swiftmodule -emit-module-doc-path /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/distributed_actor_to_actor-93d4b3.swiftdoc -emit-module-source-info-path /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/distributed_actor_to_actor-93d4b3.swiftsourceinfo -target arm64-apple-macosx10.13 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -color-diagnostics -I /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/test-macosx-arm64/Distributed/Runtime/Output/distributed_actor_to_actor.swift.tmp -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/lib -g -module-cache-path /Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/swift-test-results/arm64-apple-macosx10.13/clang-module-cache -swift-version 4 -define-availability "SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -define-availability "SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2" -define-availability "SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0" -define-availability "SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4" -define-availability "SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0" -define-availability "SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5" -define-availability "SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0" -define-availability "SwiftStdlib 5.6:macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4" -define-availability "SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0" -define-availability "SwiftStdlib 5.8:macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4" -define-availability "SwiftStdlib 5.9:macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0" -define-availability "SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.1" -define-availability "SwiftStdlib 6.0:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999" -disable-availability-checking -enable-anonymous-context-mangled-names -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/host/plugins -plugin-path /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/local/lib/swift/host/plugins -target-sdk-version 14.0 -dwarf-version=4 -parse-as-library -module-name main -o /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/distributed_actor_to_actor-93d4b3.o
/Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/bin/swift-frontend -frontend -c /Users/ktoso/code/swift-project/swift/test/Distributed/Runtime/distributed_actor_to_actor.swift -primary-file /Users/ktoso/code/swift-project/swift/test/Distributed/Runtime/../Inputs/FakeDistributedActorSystems.swift -emit-module-path /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/FakeDistributedActorSystems-2b3bf4.swiftmodule -emit-module-doc-path /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/FakeDistributedActorSystems-2b3bf4.swiftdoc -emit-module-source-info-path /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/FakeDistributedActorSystems-2b3bf4.swiftsourceinfo -target arm64-apple-macosx10.13 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -color-diagnostics -I /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/test-macosx-arm64/Distributed/Runtime/Output/distributed_actor_to_actor.swift.tmp -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/lib -g -module-cache-path /Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/swift-test-results/arm64-apple-macosx10.13/clang-module-cache -swift-version 4 -define-availability "SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -define-availability "SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2" -define-availability "SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0" -define-availability "SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4" -define-availability "SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0" -define-availability "SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5" -define-availability "SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0" -define-availability "SwiftStdlib 5.6:macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4" -define-availability "SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0" -define-availability "SwiftStdlib 5.8:macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4" -define-availability "SwiftStdlib 5.9:macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0" -define-availability "SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.1" -define-availability "SwiftStdlib 6.0:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999" -disable-availability-checking -enable-anonymous-context-mangled-names -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/host/plugins -plugin-path /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/local/lib/swift/host/plugins -target-sdk-version 14.0 -dwarf-version=4 -parse-as-library -module-name main -o /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/FakeDistributedActorSystems-2b3bf4.o
/Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/bin/swift-frontend -frontend -merge-modules -emit-module /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/distributed_actor_to_actor-93d4b3.swiftmodule /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/FakeDistributedActorSystems-2b3bf4.swiftmodule -parse-as-library -disable-diagnostic-passes -disable-sil-perf-optzns -target arm64-apple-macosx10.13 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -color-diagnostics -I /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/test-macosx-arm64/Distributed/Runtime/Output/distributed_actor_to_actor.swift.tmp -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/lib -g -module-cache-path /Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/swift-test-results/arm64-apple-macosx10.13/clang-module-cache -swift-version 4 -define-availability "SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -define-availability "SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2" -define-availability "SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0" -define-availability "SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4" -define-availability "SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0" -define-availability "SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5" -define-availability "SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0" -define-availability "SwiftStdlib 5.6:macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4" -define-availability "SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0" -define-availability "SwiftStdlib 5.8:macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4" -define-availability "SwiftStdlib 5.9:macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0" -define-availability "SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.1" -define-availability "SwiftStdlib 6.0:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999" -disable-availability-checking -enable-anonymous-context-mangled-names -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/host/plugins -plugin-path /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/local/lib/swift/host/plugins -target-sdk-version 14.0 -dwarf-version=4 -emit-module-doc-path /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/main-bbfe55.swiftdoc -emit-module-source-info-path /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/main-bbfe55.swiftsourceinfo -module-name main -o /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/main-bbfe55.swiftmodule
/usr/bin/ld /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/distributed_actor_to_actor-93d4b3.o /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/FakeDistributedActorSystems-2b3bf4.o -add_ast_path /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/main-bbfe55.swiftmodule /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/clang/lib/darwin/libclang_rt.osx.a -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/lib -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -lobjc -lSystem -arch arm64 -force_load /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx/libswiftCompatibilityConcurrency.a -force_load /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx/libswiftCompatibility56.a /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx/libswiftCompatibilityPacks.a -L /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift -rpath /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx -rpath /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift -platform_version macos 11.0.0 14.0.0 -no_objc_category_merging -rpath /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -rpath /usr/lib/swift -headerpad_max_install_names -rpath /Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/lib -o /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/test-macosx-arm64/Distributed/Runtime/Output/distributed_actor_to_actor.swift.tmp/a.out
/usr/bin/dsymutil /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/test-macosx-arm64/Distributed/Runtime/Output/distributed_actor_to_actor.swift.tmp/a.out -o /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/test-macosx-arm64/Distributed/Runtime/Output/distributed_actor_to_actor.swift.tmp/a.out.dSYM
/// ------
-> % /usr/bin/ld /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/distributed_actor_to_actor-93d4b3.o /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/FakeDistributedActorSystems-2b3bf4.o -add_ast_path /var/folders/hn/c22y4jsn4j74mw23_kpgn88w0000gn/T/main-bbfe55.swiftmodule /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/clang/lib/darwin/libclang_rt.osx.a -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/lib -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -lobjc -lSystem -arch arm64 -force_load /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx/libswiftCompatibilityConcurrency.a -force_load /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx/libswiftCompatibility56.a /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx/libswiftCompatibilityPacks.a -L /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift -rpath /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx -rpath /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift -platform_version macos 11.0.0 14.0.0 -no_objc_category_merging -rpath /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -rpath /usr/lib/swift -headerpad_max_install_names -rpath /Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/lib -o /Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/test-macosx-arm64/Distributed/Runtime/Output/distributed_actor_to_actor.swift.tmp/a.out -v
@(#)PROGRAM:ld PROJECT:dyld-1015.7
BUILD 16:59:34 Oct 1 2023
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.0.12.3)
Library search paths:
/Volumes/ExternalT7/code-external/swift-project-build/Ninja-DebugAssert/swift-macosx-arm64/lib/swift/macosx
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift
Framework search paths:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks
/Users/ktoso/code/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/lib
ld: Undefined symbols:
_main, referenced from:
<initial-undefines>
*/

View File

@@ -0,0 +1,67 @@
// REQUIRES: VENDOR=apple
// REQUIRES: concurrency
// REQUIRES: distributed
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-swift-frontend %t/library.swift \
// RUN: -enable-library-evolution \
// RUN: -disable-availability-checking \
// RUN: -emit-ir -o %t/test.ll -emit-tbd \
// RUN: -emit-tbd-path %t/library.tbd -I %t -tbd-install_name protocol
// RUN: %target-swift-frontend %t/library.swift \
// RUN: -enable-library-evolution \
// RUN: -disable-availability-checking \
// RUN: -emit-module \
// RUN: -package-name Package \
// RUN: -module-name Library \
// RUN: -emit-module-path %t/Library.swiftmodule \
// RUN: -emit-module-interface-path %t/Library.swiftinterface
// RUN: %target-swift-frontend %t/actor.swift -enable-library-evolution \
// RUN: -disable-availability-checking -emit-ir -o %t/test.ll -emit-tbd \
// RUN: -emit-tbd-path %t/actor.tbd -I %t -tbd-install_name actor
// RUN: %target-swift-frontend %t/actor.swift \
// RUN: -I %t \
// RUN: -disable-availability-checking \
// RUN: -emit-module \
// RUN: -package-name Package \
// RUN: -enable-library-evolution \
// RUN: -module-name Client \
// RUN: -emit-module-path %t/Client.swiftmodule \
// RUN: -emit-module-interface-path %t/Client.swiftinterface
// RUN %llvm-nm -g %t/library.tbd | %FileCheck %s --dump-input=always
// RUN %llvm-nm -g %t/actor.tbd | %FileCheck %s --dump-input=always
//--- library.swift
import Distributed
// CHECK: @"$s4test1AC13_remote_helloyyYaKFTE" = hidden global %swift.async_func_pointer
// CHECK: @"$s4test1AC13_remote_helloyyYaKFTETu" = hidden global %swift.async_func_pointer
public protocol GreeterProtocol: DistributedActor where ActorSystem == LocalTestingDistributedActorSystem {
distributed func hello(name: String) -> String
}
//--- actor.swift
import Distributed
import Library
public distributed actor SomeDistributedActor: GreeterProtocol {
public distributed func hello(name: String) -> String {
"Hello, \(name)!"
}
}
// function:
// IR unmangledName = $s4test20SomeDistributedActorC5hello4nameS2S_tF
// function method descriptor
// IR unmangledName = $s4test20SomeDistributedActorC5hello4nameS2S_tFTq
// thunk, method reference
// IR unmangledName = $s4test20SomeDistributedActorC5hello4nameS2S_tFTE
// thunk, method reference + async function pointer
// IR unmangledName = $s4test20SomeDistributedActorC5hello4nameS2S_tFTETu