Skip to content

Commit 4aca32c

Browse files
committed
Disable the definition and use of swift_async_extendedFramePointerFlags on watchOS
The asm definition of `swift_async_extendedFramePointerFlags` prevents the use of bitcode with the back-deployment libraries, so remove the definition and use of this symbol from watchOS binaries entirely. Instead, always force the async frame bit to be set. This trades off backtraces on older OS's for debuggability of newer ones. If it causes problems, it can be disabled via the option `-swift-async-frame-pointer=never`. Fixes rdar://84687579.
1 parent 889d65d commit 4aca32c

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,14 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
19841984
}
19851985
}
19861986

1987+
// watchOS does not support auto async frame pointers due to bitcode, so
1988+
// silently override "auto" to "always". This approach sacrifies async
1989+
// backtraces in older watchOS versions to gain better backtraces in newer
1990+
// versions.
1991+
if (Triple.isWatchOS() &&
1992+
Opts.SwiftAsyncFramePointer == SwiftAsyncFramePointerKind::Auto)
1993+
Opts.SwiftAsyncFramePointer = SwiftAsyncFramePointerKind::Always;
1994+
19871995
return false;
19881996
}
19891997

stdlib/public/Concurrency/Task.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,15 @@
3636
#endif
3737

3838
#if defined(SWIFT_CONCURRENCY_BACK_DEPLOYMENT)
39+
#include <Availability.h>
40+
#include <TargetConditionals.h>
41+
#if TARGET_OS_WATCH
42+
// Bitcode compilation for the watch precludes defining the following asm
43+
// symbols, so we don't use them.
44+
#else
3945
asm("\n .globl _swift_async_extendedFramePointerFlags" \
4046
"\n _swift_async_extendedFramePointerFlags = 0x0");
47+
#endif
4148
#else
4249
#ifdef __APPLE__
4350
#if __POINTER_WIDTH__ == 64
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos7 %s -S | %FileCheck -check-prefix=ALWAYS %s
2+
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos8 %s -S | %FileCheck -check-prefix=ALWAYS %s
3+
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos7 -swift-async-frame-pointer=auto %s -S | %FileCheck -check-prefix=ALWAYS %s
4+
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos7 -swift-async-frame-pointer=never %s -S | %FileCheck -check-prefix=NEVER %s
5+
6+
// REQUIRES: OS=watchos
7+
8+
public func someAsyncFunction() async {
9+
}
10+
11+
// ALWAYS-NOT: swift_async_extendedFramePointerFlags
12+
// NEVER-NOT: swift_async_extendedFramePointerFlags

0 commit comments

Comments
 (0)