Skip to content

Cargo stopped including optional dependencies into build scripts #5475

Closed
@hdevalence

Description

@hdevalence

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions