Skip to content

Commit 2191f87

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 2a460ca commit 2191f87

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
@@ -1824,6 +1824,14 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
18241824
}
18251825
}
18261826

1827+
// watchOS does not support auto async frame pointers due to bitcode, so
1828+
// silently override "auto" to "always". This approach sacrifies async
1829+
// backtraces in older watchOS versions to gain better backtraces in newer
1830+
// versions.
1831+
if (Triple.isWatchOS() &&
1832+
Opts.SwiftAsyncFramePointer == SwiftAsyncFramePointerKind::Auto)
1833+
Opts.SwiftAsyncFramePointer = SwiftAsyncFramePointerKind::Always;
1834+
18271835
return false;
18281836
}
18291837

stdlib/public/Concurrency/Task.cpp

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

3737
#if defined(SWIFT_CONCURRENCY_BACK_DEPLOYMENT)
38+
#include <Availability.h>
39+
#include <TargetConditionals.h>
40+
#if TARGET_OS_WATCH
41+
// Bitcode compilation for the watch precludes defining the following asm
42+
// symbols, so we don't use them.
43+
#else
3844
asm("\n .globl _swift_async_extendedFramePointerFlags" \
3945
"\n _swift_async_extendedFramePointerFlags = 0x0");
46+
#endif
4047
#else
4148
#ifdef __APPLE__
4249
#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)