Skip to content

Commit

Permalink
Optimize mutually exclusive features (#130)
Browse files Browse the repository at this point in the history
* Optimize mutually exclusive features

Signed-off-by: mornyx <mornyx.z@gmail.com>

* Update CHANGELOG.md

Signed-off-by: mornyx <mornyx.z@gmail.com>

* Remove empty line

Signed-off-by: mornyx <mornyx.z@gmail.com>
  • Loading branch information
mornyx authored May 24, 2022
1 parent fb65ca7 commit 3fed55a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- Remove `backtrace-rs` feature, as the default choice when not specified (#130)

## [0.9.1] - 2022-05-19

### Fixed
Expand Down
11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ documentation = "https://docs.rs/pprof/"
readme = "README.md"

[features]
default = ["cpp", "backtrace-rs"]
default = ["cpp"]
cpp = ["symbolic-demangle/cpp"]
flamegraph = ["inferno"]
frame-pointer = []

# A private feature to indicate either prost-codec or protobuf-codec is enabled.
_protobuf = []
prost-codec = ["prost", "prost-derive", "prost-build", "_protobuf"]
protobuf-codec = ["protobuf", "protobuf-codegen-pure", "_protobuf"]

backtrace-rs = ["backtrace"]
frame-pointer = ["backtrace"]

cpp = ["symbolic-demangle/cpp"]

[dependencies]
backtrace = { version = "0.3", optional = true }
backtrace = { version = "0.3" }
once_cell = "1.9"
libc = "^0.2.66"
log = "0.4"
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ FRAME: backtrace::backtrace::trace::h3e91a3123a3049a5 -> FRAME: pprof::profiler:
- `flamegraph` enables the flamegraph report format.
- `prost-codec` enables the pprof protobuf report format through `prost`.
- `protobuf-codec` enables the pprof protobuf report format through `protobuf` crate.
- `backtrace-rs` unwind the backtrace through `backtrace-rs` (which calls the `Unwind_Backtrace`).
- `frame-pointer` gets the backtrace through frame pointer. **only available for nightly**

## Flamegraph
Expand Down
10 changes: 8 additions & 2 deletions src/backtrace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ pub trait Trace {
Self: Sized;
}

#[cfg(feature = "backtrace-rs")]
#[cfg(not(all(
any(target_arch = "x86_64", target_arch = "aarch64"),
feature = "frame-pointer"
)))]
mod backtrace_rs;
#[cfg(feature = "backtrace-rs")]
#[cfg(not(all(
any(target_arch = "x86_64", target_arch = "aarch64"),
feature = "frame-pointer"
)))]
pub use backtrace_rs::Trace as TraceImpl;

#[cfg(all(
Expand Down

0 comments on commit 3fed55a

Please sign in to comment.