-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Describe the problem you are trying to solve
TiKV is a big workspace.
It has several features that are propagated throughout most of the workspace.
The "pattern" for maintaining these features in each crate is identical,
but humans are unable to maintain the pattern consistently across the workspace.
As a result, the build for any individual crate, under any particular combination of features,
has a good chance of being broken.
This is much exacerbated in the v2 resolver,
which TiKV uses,
because cargo now does feature resolution only based on the crates passed to -p
,
not based on the default binary (or whatever it did before - I don't know exactly).
So the build of multiple crates is usually broken under various combinations of features
even though the main binary or --all
may build correctly under those feature combinations.
Maintaining a working build for each crate under its various feature combinations
is basically impossible without some kind of custom test scripting.
The script I have put together to maintain correct builds for TiKV's crates takes hours to run,
so are infeasible to put under CI.
Here is an example of the pattern we are using to maintain two mutually-exclusive protobuf backends:
[features]
default = ["protobuf-codec", ...]
protobuf-codec = [
"batch-system/protobuf-codec",
...
]
prost-codec = [
"batch-system/prost-codec",
...
]
[dependencies]
batch-system = { path = "../batch-system", default-features = false }
Every crate has a default protobuf backend so that the crate compiles by default with -p
under the v2 resolver.
Each of those crates default features must be turned off by the crates that depend on them,
and re-activated by that crate's default features.
The list of crates that have protobuf features is huge, and each crate needs to follow this same pattern perfectly -
any mistakes and some crate in the workspace will stop compiling under some feature combination.
Describe the solution you'd like
Not sure!
My first thought was a static analysis that could understand this pattern across the workspace and tell me I've made a mistake. After reading https://github.com/rust-lang/rfcs/blob/master/text/2906-cargo-workspace-deduplicate.md via #6921 though I'm also wondering if deduplicating feature metadata in some way could help.
Notes
Here's the script I'm using to brute-force test every crate/feature combo:
https://github.com/tikv/tikv/blob/master/scripts/check-build-opts.py
cc @nrc