summaryrefslogtreecommitdiffstats
path: root/library/backtrace/crates/as-if-std
diff options
context:
space:
mode:
Diffstat (limited to 'library/backtrace/crates/as-if-std')
-rw-r--r--library/backtrace/crates/as-if-std/Cargo.toml29
-rw-r--r--library/backtrace/crates/as-if-std/build.rs3
-rw-r--r--library/backtrace/crates/as-if-std/src/lib.rs21
3 files changed, 53 insertions, 0 deletions
diff --git a/library/backtrace/crates/as-if-std/Cargo.toml b/library/backtrace/crates/as-if-std/Cargo.toml
new file mode 100644
index 000000000..c763227f2
--- /dev/null
+++ b/library/backtrace/crates/as-if-std/Cargo.toml
@@ -0,0 +1,29 @@
+[package]
+name = "as-if-std"
+version = "0.1.0"
+authors = ["Alex Crichton <alex@alexcrichton.com>"]
+edition = "2018"
+publish = false
+
+[lib]
+test = false
+doc = false
+doctest = false
+bench = false
+
+[dependencies]
+cfg-if = "1.0"
+rustc-demangle = "0.1.4"
+libc = { version = "0.2.45", default-features = false }
+addr2line = { version = "0.16.0", default-features = false, optional = true }
+miniz_oxide = { version = "0.4.0", default-features = false }
+
+[dependencies.object]
+version = "0.28"
+default-features = false
+optional = true
+features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive']
+
+[features]
+default = ['backtrace']
+backtrace = ['addr2line', 'object']
diff --git a/library/backtrace/crates/as-if-std/build.rs b/library/backtrace/crates/as-if-std/build.rs
new file mode 100644
index 000000000..7018b1017
--- /dev/null
+++ b/library/backtrace/crates/as-if-std/build.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("cargo:rustc-cfg=backtrace_in_libstd");
+}
diff --git a/library/backtrace/crates/as-if-std/src/lib.rs b/library/backtrace/crates/as-if-std/src/lib.rs
new file mode 100644
index 000000000..c0f49b77d
--- /dev/null
+++ b/library/backtrace/crates/as-if-std/src/lib.rs
@@ -0,0 +1,21 @@
+// A crate which builds the `backtrace` crate as-if it's included as a
+// submodule into the standard library. We try to set this crate up similarly
+// to the standard library itself to minimize the likelihood of issues when
+// updating the `backtrace` crate.
+
+#![no_std]
+
+extern crate alloc;
+
+// We want to `pub use std::*` in the root but we don't want `std` available in
+// the root namespace, so do this in a funky inner module.
+mod __internal {
+ extern crate std;
+ pub use std::*;
+}
+
+pub use __internal::*;
+
+// This is the magical part which we hope works.
+#[path = "../../../src/lib.rs"]
+mod the_backtrace_crate;