Skip to content

Commit cc4f547

Browse files
Revert "std: Switch from libbacktrace to gimli"
This reverts commit 13db3cc.
1 parent 3c6003c commit cc4f547

File tree

13 files changed

+55
-108
lines changed

13 files changed

+55
-108
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,3 @@
4444
[submodule "src/tools/rust-analyzer"]
4545
path = src/tools/rust-analyzer
4646
url = https://github.com/rust-analyzer/rust-analyzer.git
47-
[submodule "src/backtrace"]
48-
path = src/backtrace
49-
url = https://github.com/rust-lang/backtrace-rs.git

Cargo.lock

+29-59
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,10 @@
11
# This file is automatically @generated by Cargo.
22
# It is not intended for manual editing.
33
[[package]]
4-
name = "addr2line"
5-
version = "0.13.0"
6-
source = "registry+https://github.com/rust-lang/crates.io-index"
7-
checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"
8-
dependencies = [
9-
"compiler_builtins",
10-
"gimli",
11-
"rustc-std-workspace-alloc",
12-
"rustc-std-workspace-core",
13-
]
14-
15-
[[package]]
16-
name = "adler"
17-
version = "0.2.2"
4+
name = "adler32"
5+
version = "1.0.3"
186
source = "registry+https://github.com/rust-lang/crates.io-index"
19-
checksum = "ccc9a9dd069569f212bc4330af9f17c4afb5e8ce185e83dbb14f1349dda18b10"
20-
dependencies = [
21-
"compiler_builtins",
22-
"rustc-std-workspace-core",
23-
]
7+
checksum = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
248

259
[[package]]
2610
name = "aho-corasick"
@@ -141,14 +125,28 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
141125

142126
[[package]]
143127
name = "backtrace"
144-
version = "0.3.50"
128+
version = "0.3.46"
129+
source = "registry+https://github.com/rust-lang/crates.io-index"
130+
checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e"
145131
dependencies = [
146-
"addr2line",
132+
"backtrace-sys",
147133
"cfg-if",
134+
"compiler_builtins",
148135
"libc",
149-
"miniz_oxide",
150-
"object",
151136
"rustc-demangle",
137+
"rustc-std-workspace-core",
138+
]
139+
140+
[[package]]
141+
name = "backtrace-sys"
142+
version = "0.1.37"
143+
source = "registry+https://github.com/rust-lang/crates.io-index"
144+
checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399"
145+
dependencies = [
146+
"cc",
147+
"compiler_builtins",
148+
"libc",
149+
"rustc-std-workspace-core",
152150
]
153151

