Skip to content
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

Fix cross-compiling i686-pc-windows-gnu from Linux #49633

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 5 additions & 0 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ pub fn std_cargo(build: &Builder,
cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
}

// FIXME: Temporary detection of SJLJ MinGW compilers.
if build.build.build.contains("linux") && target == "i686-pc-windows-gnu" {
features.push_str(" sjlj_eh");
}

// When doing a local rebuild we tell cargo that we're stage1 rather than
// stage0. This works fine if the local rust and being-built rust have the
// same view of what the default allocator is, but fails otherwise. Since
Expand Down
1 change: 1 addition & 0 deletions src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ force_alloc_system = []
panic-unwind = ["panic_unwind"]
profiler = ["profiler_builtins"]
wasm_syscall = []
sjlj_eh = ["unwind/sjlj_eh"]
4 changes: 4 additions & 0 deletions src/libunwind/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ doc = false
[dependencies]
core = { path = "../libcore" }
libc = { path = "../rustc/libc_shim" }

[features]
sjlj_eh = []

46 changes: 32 additions & 14 deletions src/libunwind/libunwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@

#![allow(bad_style)]

macro_rules! cfg_if {
( $( if #[cfg( $meta:meta )] { $($it1:item)* } else { $($it2:item)* } )* ) =>
( $( $( #[cfg($meta)] $it1)* $( #[cfg(not($meta))] $it2)* )* )
}

use libc::{c_int, c_void, uintptr_t};

#[repr(C)]
Expand Down Expand Up @@ -85,7 +80,6 @@ pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn(unwind_code: _Unwind_Reaso
extern "C" {
#[cfg_attr(stage0, unwind)]
#[cfg_attr(not(stage0), unwind(allowed))]
pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !;
pub fn _Unwind_DeleteException(exception: *mut _Unwind_Exception);
pub fn _Unwind_GetLanguageSpecificData(ctx: *mut _Unwind_Context) -> *mut c_void;
pub fn _Unwind_GetRegionStart(ctx: *mut _Unwind_Context) -> _Unwind_Ptr;
Expand Down Expand Up @@ -217,28 +211,52 @@ if #[cfg(all(any(target_os = "ios", not(target_arch = "arm"))))] {
pc
}
}
} // cfg_if!

if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] {
// Not 32-bit iOS
cfg_if! {
if #[cfg(all(target_os = "ios", target_arch = "arm"))] {
// 32-bit iOS uses SjLj and does not provide _Unwind_Backtrace()
extern "C" {
#[cfg_attr(stage0, unwind)]
#[cfg_attr(not(stage0), unwind(allowed))]
pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
trace_argument: *mut c_void)
-> _Unwind_Reason_Code;
pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !;
pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
}
} else {
// 32-bit iOS uses SjLj and does not provide _Unwind_Backtrace()

#[inline]
pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception) -> _Unwind_Reason_Code {
_Unwind_SjLj_RaiseException(exc)
}

} else if #[cfg(feature = "sjlj_eh")] {
extern "C" {
#[cfg_attr(stage0, unwind)]
#[cfg_attr(not(stage0), unwind(allowed))]
pub fn _Unwind_SjLj_Resume(e: *mut _Unwind_Exception) -> !;
pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
trace_argument: *mut c_void)
-> _Unwind_Reason_Code;
}

#[inline]
pub unsafe fn _Unwind_Resume(exc: *mut _Unwind_Exception) -> ! {
_Unwind_SjLj_Resume(exc)
}

#[inline]
pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception) -> _Unwind_Reason_Code {
_Unwind_SjLj_RaiseException(exc)
}
} else {
extern "C" {
#[cfg_attr(stage0, unwind)]
#[cfg_attr(not(stage0), unwind(allowed))]
pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !;
pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
trace_argument: *mut c_void)
-> _Unwind_Reason_Code;
}
}
} // cfg_if!