diff --git a/src/librustc_target/spec/i686_unknown_windows_gnu.rs b/src/librustc_target/spec/i686_unknown_windows_gnu.rs new file mode 100644 index 0000000000000..dfe12626af21b --- /dev/null +++ b/src/librustc_target/spec/i686_unknown_windows_gnu.rs @@ -0,0 +1,27 @@ +use crate::spec::{LinkerFlavor, Target, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::windows_base::opts(); + base.cpu = "pentium4".to_string(); + base.max_atomic_width = Some(64); + base.eliminate_frame_pointer = false; // Required for backtraces + + // Mark all dynamic libraries and executables as compatible with the larger 4GiB address + // space available to x86 Windows binaries on x86_64. + base.pre_link_args + .get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--large-address-aware".to_string()); + + Ok(Target { + llvm_target: "i686-unknown-windows-gnu".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32".to_string(), + arch: "x86".to_string(), + target_os: "windows".to_string(), + target_env: "gnu".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 3054ffabb4f1f..3f763cc70eb70 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -433,6 +433,7 @@ supported_targets! { ("x86_64-pc-windows-gnu", x86_64_pc_windows_gnu), ("i686-pc-windows-gnu", i686_pc_windows_gnu), + ("i686-unknown-windows-gnu", i686_unknown_windows_gnu), ("aarch64-pc-windows-msvc", aarch64_pc_windows_msvc), ("x86_64-pc-windows-msvc", x86_64_pc_windows_msvc), diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index 30897970fa220..00f9115107359 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -72,7 +72,6 @@ pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn(unwind_code: _Unwind_Reaso link(name = "unwind", kind = "static"))] 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; @@ -212,32 +211,55 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm } } // cfg_if! -cfg_if::cfg_if! { -if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] { - // Not 32-bit iOS +pub mod dwarf2 { + use crate::{_Unwind_Exception, _Unwind_Reason_Code, _Unwind_Trace_Fn}; + use libc::c_void; #[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static"))] 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; + pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn, trace_argument: *mut c_void) + -> _Unwind_Reason_Code; } -} else { - // 32-bit iOS uses SjLj and does not provide _Unwind_Backtrace() +} + +pub mod sjlj { + use crate::{_Unwind_Exception, _Unwind_Reason_Code}; #[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static"))] extern "C" { #[unwind(allowed)] - pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code; + pub fn _Unwind_Sjlj_Resume(exception: *mut _Unwind_Exception) -> !; + pub fn _Unwind_Sjlj_RaiseException(exception: *mut _Unwind_Exception) + -> _Unwind_Reason_Code; + } + #[inline] + pub unsafe fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> ! { + _Unwind_Sjlj_Resume(exception) } - #[inline] - pub unsafe fn _Unwind_RaiseException(exc: *mut _Unwind_Exception) -> _Unwind_Reason_Code { - _Unwind_SjLj_RaiseException(exc) + pub unsafe fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code { + _Unwind_Sjlj_RaiseException(exception) } } + +cfg_if::cfg_if! { + // 32-bit iOS + if #[cfg(all(target_os = "ios", target_arch = "arm"))] { + pub use sjlj::*; + } + // FIXME: i686-unknown-windows-gnu target with sjlj + else if #[cfg(all(target_vendor = "unknown", + target_os = "windows", + target_arch = "x86", + target_env = "gnu"))] { + pub use sjlj::*; + } + else { + pub use dwarf2::*; + } } // cfg_if!