154152
[[package]]
@@ -690,9 +688,9 @@ dependencies = [
690688

691689
[[package]]
692690
name = "crc32fast"
693-
version = "1.2.0"
691+
version = "1.1.2"
694692
source = "registry+https://github.com/rust-lang/crates.io-index"
695-
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
693+
checksum = "e91d5240c6975ef33aeb5f148f35275c25eda8e8a5f95abe421978b05b8bf192"
696694
dependencies = [
697695
"cfg-if",
698696
]
@@ -1025,9 +1023,9 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
10251023

10261024
[[package]]
10271025
name = "flate2"
1028-
version = "1.0.16"
1026+
version = "1.0.12"
10291027
source = "registry+https://github.com/rust-lang/crates.io-index"
1030-
checksum = "68c90b0fc46cf89d227cc78b40e494ff81287a92dd07631e5af0d06fe3cf885e"
1028+
checksum = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3"
10311029
dependencies = [
10321030
"cfg-if",
10331031
"crc32fast",
@@ -1161,17 +1159,6 @@ dependencies = [
11611159
"wasi",
11621160
]
11631161

1164-
[[package]]
1165-
name = "gimli"
1166-
version = "0.22.0"
1167-
source = "registry+https://github.com/rust-lang/crates.io-index"
1168-
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
1169-
dependencies = [
1170-
"compiler_builtins",
1171-
"rustc-std-workspace-alloc",
1172-
"rustc-std-workspace-core",
1173-
]
1174-
11751162
[[package]]
11761163
name = "git2"
11771164
version = "0.13.5"
@@ -1832,14 +1819,11 @@ dependencies = [
18321819

18331820
[[package]]
18341821
name = "miniz_oxide"
1835-
version = "0.4.0"
1822+
version = "0.3.5"
18361823
source = "registry+https://github.com/rust-lang/crates.io-index"
1837-
checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f"
1824+
checksum = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625"
18381825
dependencies = [
1839-
"adler",
1840-
"compiler_builtins",
1841-
"rustc-std-workspace-alloc",
1842-
"rustc-std-workspace-core",
1826+
"adler32",
18431827
]
18441828

18451829
[[package]]
@@ -1971,17 +1955,6 @@ dependencies = [
19711955
"libc",
19721956
]
19731957

1974-
[[package]]
1975-
name = "object"
1976-
version = "0.20.0"
1977-
source = "registry+https://github.com/rust-lang/crates.io-index"
1978-
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
1979-
dependencies = [
1980-
"compiler_builtins",
1981-
"rustc-std-workspace-alloc",
1982-
"rustc-std-workspace-core",
1983-
]
1984-
19851958
[[package]]
19861959
name = "once_cell"
19871960
version = "1.1.0"
@@ -4373,8 +4346,8 @@ dependencies = [
43734346
name = "std"
43744347
version = "0.0.0"
43754348
dependencies = [
4376-
"addr2line",
43774349
"alloc",
4350+
"backtrace",
43784351
"cfg-if",
43794352
"compiler_builtins",
43804353
"core",
@@ -4383,13 +4356,10 @@ dependencies = [
43834356
"hashbrown",
43844357
"hermit-abi",
43854358
"libc",
4386-
"miniz_oxide",
4387-
"object",
43884359
"panic_abort",
43894360
"panic_unwind",
43904361
"profiler_builtins",
43914362
"rand 0.7.3",
4392-
"rustc-demangle",
43934363
"unwind",
43944364
"wasi",
43954365
]

Cargo.toml

-6
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,5 @@ rustc-std-workspace-core = { path = 'src/tools/rustc-std-workspace-core' }
8080
rustc-std-workspace-alloc = { path = 'src/tools/rustc-std-workspace-alloc' }
8181
rustc-std-workspace-std = { path = 'src/tools/rustc-std-workspace-std' }
8282

83-
# This crate's integration with libstd is a bit wonky, so we use a submodule
84-
# instead of a crates.io dependency. Make sure everything else in the repo is
85-
# also using the submodule, however, so we can avoid duplicate copies of the
86-
# source code for this crate.
87-
backtrace = { path = "src/backtrace" }
88-
8983
[patch."https://github.com/rust-lang/rust-clippy"]
9084
clippy_lints = { path = "src/tools/clippy/clippy_lints" }

rustfmt.toml

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ ignore = [
3030
"src/tools/rust-analyzer",
3131
"src/tools/rust-installer",
3232
"src/tools/rustfmt",
33-
"src/backtrace",
3433

3534
# We do not format this file as it is externally sourced and auto-generated.
3635
"src/libstd/sys/cloudabi/abi/cloudabi.rs",

src/backtrace

-1
This file was deleted.

src/libstd/Cargo.toml

+9-15
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@ profiler_builtins = { path = "../libprofiler_builtins", optional = true }
2525
unwind = { path = "../libunwind" }
2626
hashbrown = { version = "0.6.2", default-features = false, features = ['rustc-dep-of-std'] }
2727

28-
# Dependencies of the `backtrace` crate
29-
addr2line = { version = "0.13.0", optional = true, default-features = false }
30-
rustc-demangle = { version = "0.1.4", optional = true }
31-
miniz_oxide = { version = "0.4.0", optional = true, default-features = false }
32-
[dependencies.object]
33-
version = "0.20"
34-
optional = true
35-
default-features = false
36-
features = ['read_core', 'elf', 'macho', 'pe']
28+
[dependencies.backtrace_rs]
29+
package = "backtrace"
30+
version = "0.3.46"
31+
default-features = false # without the libstd `backtrace` feature, stub out everything
32+
features = [ "rustc-dep-of-std" ] # enable build support for integrating into libstd
3733

3834
[dev-dependencies]
3935
rand = "0.7"
@@ -52,13 +48,11 @@ wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features =
5248

5349
[features]
5450
backtrace = [
55-
"gimli-symbolize",
56-
'addr2line/rustc-dep-of-std',
57-
'object/rustc-dep-of-std',
58-
'rustc-demangle/rustc-dep-of-std',
59-
'miniz_oxide/rustc-dep-of-std',
51+
"backtrace_rs/dbghelp", # backtrace/symbolize on MSVC
52+
"backtrace_rs/libbacktrace", # symbolize on most platforms
53+
"backtrace_rs/libunwind", # backtrace on most platforms
54+
"backtrace_rs/dladdr", # symbolize on platforms w/o libbacktrace
6055
]
61-
gimli-symbolize = []
6256

6357
panic-unwind = ["panic_unwind"]
6458
profiler = ["profiler_builtins"]

src/libstd/backtrace.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,15 @@
9191
// `Backtrace`, but that's a relatively small price to pay relative to capturing
9292
// a backtrace or actually symbolizing it.
9393

94-
use crate::backtrace_rs::{self, BytesOrWideString};
9594
use crate::env;
9695
use crate::ffi::c_void;
9796
use crate::fmt;
9897
use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst};
9998
use crate::sync::Mutex;
10099
use crate::sys_common::backtrace::{lock, output_filename};
101100
use crate::vec::Vec;
101+
use backtrace::BytesOrWideString;
102+
use backtrace_rs as backtrace;
102103

103104
/// A captured OS thread stack backtrace.
104105
///
@@ -149,7 +150,7 @@ struct BacktraceFrame {
149150
}
150151

151152
enum RawFrame {
152-
Actual(backtrace_rs::Frame),
153+
Actual(backtrace::Frame),
153154
#[cfg(test)]
154155
Fake,
155156
}
@@ -196,7 +197,7 @@ impl fmt::Debug for BacktraceSymbol {
196197
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
197198
write!(fmt, "{{ ")?;
198199

199-
if let Some(fn_name) = self.name.as_ref().map(|b| backtrace_rs::SymbolName::new(b)) {
200+
if let Some(fn_name) = self.name.as_ref().map(|b| backtrace::SymbolName::new(b)) {
200201
write!(fmt, "fn: \"{:#}\"", fn_name)?;
201202
} else {
202203
write!(fmt, "fn: <unknown>")?;
@@ -222,7 +223,7 @@ impl fmt::Debug for BytesOrWide {
222223
BytesOrWide::Bytes(w) => BytesOrWideString::Bytes(w),
223224
BytesOrWide::Wide(w) => BytesOrWideString::Wide(w),
224225
},
225-
backtrace_rs::PrintFmt::Short,
226+
backtrace::PrintFmt::Short,
226227
crate::env::current_dir().as_ref().ok(),
227228
)
228229
}
@@ -298,7 +299,7 @@ impl Backtrace {
298299
let mut frames = Vec::new();
299300
let mut actual_start = None;
300301
unsafe {
301-
backtrace_rs::trace_unsynchronized(|frame| {
302+
backtrace::trace_unsynchronized(|frame| {
302303
frames.push(BacktraceFrame {
303304
frame: RawFrame::Actual(frame.clone()),
304305
symbols: Vec::new(),
@@ -349,9 +350,9 @@ impl fmt::Display for Backtrace {
349350

350351
let full = fmt.alternate();
351352
let (frames, style) = if full {
352-
(&capture.frames[..], backtrace_rs::PrintFmt::Full)
353+
(&capture.frames[..], backtrace::PrintFmt::Full)
353354
} else {
354-
(&capture.frames[capture.actual_start..], backtrace_rs::PrintFmt::Short)
355+
(&capture.frames[capture.actual_start..], backtrace::PrintFmt::Short)
355356
};
356357

357358
// When printing paths we try to strip the cwd if it exists, otherwise
@@ -363,7 +364,7 @@ impl fmt::Display for Backtrace {
363364
output_filename(fmt, path, style, cwd.as_ref().ok())
364365
};
365366

366-
let mut f = backtrace_rs::BacktraceFmt::new(fmt, style, &mut print_path);
367+
let mut f = backtrace::BacktraceFmt::new(fmt, style, &mut print_path);
367368
f.add_context()?;
368369
for frame in frames {
369370
let mut f = f.frame();
@@ -373,7 +374,7 @@ impl fmt::Display for Backtrace {
373374
for symbol in frame.symbols.iter() {
374375
f.print_raw(
375376
frame.frame.ip(),
376-
symbol.name.as_ref().map(|b| backtrace_rs::SymbolName::new(b)),
377+
symbol.name.as_ref().map(|b| backtrace::SymbolName::new(b)),
377378
symbol.filename.as_ref().map(|b| match b {
378379
BytesOrWide::Bytes(w) => BytesOrWideString::Bytes(w),
379380
BytesOrWide::Wide(w) => BytesOrWideString::Wide(w),
@@ -408,7 +409,7 @@ impl Capture {
408409
RawFrame::Fake => unimplemented!(),
409410
};
410411
unsafe {
411-
backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| {
412+
backtrace::resolve_frame_unsynchronized(frame, |symbol| {
412413
symbols.push(BacktraceSymbol {
413414
name: symbol.name().map(|m| m.as_bytes().to_vec()),
414415
filename: symbol.filename_raw().map(|b| match b {

src/libstd/build.rs

-1
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,4 @@ fn main() {
8787
println!("cargo:rustc-cfg=feature=\"restricted-std\"");
8888
}
8989
println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap());
90-
println!("cargo:rustc-cfg=backtrace_in_libstd");
9190
}

src/libstd/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,6 @@ mod panicking;
511511
// compiler
512512
pub mod rt;
513513

514-
#[path = "../backtrace/src/lib.rs"]
515-
#[allow(dead_code, unused_attributes)]
516-
mod backtrace_rs;
517-
518514
// Pull in the `std_detect` crate directly into libstd. The contents of
519515
// `std_detect` are in a different repository: rust-lang/stdarch.
520516
//

src/libstd/panicking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fn default_hook(info: &PanicInfo<'_>) {
171171
// If this is a double panic, make sure that we print a backtrace
172172
// for this panic. Otherwise only print it if logging is enabled.
173173
let backtrace_env = if panic_count::get() >= 2 {
174-
RustBacktrace::Print(crate::backtrace_rs::PrintFmt::Full)
174+
RustBacktrace::Print(backtrace_rs::PrintFmt::Full)
175175
} else {
176176
backtrace::rust_backtrace_env()
177177
};

src/libstd/sys_common/backtrace.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt};
21
use crate::borrow::Cow;
32
/// Common code for printing the backtrace in the same way across the different
43
/// supported platforms.
@@ -10,6 +9,8 @@ use crate::path::{self, Path, PathBuf};
109
use crate::sync::atomic::{self, Ordering};
1110
use crate::sys::mutex::Mutex;
1211

12+
use backtrace_rs::{BacktraceFmt, BytesOrWideString, PrintFmt};
13+
1314
/// Max number of frames to print.
1415
const MAX_NB_FRAMES: usize = 100;
1516

0 commit comments

Comments
 (0)