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 #55444

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 @@ -150,6 +150,11 @@ pub fn std_cargo(builder: &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" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be builder.build.build?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target.contains("linux") ?

as like:
...
766 !target.contains("freebsd") &&
767 !target.contains("windows") &&
768 !target.contains("apple") {
...

features.push_str(" sjlj_eh");
}

if builder.no_std(target) == Some(true) {
// for no-std targets we only compile a few no_std crates
cargo.arg("--features").arg("c mem")
Expand Down
3 changes: 3 additions & 0 deletions src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ wasm_syscall = []
# the environment for hooking up some thread-related information like the
# current thread id and accessing/getting the current thread's TCB
wasm-bindgen-threads = []

# setjmp / longjmp exception handling for i686-pc-windows-gnu
sjlj_eh = ["unwind/sjlj_eh"]
3 changes: 3 additions & 0 deletions src/libunwind/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ doc = false
core = { path = "../libcore" }
libc = { path = "../rustc/libc_shim" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }

[features]
sjlj_eh = []
40 changes: 31 additions & 9 deletions src/libunwind/libunwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn(unwind_code: _Unwind_Reaso
exception: *mut _Unwind_Exception);
extern "C" {
#[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 @@ -216,26 +215,49 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", 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" {
#[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" {
#[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" {
#[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!