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

A build dependency can force runtime features to be enabled in the final artifact #8592

Closed
mwcampbell opened this issue Aug 5, 2020 · 2 comments

Comments

@mwcampbell
Copy link

Minimal repro test case

In Cargo.toml, default_features is set to false for env_logger. But when you build the binary, env_logger has all features enabled anyway, as is evident from the binary size and the output of cargo-tree.

This is caused by the dependency on speech-dispatcher, which has an indirect build dependency on bindgen, which depends on env_logger with default features. This dependency forces env_logger in the final program to have default features even when built on a non-Linux platform (the dependency on speech-dispatcher is conditional). If you remove the dependency on speech-dispatcher, then the optional features of env_logger are disabled as expected.

Tested with Cargo 1.45.1 (f242df6 2020-07-22).

@ehuss
Copy link
Contributor

ehuss commented Aug 5, 2020

This should already be implemented with the -Zfeatures option (see docs and #7915).

@mwcampbell
Copy link
Author

Ah, sorry for the duplicate.

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

No branches or pull requests

2 participants