Skip to content

[Concurrency] Hide async_Main from other object files #69113

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
9 changes: 7 additions & 2 deletions lib/SIL/IR/SILDeclRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,13 @@ SILLinkage SILDeclRef::getDefinitionLinkage() const {
// The main entry-point is public.
if (kind == Kind::EntryPoint)
return SILLinkage::Public;
if (kind == Kind::AsyncEntryPoint)
return SILLinkage::Hidden;
if (kind == Kind::AsyncEntryPoint) {
// async main entrypoint is referenced only from @main and
// they are in the same SIL module. Hiding this entrypoint
// from other object file makes it possible to link multiple
// executable targets for SwiftPM testing with -entry-point-function-name
return SILLinkage::Private;
}

// Calling convention thunks have shared linkage.
if (isForeignToNativeThunk())
Expand Down
2 changes: 1 addition & 1 deletion test/Concurrency/async_main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func asyncFunc() async {


// async_Main
// CHECK-SIL-LABEL: sil hidden @async_Main : $@convention(thin) @async () -> () {
// CHECK-SIL-LABEL: sil private @async_Main : $@convention(thin) @async () -> () {
// call main
// CHECK-SIL: %0 = metatype $@thin MyProgram.Type // user: %2
// CHECK-SIL-NEXT: // function_ref static MyProgram.$main()
Expand Down
2 changes: 1 addition & 1 deletion test/SILGen/toplevel_globalactorvars.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// a
// CHECK-LABEL: sil_global hidden @$s24toplevel_globalactorvars1aSivp : $Int

// CHECK-LABEL: sil hidden [ossa] @async_Main
// CHECK-LABEL: sil private [ossa] @async_Main
// CHECK: bb0:
// CHECK-NEXT: // function_ref
// CHECK-NEXT: [[GET_MAIN:%.*]] = function_ref @swift_task_getMainExecutor
Expand Down