about summary refs log tree commit diff
path: root/src/libstd/sys_common/backtrace.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-12-14 16:47:18 -0800
committerAlex Crichton <alex@alexcrichton.com>2018-12-24 08:32:57 -0800
commit8d500572fa8f4110033fa3bc5e925831f6bbd18e (patch)
treec21fb3a40f8f8a4f57879ed39a9ce5ddc1f66fbd /src/libstd/sys_common/backtrace.rs
parent50f3d6eccb85a24a02b7c1daf5e242768dddf3b5 (diff)
downloadrust-8d500572fa8f4110033fa3bc5e925831f6bbd18e.tar.gz
rust-8d500572fa8f4110033fa3bc5e925831f6bbd18e.zip
std: Use backtrace-sys from crates.io
This commit switches the standard library to using the `backtrace-sys`
crate from crates.io instead of duplicating the logic here in the Rust
repositor with the `backtrace-sys`'s crate's logic.

Eventually this will hopefully be a good step towards using the
`backtrace` crate directly from crates.io itself, but we're not quite
there yet! Hopefully this is a small incremental first step we can take.
Diffstat (limited to 'src/libstd/sys_common/backtrace.rs')
-rw-r--r--src/libstd/sys_common/backtrace.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libstd/sys_common/backtrace.rs b/src/libstd/sys_common/backtrace.rs
index e44113f76f4..08cd7b05e07 100644
--- a/src/libstd/sys_common/backtrace.rs
+++ b/src/libstd/sys_common/backtrace.rs
@@ -53,6 +53,14 @@ const MAX_NB_FRAMES: usize = 100;
 pub fn print(w: &mut dyn Write, format: PrintFormat) -> io::Result<()> {
     static LOCK: Mutex = Mutex::new();
 
+    // There are issues currently linking libbacktrace into tests, and in
+    // general during libstd's own unit tests we're not testing this path. In
+    // test mode immediately return here to optimize away any references to the
+    // libbacktrace symbols
+    if cfg!(test) {
+        return Ok(())
+    }
+
     // Use a lock to prevent mixed output in multithreading context.
     // Some platforms also requires it, like `SymFromAddr` on Windows.
     unsafe {