summaryrefslogtreecommitdiffstats
path: root/library/unwind
diff options
context:
space:
mode:
Diffstat (limited to 'library/unwind')
-rw-r--r--library/unwind/Cargo.toml3
-rw-r--r--library/unwind/build.rs25
-rw-r--r--library/unwind/src/lib.rs11
-rw-r--r--library/unwind/src/libunwind.rs14
4 files changed, 13 insertions, 40 deletions
diff --git a/library/unwind/Cargo.toml b/library/unwind/Cargo.toml
index eab2717c4..9aa552ed8 100644
--- a/library/unwind/Cargo.toml
+++ b/library/unwind/Cargo.toml
@@ -19,9 +19,6 @@ libc = { version = "0.2.79", features = ['rustc-dep-of-std'], default-features =
compiler_builtins = "0.1.0"
cfg-if = "1.0"
-[build-dependencies]
-cc = "1.0.76"
-
[features]
# Only applies for Linux and Fuchsia targets
diff --git a/library/unwind/build.rs b/library/unwind/build.rs
deleted file mode 100644
index 5c3c02fb6..000000000
--- a/library/unwind/build.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-use std::env;
-
-fn main() {
- println!("cargo:rerun-if-changed=build.rs");
- println!("cargo:rerun-if-env-changed=CARGO_CFG_MIRI");
-
- if env::var_os("CARGO_CFG_MIRI").is_some() {
- // Miri doesn't need the linker flags or a libunwind build.
- return;
- }
-
- let target = env::var("TARGET").expect("TARGET was not set");
- if target.contains("android") {
- let build = cc::Build::new();
-
- // Since ndk r23 beta 3 `libgcc` was replaced with `libunwind` thus
- // check if we have `libunwind` available and if so use it. Otherwise
- // fall back to `libgcc` to support older ndk versions.
- let has_unwind = build.is_flag_supported("-lunwind").expect("Unable to invoke compiler");
-
- if has_unwind {
- println!("cargo:rustc-cfg=feature=\"system-llvm-libunwind\"");
- }
- }
-}
diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs
index df4f286a5..335bded71 100644
--- a/library/unwind/src/lib.rs
+++ b/library/unwind/src/lib.rs
@@ -4,6 +4,7 @@
#![feature(staged_api)]
#![feature(c_unwind)]
#![feature(cfg_target_abi)]
+#![feature(strict_provenance)]
#![cfg_attr(not(target_env = "msvc"), feature(libc))]
#![allow(internal_features)]
@@ -75,14 +76,10 @@ cfg_if::cfg_if! {
cfg_if::cfg_if! {
if #[cfg(feature = "llvm-libunwind")] {
compile_error!("`llvm-libunwind` is not supported for Android targets");
- } else if #[cfg(feature = "system-llvm-libunwind")] {
+ } else {
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {}
- } else {
- #[link(name = "gcc", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
- #[link(name = "gcc", cfg(not(target_feature = "crt-static")))]
- extern "C" {}
}
}
// Android's unwinding library depends on dl_iterate_phdr in `libdl`.
@@ -145,6 +142,10 @@ extern "C" {}
#[link(name = "gcc_s")]
extern "C" {}
+#[cfg(target_os = "aix")]
+#[link(name = "unwind")]
+extern "C" {}
+
#[cfg(target_os = "nto")]
#[link(name = "gcc_s")]
extern "C" {}
diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs
index a2bfa8e96..dba64aa74 100644
--- a/library/unwind/src/libunwind.rs
+++ b/library/unwind/src/libunwind.rs
@@ -1,6 +1,6 @@
#![allow(nonstandard_style)]
-use libc::{c_int, c_void, uintptr_t};
+use libc::{c_int, c_void};
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq)]
@@ -19,8 +19,8 @@ pub enum _Unwind_Reason_Code {
pub use _Unwind_Reason_Code::*;
pub type _Unwind_Exception_Class = u64;
-pub type _Unwind_Word = uintptr_t;
-pub type _Unwind_Ptr = uintptr_t;
+pub type _Unwind_Word = *const u8;
+pub type _Unwind_Ptr = *const u8;
pub type _Unwind_Trace_Fn =
extern "C" fn(ctx: *mut _Unwind_Context, arg: *mut c_void) -> _Unwind_Reason_Code;
@@ -214,7 +214,7 @@ if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", targe
// On Android or ARM/Linux, these are implemented as macros:
pub unsafe fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word {
- let mut val: _Unwind_Word = 0;
+ let mut val: _Unwind_Word = core::ptr::null();
_Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32,
&mut val as *mut _ as *mut c_void);
val
@@ -229,14 +229,14 @@ if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", targe
pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context)
-> _Unwind_Word {
let val = _Unwind_GetGR(ctx, UNWIND_IP_REG);
- (val & !1) as _Unwind_Word
+ val.map_addr(|v| v & !1)
}
pub unsafe fn _Unwind_SetIP(ctx: *mut _Unwind_Context,
value: _Unwind_Word) {
// Propagate thumb bit to instruction pointer
- let thumb_state = _Unwind_GetGR(ctx, UNWIND_IP_REG) & 1;
- let value = value | thumb_state;
+ let thumb_state = _Unwind_GetGR(ctx, UNWIND_IP_REG).addr() & 1;
+ let value = value.map_addr(|v| v | thumb_state);
_Unwind_SetGR(ctx, UNWIND_IP_REG, value);
}