From 6e41885bd813a1628b6ca54058ab9595e9957c67 Mon Sep 17 00:00:00 2001 From: Timon Van Overveldt Date: Sat, 19 Mar 2016 14:53:40 -0700 Subject: Fix backtraces on ARM EHABI. Before this patch, our rust_eh_personality_catch routine would cut backtracing short at the __rust_try function, due to it not handling the _US_FORCE_UNWIND bit properly, which is passed by libunwind implementations on ARM EHABI. Examples of where the _US_FORCE_UNWIND bit is passed to the PR: - GCC's libunwind: https://github.com/gcc-mirror/gcc/blob/f1717362de1e56fe1ffab540289d7d0c6ed48b20/libgcc/unwind-arm-common.inc#L590 - LLVM's libunwind: https://github.com/llvm-mirror/libunwind/blob/61278584b5c84c422ff5da10f46c3235c54636c9/src/UnwindLevel1-gcc-ext.c#L153 --- src/libstd/sys/common/unwind/gcc.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/common/unwind/gcc.rs b/src/libstd/sys/common/unwind/gcc.rs index ff6a11951dc..da7a340af35 100644 --- a/src/libstd/sys/common/unwind/gcc.rs +++ b/src/libstd/sys/common/unwind/gcc.rs @@ -224,8 +224,13 @@ pub mod eabi { context: *mut uw::_Unwind_Context ) -> uw::_Unwind_Reason_Code { + // Backtraces on ARM will call the personality routine with + // state == _US_VIRTUAL_UNWIND_FRAME | _US_FORCE_UNWIND. In those cases + // we want to continue unwinding the stack, otherwise all our backtraces + // would end at __rust_try. if (state as c_int & uw::_US_ACTION_MASK as c_int) - == uw::_US_VIRTUAL_UNWIND_FRAME as c_int { // search phase + == uw::_US_VIRTUAL_UNWIND_FRAME as c_int + && (state as c_int & uw::_US_FORCE_UNWIND as c_int) == 0 { // search phase uw::_URC_HANDLER_FOUND // catch! } else { // cleanup phase -- cgit 1.4.1-3-g733a5 From 60c988ec176b9653bc1c3a6d6a738646d15a5ad6 Mon Sep 17 00:00:00 2001 From: Michael Neumann Date: Sat, 2 Apr 2016 19:06:16 +0200 Subject: Fix libstd on DragonFly Following changes: * birthtime does not exist on DragonFly * errno: __dfly_error is no more. Use #[thread_local] static errno. * clock_gettime expects a c_ulong (use a type alias) These changes are required to build DragonFly snapshots again. --- src/libstd/os/dragonfly/fs.rs | 10 ---------- src/libstd/sys/unix/os.rs | 12 +++++++++++- src/libstd/sys/unix/time.rs | 7 ++++++- 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/os/dragonfly/fs.rs b/src/libstd/os/dragonfly/fs.rs index eb09800a18c..db672e56435 100644 --- a/src/libstd/os/dragonfly/fs.rs +++ b/src/libstd/os/dragonfly/fs.rs @@ -63,10 +63,6 @@ pub trait MetadataExt { #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_ctime_nsec(&self) -> i64; #[stable(feature = "metadata_ext2", since = "1.8.0")] - fn st_birthtime(&self) -> i64; - #[stable(feature = "metadata_ext2", since = "1.8.0")] - fn st_birthtime_nsec(&self) -> i64; - #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_blksize(&self) -> u64; #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_blocks(&self) -> u64; @@ -129,12 +125,6 @@ impl MetadataExt for Metadata { fn st_ctime_nsec(&self) -> i64 { self.as_inner().as_inner().st_ctime_nsec as i64 } - fn st_birthtime(&self) -> i64 { - self.as_inner().as_inner().st_birthtime as i64 - } - fn st_birthtime_nsec(&self) -> i64 { - self.as_inner().as_inner().st_birthtime_nsec as i64 - } fn st_blksize(&self) -> u64 { self.as_inner().as_inner().st_blksize as u64 } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index eed62c9ecfd..94ebbd70ae8 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -36,6 +36,7 @@ const TMPBUF_SZ: usize = 128; static ENV_LOCK: StaticMutex = StaticMutex::new(); /// Returns the platform-specific value of errno +#[cfg(not(target_os = "dragonfly"))] pub fn errno() -> i32 { extern { #[cfg_attr(any(target_os = "linux", target_os = "emscripten"), @@ -47,7 +48,6 @@ pub fn errno() -> i32 { target_env = "newlib"), link_name = "__errno")] #[cfg_attr(target_os = "solaris", link_name = "___errno")] - #[cfg_attr(target_os = "dragonfly", link_name = "__dfly_error")] #[cfg_attr(any(target_os = "macos", target_os = "ios", target_os = "freebsd"), @@ -60,6 +60,16 @@ pub fn errno() -> i32 { } } +#[cfg(target_os = "dragonfly")] +pub fn errno() -> i32 { + extern { + #[thread_local] + static errno: c_int; + } + + errno as i32 +} + /// Gets a detailed string description for the given error number. pub fn error_string(errno: i32) -> String { extern { diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index 1444cf31e85..cc7abe25e35 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -303,8 +303,13 @@ mod inner { } } + #[cfg(not(target_os = "dragonfly"))] + pub type clock_t = libc::c_int; + #[cfg(target_os = "dragonfly")] + pub type clock_t = libc::c_ulong; + impl Timespec { - pub fn now(clock: libc::c_int) -> Timespec { + pub fn now(clock: clock_t) -> Timespec { let mut t = Timespec { t: libc::timespec { tv_sec: 0, -- cgit 1.4.1-3-g733a5