Skip to content

Commit c0694ca

Browse files
Merge pull request #69195 from kateinoigakukun/yt/release-5.10-cherry-pick-private-async-main
[5.10][Concurrency] Hide `async_Main` from other object files
2 parents fd38fe4 + 37c3caa commit c0694ca

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

lib/SIL/IR/SILDeclRef.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,13 @@ SILLinkage SILDeclRef::getDefinitionLinkage() const {
538538
// The main entry-point is public.
539539
if (kind == Kind::EntryPoint)
540540
return SILLinkage::Public;
541-
if (kind == Kind::AsyncEntryPoint)
542-
return SILLinkage::Hidden;
541+
if (kind == Kind::AsyncEntryPoint) {
542+
// async main entrypoint is referenced only from @main and
543+
// they are in the same SIL module. Hiding this entrypoint
544+
// from other object file makes it possible to link multiple
545+
// executable targets for SwiftPM testing with -entry-point-function-name
546+
return SILLinkage::Private;
547+
}
543548

544549
// Calling convention thunks have shared linkage.
545550
if (isForeignToNativeThunk())

test/Concurrency/async_main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func asyncFunc() async {
4040

4141

4242
// async_Main
43-
// CHECK-SIL-LABEL: sil hidden @async_Main : $@convention(thin) @async () -> () {
43+
// CHECK-SIL-LABEL: sil private @async_Main : $@convention(thin) @async () -> () {
4444
// call main
4545
// CHECK-SIL: %0 = metatype $@thin MyProgram.Type // user: %2
4646
// CHECK-SIL-NEXT: // function_ref static MyProgram.$main()

test/SILGen/toplevel_globalactorvars.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// a
44
// CHECK-LABEL: sil_global hidden @$s24toplevel_globalactorvars1aSivp : $Int
55

6-
// CHECK-LABEL: sil hidden [ossa] @async_Main
6+
// CHECK-LABEL: sil private [ossa] @async_Main
77
// CHECK: bb0:
88
// CHECK-NEXT: // function_ref
99
// CHECK-NEXT: [[GET_MAIN:%.*]] = function_ref @swift_task_getMainExecutor

0 commit comments

Comments
 (0)