Skip to content

Include missing _getMainExecutor and _asyncMainDrainQueue in concurrency swiftinterface #40221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/SILGen/SILGenFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,25 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {

// Start Main loop!
FuncDecl *drainQueueFuncDecl = SGM.getAsyncMainDrainQueue();
if (!drainQueueFuncDecl) {
// If it doesn't exist, we can conjure one up instead of crashing
// @available(SwiftStdlib 5.5, *)
// @_silgen_name("swift_task_asyncMainDrainQueue")
// internal func _asyncMainDrainQueue() -> Never
ParameterList *emptyParams = ParameterList::createEmpty(getASTContext());
drainQueueFuncDecl = FuncDecl::createImplicit(
getASTContext(), StaticSpellingKind::None,
DeclName(
getASTContext(),
DeclBaseName(getASTContext().getIdentifier("_asyncMainDrainQueue")),
/*Arguments*/ emptyParams),
{}, /*async*/ false, /*throws*/ false, {}, emptyParams,
getASTContext().getNeverType(),
entryPoint.getDecl()->getModuleContext());
drainQueueFuncDecl->getAttrs().add(new (getASTContext()) SILGenNameAttr(
"swift_task_asyncMainDrainQueue", /*implicit*/ true));
}

SILFunction *drainQueueSILFunc = SGM.getFunction(
SILDeclRef(drainQueueFuncDecl, SILDeclRef::Kind::Func), NotForDefinition);
SILValue drainQueueFunc =
Expand Down
2 changes: 2 additions & 0 deletions stdlib/public/Concurrency/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -752,10 +752,12 @@ func _enqueueJobGlobal(_ task: Builtin.Job)
func _enqueueJobGlobalWithDelay(_ delay: UInt64, _ task: Builtin.Job)

@available(SwiftStdlib 5.1, *)
@usableFromInline
@_silgen_name("swift_task_asyncMainDrainQueue")
internal func _asyncMainDrainQueue() -> Never

@available(SwiftStdlib 5.1, *)
@usableFromInline
@_silgen_name("swift_task_getMainExecutor")
internal func _getMainExecutor() -> Builtin.Executor

Expand Down