fix(pprof): gate framehop-unwinder to supported targets

framehop-unwinder is only available on x86_64/aarch64 Linux/macOS.
Enabling it unconditionally for all Unix targets breaks the build on
riscv64 and other platforms: pprof disables its backtrace-rs fallback
when framehop-unwinder is set, but the framehop module is not compiled
on unsupported targets, leaving no TraceImpl implementation.

Split the pprof dependency: the base target.'cfg(unix)' block carries
the common features (flamegraph, prost-codec, protobuf), and a separate
target block adds framehop-unwinder only on supported targets.
Cargo unions features from both blocks on matching targets, so x86_64
and aarch64 Linux/macOS get the full feature set while other Unix
targets fall back to the default backtrace-rs implementation.

Addresses review comment discussion_r3987313632.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
This commit is contained in:
Lei, HUANG
2026-09-11 16:55:51 +08:00
parent d5a3777ad7
commit 9422806277
+6 -1
View File
@@ -13,10 +13,15 @@ tokio.workspace = true
[target.'cfg(unix)'.dependencies]
pprof = { version = "0.15", features = [
"flamegraph",
"framehop-unwinder",
"prost-codec",
"protobuf",
] }
# framehop-unwinder is only available on x86_64/aarch64 Linux/macOS.
# Enabling it on other targets (e.g. riscv64) would disable the
# backtrace-rs fallback without providing a TraceImpl, breaking the build.
[target.'cfg(all(unix, any(target_arch = "x86_64", target_arch = "aarch64"), any(target_os = "linux", target_os = "macos")))'.dependencies]
pprof = { version = "0.15", features = ["framehop-unwinder"] }
[lints]
workspace = true