Skip to content

Annotate "Compiling X" status lines with active features #16942

@pnkfelix

Description

@pnkfelix

Problem

Developers of systems that invoke cargo build multiple times are sometimes surprised to see the same dependencies show up repeatedly. "Why isn't Rust caching these" I have heard many times.

There are many reasons this can happen, but one is especially insidious: different feature-sets for the given dependency, which leads to the previous build artifact not being reusable for the current context.

Proposed Solution

My suggestion is that we actually make Compiling X include (in addition to its current output), the feature set that it is being built with.

Once you know that this is the problem, you can investigate it via cargo tree and such.

By including that information, people will be able to more immediately see why a crate is being rebuilt.

Concretely, today:

      Compiling serde_json v1.0.149
[...]
      Compiling serde_json v1.0.149

With this proposal:

      Compiling serde_json v1.0.149  [features: default, preserve_order, std]
[...]
      Compiling serde_json v1.0.149  [features: arbitrary_precision, default, std]

Even just having it as an opt-in via an env var would be enough to allow quick investigations. E.g. something like CARGO_TERM_COMPILING_FEATURE_SET, analogous to flags like CARGO_TERM_PROGRESS_WHEN. (I suggest an env var specifically because I would like to have access to this in wrappers around cargo rather than be forced to achieve it via flags like --message-format.)

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-console-outputArea: Terminal output, colors, progress bar, etc.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Z-build-analysisNightly: build-analysis

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions