Skip to content

Commit

Permalink
Remove libbacktrace implementation (#423)
Browse files Browse the repository at this point in the history
* Remove libbacktrace implementation

This commit removes the `backtrace-sys` crate and the libbacktrace
implementation of this crate. For quite some time now the
`gimli-symbolize` feture has been on-by-default. While `libbacktrace`
has been an option all relevant features should have been implemented in
`gimli-symbolize` by now.

The libbacktrace implementation has always been approached with wariness
where it may segfault or cause worse behavior when fed bad debug
information. Debug information is possible to change at runtime, so
libbacktrace has always been a risk for Rust binaries. Additionally
libbacktrace development was very quite for a very long time and our
patches upstream were generally met with silence. Development seems to
have picked back up upstream but with this crate now switched to gimli
I'm not too personally motivated to check to see if all our fixes have
landed. In general, though, libbacktrace upstream always worked best
with Linux and other platforms were more "best-effort". Additionally
gimli now has more features for supporting compressed and
split-debuginfo as well.

This commit comes about to reduce the maintenance burden on this crate.
Recent changes in rust-lang/rust have actually broken libbacktrace
testing. This appears fixed with sync'ing to the upstream repository of
libbacktrace, but it seems like now's the right time to go ahead and
remove the crate.

* Fix MSVC test

* Fix a macOS test
  • Loading branch information
alexcrichton authored May 5, 2021
1 parent fbb9fc1 commit 5fc4f79
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 835 deletions.
25 changes: 5 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,24 @@ jobs:
shell: bash
if: matrix.rust == 'stable-i686-msvc'

# Force packed debuginfo on macOS because libbacktrace only works with
# packed debuginfo. We specifically test later that both packed and
# unpacked work.
- run: |
echo CARGO_PROFILE_DEV_SPLIT_DEBUGINFO=packed >> $GITHUB_ENV
echo CARGO_PROFILE_TEST_SPLIT_DEBUGINFO=packed >> $GITHUB_ENV
if: matrix.os == 'macos-latest'
- run: cargo build --manifest-path crates/backtrace-sys/Cargo.toml
- run: cargo build
- run: cargo test
- run: cargo test --features "gimli-symbolize"
# run: cargo test --features "libbacktrace"
- run: cargo check --features "libbacktrace gimli-symbolize"
- run: cargo test --features "serialize-rustc"
- run: cargo test --features "serialize-serde"
- run: cargo test --features "verify-winapi"
- run: cargo test --features "cpp_demangle"
- run: cargo test --no-default-features
- run: cargo test --no-default-features --features "libbacktrace"
- run: cargo test --no-default-features --features "gimli-symbolize"
- run: cargo test --no-default-features --features "gimli-symbolize libbacktrace"
- run: cargo test --no-default-features --features "libbacktrace std"
- run: cargo test --no-default-features --features "gimli-symbolize std"
- run: cargo test --no-default-features --features "std"
- run: cargo test --manifest-path crates/cpp_smoke_test/Cargo.toml
# This test is specifically about packed debuginfo with `*.dSYM` files
- run: cargo test --manifest-path crates/macos_frames_test/Cargo.toml
- run: cargo test --features libbacktrace --manifest-path crates/without_debuginfo/Cargo.toml
env:
CARGO_PROFILE_DEV_SPLIT_DEBUGINFO: packed
CARGO_PROFILE_TEST_SPLIT_DEBUGINFO: packed
- run: cargo test --features gimli-symbolize --manifest-path crates/without_debuginfo/Cargo.toml
- run: cargo test --manifest-path crates/line-tables-only/Cargo.toml --features libbacktrace
- run: cargo test --manifest-path crates/line-tables-only/Cargo.toml --features gimli-symbolize

# Test that if debuginfo is compressed gimli still works
# Test debuginfo compression still works
- run: cargo test
if: contains(matrix.os, 'ubuntu')
env:
Expand Down
31 changes: 8 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ exclude = ['crates/without_debuginfo', 'crates/macos_frames_test', 'crates/line-
[dependencies]
cfg-if = "1.0"
rustc-demangle = "0.1.4"
backtrace-sys = { path = "crates/backtrace-sys", version = "0.1.35", optional = true, default_features = false }
libc = { version = "0.2.94", default-features = false }

# Optionally enable the ability to serialize a `Backtrace`, controlled through
Expand All @@ -36,11 +35,10 @@ cpp_demangle = { default-features = false, version = "0.3.0", optional = true }

# Optional dependencies enabled through the `gimli-symbolize` feature, do not
# use these features directly.
addr2line = { version = "0.15.1", optional = true, default-features = false }
miniz_oxide = { version = "0.4.0", optional = true, default-features = false }
addr2line = { version = "0.15.1", default-features = false }
miniz_oxide = { version = "0.4.0", default-features = false }
[dependencies.object]
version = "0.24"
optional = true
default-features = false
features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive']

Expand All @@ -58,26 +56,11 @@ libloading = "0.6"

[features]
# By default libstd support and gimli-symbolize is used to symbolize addresses.
default = ["std", "gimli-symbolize"]
default = ["std"]

# Include std support. This enables types like `Backtrace`.
std = []

#=======================================
# Methods of resolving symbols
#
# - gimli-symbolize: use the `gimli-rs/addr2line` crate to symbolicate
# addresses into file, line, and name using DWARF debug information.
# - libbacktrace: this feature activates the `backtrace-sys` dependency,
# building the libbacktrace library found in gcc repos.
#
# Note that MSVC unconditionally uses the dbghelp library to symbolize and won't
# be affected by feature selection here. Also note that it's highly unlikely you
# want to configure this. If you're having trouble getting backtraces it's
# likely best to open an issue.
gimli-symbolize = ["addr2line", "miniz_oxide", "object"]
libbacktrace = ["backtrace-sys/backtrace-sys"]

#=======================================
# Methods of serialization
#
Expand All @@ -91,11 +74,13 @@ serialize-serde = ["serde"]
# Only here for backwards compatibility purposes or for internal testing
# purposes. New code should use none of these features.
coresymbolication = []
dbghelp = []
dladdr = []
gimli-symbolize = []
kernel32 = []
unix-backtrace = []
libbacktrace = []
libunwind = []
dbghelp = []
unix-backtrace = []
verify-winapi = [
'winapi/dbghelp',
'winapi/handleapi',
Expand Down Expand Up @@ -132,7 +117,7 @@ edition = '2018'

[[test]]
name = "accuracy"
required-features = ["std", "gimli-symbolize"]
required-features = ["std"]
edition = '2018'

[[test]]
Expand Down
27 changes: 0 additions & 27 deletions crates/backtrace-sys/Cargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion crates/backtrace-sys/LICENSE-APACHE

This file was deleted.

1 change: 0 additions & 1 deletion crates/backtrace-sys/LICENSE-MIT

This file was deleted.

168 changes: 0 additions & 168 deletions crates/backtrace-sys/build.rs

This file was deleted.

4 changes: 0 additions & 4 deletions crates/backtrace-sys/src/android-api.c

This file was deleted.

58 changes: 0 additions & 58 deletions crates/backtrace-sys/src/lib.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/backtrace-sys/src/libbacktrace
Submodule libbacktrace deleted from 5c88e0
Loading

0 comments on commit 5fc4f79

Please sign in to comment.