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

Cargo pulls in features only defined in [dev-dependencies] for normal builds #2596

Closed
sfackler opened this issue Apr 20, 2016 · 3 comments
Closed

Comments

@sfackler
Copy link
Member

If you have a crate that defines the same crate as both a dependency and dev-dependency, but with some features only enabled as a dev-dependency, I would expect a "cargo build" to not include those features. That does not seem to be the case, however.

Take rust-hyper-socks as an example: https://github.com/sfackler/rust-hyper-socks/blob/980099094b0fd7ba4a2d1a7df4be3e1785479c6d/Cargo.toml

$ cargo build
   Compiling lazy_static v0.1.16
   Compiling rustc-serialize v0.3.19
   Compiling httparse v1.1.2
   Compiling gcc v0.3.26
   Compiling typeable v0.1.2
   Compiling winapi v0.2.6
   Compiling bitflags v0.4.0
   Compiling winapi-build v0.1.1
   Compiling pkg-config v0.3.8
   Compiling byteorder v0.4.2
   Compiling log v0.3.6
   Compiling traitobject v0.0.1
   Compiling unicode-normalization v0.1.2
   Compiling mime v0.2.0
   Compiling hpack v0.2.0
   Compiling socks v0.2.0
   Compiling libc v0.2.10
   Compiling openssl-sys v0.7.9
   Compiling kernel32-sys v0.2.1
   Compiling semver v0.1.20
   Compiling openssl v0.7.9
   Compiling openssl-sys-extras v0.7.9
   Compiling solicit v0.4.4
   Compiling language-tags v0.2.2
   Compiling rand v0.3.14
   Compiling num_cpus v0.2.11
   Compiling time v0.1.35
   Compiling rustc_version v0.1.7
   Compiling matches v0.1.2
   Compiling unicode-bidi v0.2.3
   Compiling unicase v1.4.0
   Compiling uuid v0.2.0
   Compiling url v0.5.8
   Compiling cookie v0.2.2
   Compiling hyper v0.8.1
   Compiling hyper-socks v0.2.0 (file:///Volumes/git/rust/rust-hyper-socks)

Note the inclusion of the various openssl crates in there.

If the crate is depended on transitively, the right thing appears to happen, and those features are not activated.

@alexcrichton
Copy link
Member

Actually I believe this is a dupe of #1796, so I'm going to close in favor of that.

The gist of this is that it is likely not fixable, and even if fixable it wouldn't be what you want. Because of the unioning property of features it would meant that cargo build followed by cargo test would always rebuild the main library (as hyper changed).

@sfackler
Copy link
Member Author

I dunno, recompiling for tests is exactly the behavior I'd expect with a dependency setup like that.

@jethrogb
Copy link
Contributor

Right. See also my rationale in #1796 (comment)

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

3 participants