Skip to content

Commit 9e41e37

Browse files
authored
Merge pull request #39935 from DougGregor/watchos-noasyncframepointer-backdeploy
Disable the definition and use of swift_async_extendedFramePointerFlags on watchOS
2 parents 157c742 + 26b7cbc commit 9e41e37

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
@@ -1982,6 +1982,15 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
19821982
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
19831983
A->getAsString(Args), A->getValue());
19841984
}
1985+
} else if (Triple.isWatchOS() && !Triple.isSimulatorEnvironment()) {
1986+
// watchOS does not support auto async frame pointers due to bitcode, so
1987+
// silently override "auto" to "never" when back-deploying. This approach
1988+
// sacrifies async backtraces when back-deploying but prevents crashes in
1989+
// older tools that cannot handle the async frame bit in the frame pointer.
1990+
unsigned major, minor, micro;
1991+
Triple.getWatchOSVersion(major, minor, micro);
1992+
if (major < 8)
1993+
Opts.SwiftAsyncFramePointer = SwiftAsyncFramePointerKind::Never;
19851994
}
19861995

19871996
return false;

stdlib/public/Concurrency/Task.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,19 @@
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 device precludes defining the following asm
43+
// symbols, so we don't use them... but simulators are okay.
44+
#if TARGET_OS_SIMULATOR
3945
asm("\n .globl _swift_async_extendedFramePointerFlags" \
4046
"\n _swift_async_extendedFramePointerFlags = 0x0");
47+
#endif
48+
#else
49+
asm("\n .globl _swift_async_extendedFramePointerFlags" \
50+
"\n _swift_async_extendedFramePointerFlags = 0x0");
51+
#endif
4152
#else
4253
#ifdef __APPLE__
4354
#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)