Skip to content

Commit 2e9d830

Browse files
authored
Unrolled build for rust-lang#130077
Rollup merge of rust-lang#130077 - madsmtm:watchos-arm-unwind, r=workingjubilee Fix linking error when compiling for 32-bit watchOS In rust-lang#124494 (or rust-lang#124748), I mistakenly conflated "not SjLj" to mean "ARM EHABI", which isn't true, 32-bit watchOS uses a third unwinding method called "DWARF CFI". So this PR is effectively a revert of rust-lang#124494, with a few more comments explaining what's going on. Fixes rust-lang#130071. r? Mark-Simulacrum (since you reviewed the original)
2 parents 8d6b88b + f98ca32 commit 2e9d830

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

library/std/src/sys/personality/dwarf/eh.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ pub enum EHAction {
5454
Terminate,
5555
}
5656

57-
/// 32-bit Apple ARM uses SjLj exceptions, except for watchOS.
57+
/// 32-bit ARM Darwin platforms uses SjLj exceptions.
5858
///
59-
/// I.e. iOS and tvOS, as those are the only Apple OSes that used 32-bit ARM
60-
/// devices.
59+
/// The exception is watchOS armv7k (specifically that subarchitecture), which
60+
/// instead uses DWARF Call Frame Information (CFI) unwinding.
6161
///
6262
/// <https://github.com/llvm/llvm-project/blob/llvmorg-18.1.4/clang/lib/Driver/ToolChains/Darwin.cpp#L3107-L3119>
6363
pub const USING_SJLJ_EXCEPTIONS: bool =

library/std/src/sys/personality/gcc.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,15 @@ const UNWIND_DATA_REG: (i32, i32) = (4, 5); // a0, a1
9595

9696
cfg_if::cfg_if! {
9797
if #[cfg(all(
98-
target_arch = "arm",
99-
not(all(target_vendor = "apple", not(target_os = "watchos"))),
100-
not(target_os = "netbsd"),
101-
))] {
98+
target_arch = "arm",
99+
not(target_vendor = "apple"),
100+
not(target_os = "netbsd"),
101+
))] {
102102
/// personality fn called by [ARM EHABI][armeabi-eh]
103103
///
104-
/// Apple 32-bit ARM (but not watchOS) uses the default routine instead
105-
/// since it uses "setjmp-longjmp" unwinding.
104+
/// 32-bit ARM on iOS/tvOS/watchOS does not use ARM EHABI, it uses
105+
/// either "setjmp-longjmp" unwinding or DWARF CFI unwinding, which is
106+
/// handled by the default routine.
106107
///
107108
/// [armeabi-eh]: https://web.archive.org/web/20190728160938/https://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf
108109
#[lang = "eh_personality"]

library/unwind/src/libunwind.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ pub const unwinder_private_data_size: usize = 2;
3333
#[cfg(all(target_arch = "x86_64", target_os = "windows"))]
3434
pub const unwinder_private_data_size: usize = 6;
3535

36-
#[cfg(all(target_arch = "arm", not(all(target_vendor = "apple", not(target_os = "watchos")))))]
36+
#[cfg(all(target_arch = "arm", not(target_vendor = "apple")))]
3737
pub const unwinder_private_data_size: usize = 20;
3838

39-
#[cfg(all(target_arch = "arm", all(target_vendor = "apple", not(target_os = "watchos"))))]
39+
#[cfg(all(target_arch = "arm", target_vendor = "apple"))]
4040
pub const unwinder_private_data_size: usize = 5;
4141

4242
#[cfg(all(target_arch = "aarch64", target_pointer_width = "64", not(target_os = "windows")))]
@@ -123,8 +123,11 @@ extern "C" {
123123
}
124124

125125
cfg_if::cfg_if! {
126-
if #[cfg(any(all(target_vendor = "apple", not(target_os = "watchos")), target_os = "netbsd", not(target_arch = "arm")))] {
126+
if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "arm")))] {
127127
// Not ARM EHABI
128+
//
129+
// 32-bit ARM on iOS/tvOS/watchOS use either DWARF/Compact unwinding or
130+
// "setjmp-longjmp" / SjLj unwinding.
128131
#[repr(C)]
129132
#[derive(Copy, Clone, PartialEq)]
130133
pub enum _Unwind_Action {
@@ -259,8 +262,8 @@ if #[cfg(any(all(target_vendor = "apple", not(target_os = "watchos")), target_os
259262

260263
cfg_if::cfg_if! {
261264
if #[cfg(all(target_vendor = "apple", not(target_os = "watchos"), target_arch = "arm"))] {
262-
// 32-bit ARM Apple (except for watchOS) uses SjLj and does not provide
263-
// _Unwind_Backtrace()
265+
// 32-bit ARM Apple (except for watchOS armv7k specifically) uses SjLj and
266+
// does not provide _Unwind_Backtrace()
264267
extern "C-unwind" {
265268
pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
266269
}

0 commit comments

Comments
 (0)