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 stopped including optional dependencies into build scripts #5475

Closed
hdevalence opened this issue May 3, 2018 · 1 comment · Fixed by #5480
Closed

Cargo stopped including optional dependencies into build scripts #5475

hdevalence opened this issue May 3, 2018 · 1 comment · Fixed by #5480

Comments

@hdevalence
Copy link

With rust-toolchain = nightly-2018-04-30, it's possible to have an optional dependency specified in Cargo.toml as, say,

[build-dependencies]
...
serde = { version = "1.0", optional = true }
...

and in build.rs as, say,

#[cfg(feature = "serde")]
extern crate serde;

Then cargo invokes rustc with

rustc --crate-name build_script_build build.rs ... --cfg 'feature="serde"' ... --extern serde=...

However, with rust-toolchain = nightly-2018-05-03, cargo invokes rustc without the --extern serde flag:

rustc --crate-name build_script_build build.rs ... --cfg 'feature="serde"' ... 

This causes a build error, since the crate can't be found any more.

@alexcrichton
Copy link
Member

Aha a very subtle bug caused by #5415! I believe this should be fixed by #5480, sorry for the breakage!

alexcrichton added a commit to alexcrichton/cargo that referenced this issue May 4, 2018
This commit fixes an issue where an optional dependency was listed multiple
times in a manifest (multiple sections). This regression was introduced by rust-lang#5415
and happened because in the resolver we didn't record a `Dependency` as it was
accidentally deduplicated too soon.

The fix here was to ensure that all `Dependency` annotations make their way into
`Resolve` now that we rely on the listed `Dependency` values for correctness.

Closes rust-lang#5475
bors added a commit that referenced this issue May 4, 2018
Fix optional deps in multiple sections

This commit fixes an issue where an optional dependency was listed multiple
times in a manifest (multiple sections). This regression was introduced by #5415
and happened because in the resolver we didn't record a `Dependency` as it was
accidentally deduplicated too soon.

The fix here was to ensure that all `Dependency` annotations make their way into
`Resolve` now that we rely on the listed `Dependency` values for correctness.

Closes #5475
@bors bors closed this as completed in #5480 May 4, 2018
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

Successfully merging a pull request may close this issue.

2 participants