Skip to content

feat(unstable): Added -Zbuild-dir-new-layout unstable feature #15848

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

Merged
merged 2 commits into from
Aug 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ unstable_cli_options!(
binary_dep_depinfo: bool = ("Track changes to dependency artifacts"),
bindeps: bool = ("Allow Cargo packages to depend on bin, cdylib, and staticlib crates, and use the artifacts built by those crates"),
build_analysis: bool = ("Record and persist build metrics across runs, with commands to query past builds."),
build_dir_new_layout: bool = ("Use the new build-dir filesystem layout"),
#[serde(deserialize_with = "deserialize_comma_separated_list")]
build_std: Option<Vec<String>> = ("Enable Cargo to compile the standard library itself as part of a crate graph compilation"),
#[serde(deserialize_with = "deserialize_comma_separated_list")]
Expand Down Expand Up @@ -1365,6 +1366,7 @@ impl CliUnstable {
"binary-dep-depinfo" => self.binary_dep_depinfo = parse_empty(k, v)?,
"bindeps" => self.bindeps = parse_empty(k, v)?,
"build-analysis" => self.build_analysis = parse_empty(k, v)?,
"build-dir-new-layout" => self.build_dir_new_layout = parse_empty(k, v)?,
"build-std" => self.build_std = Some(parse_list(v)),
"build-std-features" => self.build_std_features = Some(parse_list(v)),
"cargo-lints" => self.cargo_lints = parse_empty(k, v)?,
Expand Down
9 changes: 9 additions & 0 deletions src/doc/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Each new feature described below should explain how to use it.
* [feature-unification](#feature-unification) --- Enable new feature unification modes in workspaces
* Output behavior
* [artifact-dir](#artifact-dir) --- Adds a directory where artifacts are copied to.
* [build-dir-new-layout](#build-dir-new-layout) --- Enables the new build-dir filesystem layout
* [Different binary name](#different-binary-name) --- Assign a name to the built binary that is separate from the crate name.
* [root-dir](#root-dir) --- Controls the root directory relative to which paths are printed
* Compile behavior
Expand Down Expand Up @@ -1939,6 +1940,14 @@ The `-Zbuild-analysis` feature records and persists detailed build metrics
enabled = true
```

## build-dir-new-layout

* Tracking Issue: [#15010](https://github.com/rust-lang/cargo/issues/15010)

Enables the new build-dir filesystem layout.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new layout won't be that useful enough to stabilize on its own, right? Anyway the layout changing itself could lead to unexpected breakages to workflow making assumption of the layout, so agree it is better having its own unstable flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new layout won't be that useful enough to stabilize on its own, right? Anyway the layout changing itself could lead to unexpected breakages to workflow making assumption of the layout, so agree it is better having its own unstable flag.

Yeah it seems unlikely that this alone would give users a tangible benefit, but I think there is value in allowing tool authors to test their cargo integration with the new layout.


Part of me is wondering if it would be a good idea to bundle the layout changes with moving the default build-dir location to inside of CARGO_HOME (or perhaps using XDG config #1734 ?)
My thought is that it might be easier to bundle both of these changes together to avoid churn in the default build-dir behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not? I feel like they are different kinds of churn. And XDG is always a hot topic that I am afraid of touching 😆.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that these are independent changes.

My hope was to have fine grained locking be the feature to push this to being stabilized.

This layout change unblocks work towards caching and locking improvements.


# Stabilized and removed features

## Compile progress
Expand Down
84 changes: 43 additions & 41 deletions tests/testsuite/cargo/z_help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading