1
Fork 0

Rollup merge of #130077 - madsmtm:watchos-arm-unwind, r=workingjubilee

Fix linking error when compiling for 32-bit watchOS

In https://github.com/rust-lang/rust/pull/124494 (or https://github.com/rust-lang/rust/pull/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 https://github.com/rust-lang/rust/pull/124494, with a few more comments explaining what's going on.

Fixes https://github.com/rust-lang/rust/issues/130071.

r? Mark-Simulacrum (since you reviewed the original)
This commit is contained in:
Jubilee 2024-09-11 15:53:22 -07:00 committed by GitHub
commit c4488c49de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 14 deletions

View file

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

View file

@ -95,14 +95,15 @@ const UNWIND_DATA_REG: (i32, i32) = (4, 5); // a0, a1
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(all( if #[cfg(all(
target_arch = "arm", target_arch = "arm",
not(all(target_vendor = "apple", not(target_os = "watchos"))), not(target_vendor = "apple"),
not(target_os = "netbsd"), not(target_os = "netbsd"),
))] { ))] {
/// personality fn called by [ARM EHABI][armeabi-eh] /// personality fn called by [ARM EHABI][armeabi-eh]
/// ///
/// Apple 32-bit ARM (but not watchOS) uses the default routine instead /// 32-bit ARM on iOS/tvOS/watchOS does not use ARM EHABI, it uses
/// since it uses "setjmp-longjmp" unwinding. /// either "setjmp-longjmp" unwinding or DWARF CFI unwinding, which is
/// handled by the default routine.
/// ///
/// [armeabi-eh]: https://web.archive.org/web/20190728160938/https://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf /// [armeabi-eh]: https://web.archive.org/web/20190728160938/https://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf
#[lang = "eh_personality"] #[lang = "eh_personality"]

View file

@ -33,10 +33,10 @@ pub const unwinder_private_data_size: usize = 2;
#[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[cfg(all(target_arch = "x86_64", target_os = "windows"))]
pub const unwinder_private_data_size: usize = 6; pub const unwinder_private_data_size: usize = 6;
#[cfg(all(target_arch = "arm", not(all(target_vendor = "apple", not(target_os = "watchos")))))] #[cfg(all(target_arch = "arm", not(target_vendor = "apple")))]
pub const unwinder_private_data_size: usize = 20; pub const unwinder_private_data_size: usize = 20;
#[cfg(all(target_arch = "arm", all(target_vendor = "apple", not(target_os = "watchos"))))] #[cfg(all(target_arch = "arm", target_vendor = "apple"))]
pub const unwinder_private_data_size: usize = 5; pub const unwinder_private_data_size: usize = 5;
#[cfg(all(target_arch = "aarch64", target_pointer_width = "64", not(target_os = "windows")))] #[cfg(all(target_arch = "aarch64", target_pointer_width = "64", not(target_os = "windows")))]
@ -123,8 +123,11 @@ extern "C" {
} }
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(any(all(target_vendor = "apple", not(target_os = "watchos")), target_os = "netbsd", not(target_arch = "arm")))] { if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "arm")))] {
// Not ARM EHABI // Not ARM EHABI
//
// 32-bit ARM on iOS/tvOS/watchOS use either DWARF/Compact unwinding or
// "setjmp-longjmp" / SjLj unwinding.
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, PartialEq)] #[derive(Copy, Clone, PartialEq)]
pub enum _Unwind_Action { pub enum _Unwind_Action {
@ -259,8 +262,8 @@ if #[cfg(any(all(target_vendor = "apple", not(target_os = "watchos")), target_os
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(all(target_vendor = "apple", not(target_os = "watchos"), target_arch = "arm"))] { if #[cfg(all(target_vendor = "apple", not(target_os = "watchos"), target_arch = "arm"))] {
// 32-bit ARM Apple (except for watchOS) uses SjLj and does not provide // 32-bit ARM Apple (except for watchOS armv7k specifically) uses SjLj and
// _Unwind_Backtrace() // does not provide _Unwind_Backtrace()
extern "C-unwind" { extern "C-unwind" {
pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code; pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
} }