-
-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Cargo feature: prohibit_backtrace #256
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A cfg(all(…, not(feature = "prohibit_backtrace")))
feature gate is not the right implementation strategy for this. Cargo features are required to be additive; a Cargo feature is not supposed to remove something from the API. The Cargo feature added in this PR removes anyhow::Error::backtrace
when enabled. That means if one crate enables feature = "backtrace"
and uses the backtrace method, and a different crate enables feature = "prohibit_backtrace"
, each one will compile in isolation but will break when any project tries to introduce a transitive dependency on both those crates. This is harmful for the crates.io ecosystem because it breaks composability.
From reading your rationale in #239, it sounds like the PR is motivated by wanting to use anyhow
in projects that build with -Zbuild-std-features=panic_immediate_abort
. (Because anyone not using -Zbuild-std-features=panic_immediate_abort
is gonna get the backtrace infrastructure regardless of your PR, because the standard library uses it.) I think I would recommend that those projects just use a different library. I am not really interested in scrutinizing the rest of this library for code size (the vtables, the use of core::fmt) at the level that would make it truly good for code size constrained use cases.
Doesn't |
Libraries (or project components) can talk to each other in terms of |
Is Or is |
It will be unconditional on toolchain versions that have a stable backtrace implementation. |
Actually, I've got a few projects where disabling backtrace reduces the binary size two-fold. So perhaps that would be a reasonable avenue to pursue, if anyone is interested |
Resolves #239.