Skip to content

Commit

Permalink
[HACK] Add sjlj flag for mingw-w64 cross build
Browse files Browse the repository at this point in the history
  • Loading branch information
klutzy committed Jul 17, 2014
1 parent 6d56825 commit cf04327
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mk/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ CFG_PATH_MUNGE_i686-w64-mingw32 :=
CFG_LDPATH_i686-w64-mingw32 :=$(CFG_LDPATH_i686-w64-mingw32):$(PATH)
CFG_RUN_i686-w64-mingw32=PATH="$(CFG_LDPATH_i686-w64-mingw32):$(1)" $(2)
CFG_RUN_TARG_i686-w64-mingw32=$(call CFG_RUN_i686-w64-mingw32,$(HLIB$(1)_H_$(CFG_BUILD)),$(2))
RUSTC_CROSS_FLAGS_i686-w64-mingw32 :=
RUSTC_CROSS_FLAGS_i686-w64-mingw32 :=--cfg sjlj

# x86_64-w64-mingw32 configuration
CROSS_PREFIX_x86_64-w64-mingw32=x86_64-w64-mingw32-
Expand Down
4 changes: 3 additions & 1 deletion src/librustrt/libunwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ extern {}
extern "C" {
// iOS on armv7 uses SjLj exceptions and requires to link
// against corresponding routine (..._SjLj_...)
#[cfg(not(target_os = "ios", target_arch = "arm"))]
#[cfg(not(target_os = "ios", target_arch = "arm"), not(sjlj))]
pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception)
-> _Unwind_Reason_Code;

#[cfg(sjlj)]
#[cfg(target_os = "ios", target_arch = "arm")]
fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception)
-> _Unwind_Reason_Code;
Expand All @@ -112,6 +113,7 @@ extern "C" {
// ... and now we just providing access to SjLj counterspart
// through a standard name to hide those details from others
// (see also comment above regarding _Unwind_RaiseException)
#[cfg(sjlj)]
#[cfg(target_os = "ios", target_arch = "arm")]
#[inline(always)]
pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception)
Expand Down
11 changes: 10 additions & 1 deletion src/librustrt/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn rust_exception_class() -> uw::_Unwind_Exception_Class {
// This is achieved by overriding the return value in search phase to always
// say "catch!".

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

#[cfg(sjlj)]
#[cfg(target_os = "ios", target_arch = "arm", not(test))]
#[doc(hidden)]
#[allow(visible_private_types)]
Expand Down Expand Up @@ -521,3 +522,11 @@ pub unsafe fn register(f: Callback) -> bool {
}
}
}

// dummy functions for #12859
#[cfg(sjlj)]
#[no_mangle]
#[allow(non_snake_case_functions)]
pub extern "C" fn _Unwind_Resume(_ex_obj: *mut ()) {
// _ex_obj is actually *mut uw::_Unwind_Exception, but it is private
}

0 comments on commit cf04327

Please sign in to comment.