Skip to content

Commit cf04327

Browse files
committed
[HACK] Add sjlj flag for mingw-w64 cross build
1 parent 6d56825 commit cf04327

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

mk/platform.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ CFG_PATH_MUNGE_i686-w64-mingw32 :=
521521
CFG_LDPATH_i686-w64-mingw32 :=$(CFG_LDPATH_i686-w64-mingw32):$(PATH)
522522
CFG_RUN_i686-w64-mingw32=PATH="$(CFG_LDPATH_i686-w64-mingw32):$(1)" $(2)
523523
CFG_RUN_TARG_i686-w64-mingw32=$(call CFG_RUN_i686-w64-mingw32,$(HLIB$(1)_H_$(CFG_BUILD)),$(2))
524-
RUSTC_CROSS_FLAGS_i686-w64-mingw32 :=
524+
RUSTC_CROSS_FLAGS_i686-w64-mingw32 :=--cfg sjlj
525525

526526
# x86_64-w64-mingw32 configuration
527527
CROSS_PREFIX_x86_64-w64-mingw32=x86_64-w64-mingw32-

src/librustrt/libunwind.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ extern {}
9898
extern "C" {
9999
// iOS on armv7 uses SjLj exceptions and requires to link
100100
// against corresponding routine (..._SjLj_...)
101-
#[cfg(not(target_os = "ios", target_arch = "arm"))]
101+
#[cfg(not(target_os = "ios", target_arch = "arm"), not(sjlj))]
102102
pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception)
103103
-> _Unwind_Reason_Code;
104104

105+
#[cfg(sjlj)]
105106
#[cfg(target_os = "ios", target_arch = "arm")]
106107
fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception)
107108
-> _Unwind_Reason_Code;
@@ -112,6 +113,7 @@ extern "C" {
112113
// ... and now we just providing access to SjLj counterspart
113114
// through a standard name to hide those details from others
114115
// (see also comment above regarding _Unwind_RaiseException)
116+
#[cfg(sjlj)]
115117
#[cfg(target_os = "ios", target_arch = "arm")]
116118
#[inline(always)]
117119
pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception)

src/librustrt/unwind.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ fn rust_exception_class() -> uw::_Unwind_Exception_Class {
224224
// This is achieved by overriding the return value in search phase to always
225225
// say "catch!".
226226

227-
#[cfg(not(target_arch = "arm"), not(test))]
227+
#[cfg(not(target_arch = "arm"), not(test), not(sjlj))]
228228
#[doc(hidden)]
229229
#[allow(visible_private_types)]
230230
pub mod eabi {
@@ -279,6 +279,7 @@ pub mod eabi {
279279
// iOS on armv7 is using SjLj exceptions and therefore requires to use
280280
// a specialized personality routine: __gcc_personality_sj0
281281

282+
#[cfg(sjlj)]
282283
#[cfg(target_os = "ios", target_arch = "arm", not(test))]
283284
#[doc(hidden)]
284285
#[allow(visible_private_types)]
@@ -521,3 +522,11 @@ pub unsafe fn register(f: Callback) -> bool {
521522
}
522523
}
523524
}
525+
526+
// dummy functions for #12859
527+
#[cfg(sjlj)]
528+
#[no_mangle]
529+
#[allow(non_snake_case_functions)]
530+
pub extern "C" fn _Unwind_Resume(_ex_obj: *mut ()) {
531+
// _ex_obj is actually *mut uw::_Unwind_Exception, but it is private
532+
}

0 commit comments

Comments
 (0)