Skip to content

Commit 21421b4

Browse files
authored
Merge pull request #39936 from DougGregor/watchos-noasyncframepointer-backdeploy-5.5
Disable the definition and use of swift_async_extendedFramePointerFlags on watchOS
2 parents 4f6c023 + f65ef8d commit 21421b4

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,6 +1822,15 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
18221822
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
18231823
A->getAsString(Args), A->getValue());
18241824
}
1825+
} else if (Triple.isWatchOS() && !Triple.isSimulatorEnvironment()) {
1826+
// watchOS does not support auto async frame pointers due to bitcode, so
1827+
// silently override "auto" to "never" when back-deploying. This approach
1828+
// sacrifies async backtraces when back-deploying but prevents crashes in
1829+
// older tools that cannot handle the async frame bit in the frame pointer.
1830+
unsigned major, minor, micro;
1831+
Triple.getWatchOSVersion(major, minor, micro);
1832+
if (major < 8)
1833+
Opts.SwiftAsyncFramePointer = SwiftAsyncFramePointerKind::Never;
18251834
}
18261835

18271836
return false;

stdlib/public/Concurrency/Task.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,19 @@
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 device precludes defining the following asm
42+
// symbols, so we don't use them... but simulators are okay.
43+
#if TARGET_OS_SIMULATOR
3844
asm("\n .globl _swift_async_extendedFramePointerFlags" \
3945
"\n _swift_async_extendedFramePointerFlags = 0x0");
46+
#endif
47+
#else
48+
asm("\n .globl _swift_async_extendedFramePointerFlags" \
49+
"\n _swift_async_extendedFramePointerFlags = 0x0");
50+
#endif
4051
#else
4152
#ifdef __APPLE__
4253
#if __POINTER_WIDTH__ == 64
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos7 %s -S | %FileCheck -check-prefix=NEVER %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=always %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+
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos7 -swift-async-frame-pointer=auto %s -S | %FileCheck -check-prefix=AUTO %s
6+
7+
// REQUIRES: OS=watchos
8+
// REQUIRES: CPU=armv7k || CPU=arm64_32
9+
10+
public func someAsyncFunction() async {
11+
}
12+
13+
// AUTO: swift_async_extendedFramePointerFlags
14+
15+
// ALWAYS-NOT: swift_async_extendedFramePointerFlags
16+
// ALWAYS: 0x1000000000000000
17+
// ALWAYS-NOT: swift_async_extendedFramePointerFlags
18+
19+
// NEVER-NOT: swift_async_extendedFramePointerFlags
20+
// NEVER-NOT: 0x1000000000000000

0 commit comments

Comments
 (0)