Skip to content

Commit 3793566

Browse files
committed
TDBGen: add a workaround for a workaround for async PWT
When a protocol witness thunk is formed to a serialised protocol containing an `async` function, the async function pointer to the conformance needs to be made public due to a SIL Verifier check failure (reference to a non-fragile function from within a public fragile function). Add a stop-gap solution of rolling an extra emission for a private symbol as a public symbol to avoid the error (the underlying issue has been open for ~6y and counting as of this commit). This was identified by swift-package-manager (#64900).
1 parent 387b73f commit 3793566

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/IRGen/TBDGen.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,15 @@ void TBDGenVisitor::addProtocolWitnessThunk(RootProtocolConformance *C,
472472
ValueDecl *requirementDecl) {
473473
Mangle::ASTMangler Mangler;
474474

475+
std::string decorated = Mangler.mangleWitnessThunk(C, requirementDecl);
475476
// FIXME: We should have a SILDeclRef SymbolSource for this.
476-
addSymbol(Mangler.mangleWitnessThunk(C, requirementDecl),
477-
SymbolSource::forUnknown());
477+
addSymbol(decorated, SymbolSource::forUnknown());
478+
479+
ValueDecl *PWT = C->getWitness(requirementDecl).getDecl();
480+
if (fixmeWitnessHasLinkageThatNeedsToBePublic(SILDeclRef(PWT)))
481+
if (const auto *AFD = dyn_cast<AbstractFunctionDecl>(PWT))
482+
if (AFD->hasAsync())
483+
addSymbol(decorated + "Tu", SymbolSource::forUnknown());
478484
}
479485

480486
void TBDGenVisitor::addFirstFileSymbols() {

0 commit comments

Comments
 (0)