Skip to content
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

Cannot opt out of backtrace feature on nigthly. #239

Closed
vi opened this issue May 10, 2022 · 2 comments
Closed

Cannot opt out of backtrace feature on nigthly. #239

vi opened this issue May 10, 2022 · 2 comments

Comments

@vi
Copy link

vi commented May 10, 2022

Anyhow seems to have include two backtrace strategies: one for stable and one for nightly. The former is managed by default-off Cargo feature "backtrace", but the latter is turned on automatically on nightly regardless of Cargo feature.

This may add more code to the executable, making anyhow significantly more bloated compared to Box<dyn Error+Send+Sync> in some scenarios. I see 92 additional kilobytes in .text section according to cargo bloat, which disappear when I manually edit out all Anyhow's code sections with #[cfg(backtrace)].

I think both backtracing modes should be adjustable by Cargo features. Anyhow may check #[cfg(backtrace)] only once, e.g. to compile_error! if Cargo feature for nightly-style backtraces is enabled on non-nightly. At the very least a negative Cargo feature like prohibit_backtraces should be provided to support minified builds. If user builds with -Zbuild-std-features=panic_immediate_abort to save kilobytes then backtraces are likely not welcome as well, even if natively supported by the compiler.

Related: #230.

vi added a commit to vi/anyhow that referenced this issue Aug 11, 2022
@dtolnay
Copy link
Owner

dtolnay commented Aug 13, 2022

Closing per #256 (review). Thanks anyway for the PR though!

@dtolnay dtolnay closed this as completed Aug 13, 2022
@vi
Copy link
Author

vi commented Aug 13, 2022

Why is this issue closed as "completed" instead of as "not planned"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants