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

Figure out why cargo build --all-targets --no-default-features doesn't always detect broken feature dependencies #1640

Open
daira opened this issue Dec 7, 2024 · 2 comments
Labels

Comments

@daira
Copy link
Contributor

daira commented Dec 7, 2024

#1577 (comment)

To avoid an unused input warning, SighashType should be imported only if "transparent-inputs" is enabled, i.e. move it to line 22.

(For some reason this only shows up when building zcash_primitives on its own without "transparent-inputs", not when building the whole workspace with --no-default-features. I don't know why. But this has implications for our CI testing for broken feature dependencies, so I'll file an issue.)

@daira
Copy link
Contributor Author

daira commented Dec 7, 2024

My theory is that cargo tries too hard to avoid building a given crate X more than once in any given build, even if it's a top-level build. So if another crate Y in the workspace depends on X with some features explicitly enabled, then it will not also be built without those features in the top-level build. This is not what we want, because X can also be used independently of Y.

If that's correct then I think the only way to work around it would be to have a CI task that tries to build each crate independently with a representative set of feature combinations. This isn't as inefficient as it sounds because this problem doesn't seem to affect the correctness of the caching, i.e. the builds of a given crate with duplicated feature combinations will all be quick. Also, that CI task need not be a blocker for merges, so it doesn't matter so much if it takes a while.

@conradoplg
Copy link

I've got bitten by this countless times - cargo does feature unification across workspace crates, so if any crate enables that feature, it will be enabled when building all crates. You will need to build crates separately to test this.

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

No branches or pull requests

2 participants