Skip to content

Commit 05fa143

Browse files
authored
Merge pull request #40221 from etcwilde/ewilde/include-missing-api-in-swinterface
Include missing `_getMainExecutor` and `_asyncMainDrainQueue` in concurrency swiftinterface
2 parents c569b39 + 1c852f9 commit 05fa143

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/SILGen/SILGenFunction.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,25 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
959959

960960
// Start Main loop!
961961
FuncDecl *drainQueueFuncDecl = SGM.getAsyncMainDrainQueue();
962+
if (!drainQueueFuncDecl) {
963+
// If it doesn't exist, we can conjure one up instead of crashing
964+
// @available(SwiftStdlib 5.5, *)
965+
// @_silgen_name("swift_task_asyncMainDrainQueue")
966+
// internal func _asyncMainDrainQueue() -> Never
967+
ParameterList *emptyParams = ParameterList::createEmpty(getASTContext());
968+
drainQueueFuncDecl = FuncDecl::createImplicit(
969+
getASTContext(), StaticSpellingKind::None,
970+
DeclName(
971+
getASTContext(),
972+
DeclBaseName(getASTContext().getIdentifier("_asyncMainDrainQueue")),
973+
/*Arguments*/ emptyParams),
974+
{}, /*async*/ false, /*throws*/ false, {}, emptyParams,
975+
getASTContext().getNeverType(),
976+
entryPoint.getDecl()->getModuleContext());
977+
drainQueueFuncDecl->getAttrs().add(new (getASTContext()) SILGenNameAttr(
978+
"swift_task_asyncMainDrainQueue", /*implicit*/ true));
979+
}
980+
962981
SILFunction *drainQueueSILFunc = SGM.getFunction(
963982
SILDeclRef(drainQueueFuncDecl, SILDeclRef::Kind::Func), NotForDefinition);
964983
SILValue drainQueueFunc =

stdlib/public/Concurrency/Task.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,12 @@ func _enqueueJobGlobal(_ task: Builtin.Job)
752752
func _enqueueJobGlobalWithDelay(_ delay: UInt64, _ task: Builtin.Job)
753753

754754
@available(SwiftStdlib 5.1, *)
755+
@usableFromInline
755756
@_silgen_name("swift_task_asyncMainDrainQueue")
756757
internal func _asyncMainDrainQueue() -> Never
757758

758759
@available(SwiftStdlib 5.1, *)
760+
@usableFromInline
759761
@_silgen_name("swift_task_getMainExecutor")
760762
internal func _getMainExecutor() -> Builtin.Executor
761763

0 commit comments

Comments
 (0)