Skip to content

Disable the definition and use of swift_async_extendedFramePointerFlags on watchOS #39935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,15 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
A->getAsString(Args), A->getValue());
}
} else if (Triple.isWatchOS() && !Triple.isSimulatorEnvironment()) {
// watchOS does not support auto async frame pointers due to bitcode, so
// silently override "auto" to "never" when back-deploying. This approach
// sacrifies async backtraces when back-deploying but prevents crashes in
// older tools that cannot handle the async frame bit in the frame pointer.
unsigned major, minor, micro;
Triple.getWatchOSVersion(major, minor, micro);
if (major < 8)
Opts.SwiftAsyncFramePointer = SwiftAsyncFramePointerKind::Never;
}

return false;
Expand Down
11 changes: 11 additions & 0 deletions stdlib/public/Concurrency/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,19 @@
#endif

#if defined(SWIFT_CONCURRENCY_BACK_DEPLOYMENT)
#include <Availability.h>
#include <TargetConditionals.h>
#if TARGET_OS_WATCH
// Bitcode compilation for the watch device precludes defining the following asm
// symbols, so we don't use them... but simulators are okay.
#if TARGET_OS_SIMULATOR
asm("\n .globl _swift_async_extendedFramePointerFlags" \
"\n _swift_async_extendedFramePointerFlags = 0x0");
#endif
#else
asm("\n .globl _swift_async_extendedFramePointerFlags" \
"\n _swift_async_extendedFramePointerFlags = 0x0");
#endif
#else
#ifdef __APPLE__
#if __POINTER_WIDTH__ == 64
Expand Down
20 changes: 20 additions & 0 deletions test/IRGen/swift_async_extended_frame_info_watchos.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos7 %s -S | %FileCheck -check-prefix=NEVER %s
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos8 %s -S | %FileCheck -check-prefix=ALWAYS %s
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos7 -swift-async-frame-pointer=always %s -S | %FileCheck -check-prefix=ALWAYS %s
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos7 -swift-async-frame-pointer=never %s -S | %FileCheck -check-prefix=NEVER %s
// RUN: %target-swift-frontend -disable-availability-checking -target arm64_32-apple-watchos7 -swift-async-frame-pointer=auto %s -S | %FileCheck -check-prefix=AUTO %s

// REQUIRES: OS=watchos
// REQUIRES: CPU=armv7k || CPU=arm64_32

public func someAsyncFunction() async {
}

// AUTO: swift_async_extendedFramePointerFlags

// ALWAYS-NOT: swift_async_extendedFramePointerFlags
// ALWAYS: 0x1000000000000000
// ALWAYS-NOT: swift_async_extendedFramePointerFlags

// NEVER-NOT: swift_async_extendedFramePointerFlags
// NEVER-NOT: 0x1000000000000000