-
Notifications
You must be signed in to change notification settings - Fork 412
Use RUSTFLAGS instead of feature to gate benching #1882
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
Conversation
CI is mad but generally looks good, thanks. |
2197d9b
to
174d0ba
Compare
Looks like I've botched some of the attributes up, I'll go back over the changes later with fresh eyes. |
Concept ACK |
1a8ff43
to
2c6c15b
Compare
@@ -5505,7 +5505,7 @@ pub(crate) mod bench_utils { | |||
} | |||
} | |||
|
|||
#[cfg(all(test, feature = "_bench_unstable", not(feature = "no-std")))] | |||
#[cfg(all(bench, not(features = "no-std")))] | |||
mod benches { |
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.
The original is incorrect is it not? These benches will never be run because we run benches with "std" enabled since it is enabled by default (RUSTC_BOOTSTRAP=1 RUSTFLAGS='--cfg=bench' cargo bench
).
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.
oh I wrote this comment on an old version of the PR, now it uses #[cfg(bench)]
.
2c6c15b
to
2db80b6
Compare
Drats this can't go in until I'll put this on ice until then. |
2db80b6
to
aeab7a7
Compare
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #1882 +/- ##
==========================================
+ Coverage 90.90% 90.93% +0.02%
==========================================
Files 104 91 -13
Lines 52838 50519 -2319
Branches 52838 50519 -2319
==========================================
- Hits 48032 45937 -2095
+ Misses 4806 4582 -224
☔ View full report in Codecov by Sentry. |
Currently we use the `"_bench_unstable"` feature to gate benching code. This results in features not being additive for stable toolchains i.e., one cannot currently run `cargo +stable check --all-features`. Although this method of gating bench code is widely proposed as a good solution online there is another solution that keeps all features additive. Guard the bench code with `#[cfg(bench)]` and when running benches use `RUSTFLAGS='--cfg=bench'` to turn on `bench`.
aeab7a7
to
e2156c0
Compare
Rebased and added docs in |
Oops I forgot about this PR. Is probably superseded by #2235. |
Cool, maybe we should be doing that in rust-bitcoin land as well. |
Currently we use the
"_bench_unstable"
feature to gate benching code. This results in features not being additive for stable toolchains i.e., one cannot currently runcargo +stable check --all-features
(error below). Although this method of gating bench code is widely proposed as a good solution online there is another solution that keeps all features additive.Guard the bench code with
#[cfg(bench)]
and when running benches useRUSTFLAGS='--cfg=bench'
to turn onbench
.