Skip to content

Cargo.toml directive to declare default optimization level when built as a build-dependency #7940

@joshtriplett

Description

@joshtriplett

(Filing this issue based on discussion in the Cargo team meeting today.)

Describe the problem you are trying to solve
I like the build-time improvements provided by explicitly not optimizing build-dependencies. I'd like the ecosystem to be able to gain those improvements by default with less manual declaration.

Describe the solution you'd like
I would propose an option in the Cargo.toml of a crate that can either say "don't bother optimizing me if I'm just a build-dependency, I probably won't benefit from it" or "please optimize me even if I'm just a build-dependency" (which would optimize it even in debug mode). The former would work well for proc-macro crates that just do a simple derive, where the time spent optimizing would never get paid off when run at build time. The latter would work well for certain types of "generator" crates like phf, where optimization is incredibly important for the performance of build-time table generation, and optimization doesn't take long.

We could then use that as the default optimization level when a crate is built as a build-dependency, with higher-level crates able to explicitly override those defaults and declare how they want their build-dependencies optimized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-profilesArea: profilesC-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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions