Skip to content
Draft
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
4 changes: 0 additions & 4 deletions crates/cargo-test-support/src/lib.rs

@epage epage Aug 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Blocked until at least August 14th to be after beta branch: https://forge.rust-lang.org/

View changes since the review

Original file line number Diff line number Diff line change
Expand Up @@ -1439,10 +1439,6 @@ pub trait TestEnvCommandExt: Sized {
.env("CARGO_INCREMENTAL", "0")
// Don't read the system git config which is out of our control.
.env("GIT_CONFIG_NOSYSTEM", "1")
// See: https://github.com/rust-lang/rust/pull/159857#issuecomment-5119325932
// This should be removed once the new build-dir layout is stabilized and the old layout
// is removed.
.env("__CARGO_TEMPORARY_BUILD_DIR_NEW_LAYOUT_OPT_OUT", "1")
.env_remove("CI")
.env_remove("__CARGO_DEFAULT_LIB_METADATA")
.env_remove("ALL_PROXY")
Expand Down
7 changes: 4 additions & 3 deletions doc/book/src/reference/build-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ change. Some of these directories are:

Directory | Description
----------|------------
<code style="white-space: nowrap">\<build-dir>/debug/deps/</code> | Dependencies and other artifacts.
<code style="white-space: nowrap">\<build-dir>/debug/incremental/</code> | `rustc` [incremental output], a cache used to speed up subsequent builds.
<code style="white-space: nowrap">\<build-dir>/debug/build/</code> | Output from [build scripts].
<code style="white-space: nowrap">\<build-dir>/debug/build/</code> | Build step results including compilation artifacts and [build script] output.

> **Note**: The build-dir layout was changed in Cargo 1.100.0, thus prior versions use a different layout. (see [#15010](https://github.com/rust-lang/cargo/issues/15010))

## Dep-info files

Expand Down Expand Up @@ -107,7 +108,7 @@ configuration][config]. Refer to sccache documentation for more details.
[`cargo doc`]: ../commands/cargo-doc.md
[`cargo package`]: ../commands/cargo-package.md
[`cargo publish`]: ../commands/cargo-publish.md
[build scripts]: ../reference/build-scripts.md
[build script]: ../reference/build-scripts.md
[config]: ../reference/config.md
[def-workspace]: ../appendix/glossary.md#workspace '"workspace" (glossary entry)'
[target]: ../appendix/glossary.md#target '"target" (glossary entry)'
Expand Down
15 changes: 4 additions & 11 deletions doc/book/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ Each new feature described below should explain how to use it.
* [min-publish-age](#min-publish-age) --- Filters out dependency versions published more recently than a configured minimum age.
* 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 @@ -1735,8 +1734,6 @@ panic = "immediate-abort"

Use fine grain locking instead of locking the entire build cache.

Note: Fine grain locking implicitly enables [build-dir-new-layout](#build-dir-new-layout) as fine grain locking builds on that directory reoganization.

## `[lints.cargo]`

* Tracking Issue: [#12235](https://github.com/rust-lang/cargo/issues/12235)
Expand Down Expand Up @@ -2005,14 +2002,6 @@ The following commands are available under `-Zbuild-analysis`:
- `cargo report rebuilds` --- Reports why crates were rebuilt,
helping diagnose unexpected recompilations.

## build-dir-new-layout

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

Enables the new build-dir filesystem layout.
This layout change unblocks work towards caching and locking improvements.


## compile-time-deps

This permanently-unstable flag to only build proc-macros and build scripts (and their required dependencies),
Expand Down Expand Up @@ -2465,3 +2454,7 @@ The `build.warnings` config field has been stabilized in Rust 1.97.

The `cargo update -Zunstable-options --breaking` flag has been removed in 1.99-nightly.
See <https://github.com/rust-lang/cargo/pull/17333> fopr the reason for its removal.

## build-dir-new-layout

The new build-dir filesystem layout was stabilized in the 1.100.0 release.
10 changes: 4 additions & 6 deletions src/workspace/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,7 @@ macro_rules! unstable_cli_options {
),*
};

// Defaults to enabled on nightly unless explicitly opted out.
if !is_new_build_dir_layout_opt_out() {
unstable.build_dir_new_layout =
matches!(crate::version().release_channel.as_deref(), Some("nightly" | "dev"));
}
unstable.build_dir_new_layout = !is_new_build_dir_layout_opt_out();

return unstable;
}
Expand Down Expand Up @@ -1023,6 +1019,8 @@ const STABILIZED_LOCKFILE_PATH: &str = "The `lockfile-path` config key is now al

const STABILIZED_WARNINGS: &str = "The `build.warnings` config key is now always available";

const STABILIZED_BUILD_DIR_NEW_LAYOUT: &str = "build.build-dir-new-layout is now always enabled.";

fn deserialize_comma_separated_list<'de, D>(
deserializer: D,
) -> Result<Option<Vec<String>>, D::Error>
Expand Down Expand Up @@ -1423,6 +1421,7 @@ impl CliUnstable {
"config-include" => stabilized_warn(k, "1.93", STABILIZED_CONFIG_INCLUDE),
"lockfile-path" => stabilized_warn(k, "1.97", STABILIZED_LOCKFILE_PATH),
"warnings" => stabilized_warn(k, "1.97", STABILIZED_WARNINGS),
"build-dir-new-layout" => stabilized_warn(k, "1.100", STABILIZED_BUILD_DIR_NEW_LAYOUT),

// Unstable features
// Sorted alphabetically:
Expand All @@ -1433,7 +1432,6 @@ 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
14 changes: 7 additions & 7 deletions tests/build-std/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ fn basic() {
[COMPILING] [..]
...
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] unittests src/lib.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH])
[RUNNING] unittests src/main.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH])
[RUNNING] tests/smoke.rs (target/[HOST_TARGET]/debug/deps/smoke-[HASH])
[RUNNING] unittests src/lib.rs (target/[HOST_TARGET]/debug/build/foo/[HASH]/out/foo-[HASH])
[RUNNING] unittests src/main.rs (target/[HOST_TARGET]/debug/build/foo/[HASH]/out/foo-[HASH])
[RUNNING] tests/smoke.rs (target/[HOST_TARGET]/debug/build/foo/[HASH]/out/smoke-[HASH])
[DOCTEST] foo

"#]])
Expand All @@ -180,9 +180,9 @@ fn basic() {
let deps_dir = Path::new("target")
.join(rustc_host())
.join("debug")
.join("deps");
assert!(p.glob(deps_dir.join("*.rlib")).count() > 0);
assert_eq!(p.glob(deps_dir.join("*.dylib")).count(), 0);
.join("build");
assert!(p.glob(deps_dir.join("**/*.rlib")).count() > 0);
assert_eq!(p.glob(deps_dir.join("**/*.dylib")).count(), 0);
}

#[cargo_test(build_std_real)]
Expand Down Expand Up @@ -432,7 +432,7 @@ fn test_proc_macro() {
...
[COMPILING] foo v0.0.0 ([ROOT]/foo)
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] unittests src/lib.rs (target/debug/deps/foo-[HASH])
[RUNNING] unittests src/lib.rs (target/debug/build/foo/[HASH]/out/foo-[HASH])

"#]])
.run();
Expand Down
66 changes: 35 additions & 31 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,25 +620,25 @@ fn build_script_with_bin_artifacts() {
assert_e2e().eq(
&build_script_output,
str![[r#"
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/baz[EXE]
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/staticlib/bar-[HASH].lib
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/cdylib/bar.dll
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/bar[EXE]
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/bar[EXE]
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/bin/baz[EXE]
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/staticlib/bar-[HASH].lib
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/cdylib/bar.dll
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/bin
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/bin/bar[EXE]
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/bin/bar[EXE]

"#]],
);
} else {
assert_e2e().eq(
&build_script_output,
str![[r#"
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/baz-[HASH][EXE]
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/staticlib/libbar-[HASH].a
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/cdylib/[..]bar.[..]
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/bar-[HASH][EXE]
[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/bar-[HASH][EXE]
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/bin/baz[EXE]
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/staticlib/libbar-[HASH].a
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/cdylib/[..]bar.[..]
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/bin
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/bin/bar[EXE]
[ROOT]/foo/target/debug/build/bar/[HASH]/artifact/bin/bar[EXE]

"#]],
);
Expand Down Expand Up @@ -810,17 +810,17 @@ fn build_script_with_selected_dashed_bin_artifact_and_lib_true() {
assert_e2e().eq(
&build_script_output,
str![[r#"
[ROOT]/foo/target/debug/deps/artifact/bar-baz-[HASH]/bin
[ROOT]/foo/target/debug/deps/artifact/bar-baz-[HASH]/bin/baz_suffix[EXE]
[ROOT]/foo/target/debug/build/bar-baz/[HASH]/artifact/bin
[ROOT]/foo/target/debug/build/bar-baz/[HASH]/artifact/bin/baz_suffix[EXE]

"#]],
);
} else {
assert_e2e().eq(
&build_script_output,
str![[r#"
[ROOT]/foo/target/debug/deps/artifact/bar-baz-[HASH]/bin
[ROOT]/foo/target/debug/deps/artifact/bar-baz-[HASH]/bin/baz_suffix-[HASH][EXE]
[ROOT]/foo/target/debug/build/bar-baz/[HASH]/artifact/bin
[ROOT]/foo/target/debug/build/bar-baz/[HASH]/artifact/bin/baz_suffix[EXE]

"#]],
);
Expand All @@ -830,7 +830,7 @@ fn build_script_with_selected_dashed_bin_artifact_and_lib_true() {
!p.bin("bar").is_file(),
"artifacts are located in their own directory, exclusively, and won't be lifted up"
);
assert_artifact_executable_output(&p, "debug", "bar", "baz_suffix");
assert_artifact_executable_output(&p, "debug", "bar-baz", "baz_suffix");
}

#[cargo_test]
Expand Down Expand Up @@ -900,7 +900,7 @@ fn lib_with_selected_dashed_bin_artifact_and_lib_true() {
!p.bin("bar").is_file(),
"artifacts are located in their own directory, exclusively, and won't be lifted up"
);
assert_artifact_executable_output(&p, "debug", "bar", "baz_suffix");
assert_artifact_executable_output(&p, "debug", "bar-baz", "baz_suffix");
}

#[cargo_test]
Expand Down Expand Up @@ -943,7 +943,7 @@ fn allow_artifact_and_no_artifact_dep_to_same_package_within_different_dep_categ
[COMPILING] bar v0.5.0 ([ROOT]/foo/bar)
[COMPILING] foo v0.0.0 ([ROOT]/foo)
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] unittests src/lib.rs (target/debug/deps/foo-[HASH][EXE])
[RUNNING] unittests src/lib.rs (target/debug/build/foo/[HASH]/out/foo-[HASH][EXE])
[DOCTEST] foo

"#]])
Expand Down Expand Up @@ -1292,7 +1292,7 @@ fn cross_doctests_works_with_artifacts() {
[COMPILING] bar v0.5.0 ([ROOT]/foo/bar)
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] unittests src/lib.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH][EXE])
[RUNNING] unittests src/lib.rs (target/[HOST_TARGET]/debug/build/foo/[HASH]/out/foo-[HASH][EXE])
[DOCTEST] foo

"#]])
Expand All @@ -1316,7 +1316,7 @@ fn cross_doctests_works_with_artifacts() {
[RUNNING] `rustc --crate-name foo [..]
[RUNNING] `rustc --crate-name foo [..]
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] `[ROOT]/foo/target/[ALT_TARGET]/debug/deps/foo-[HASH][EXE]`
[RUNNING] `[ROOT]/foo/target/[ALT_TARGET]/debug/build/foo/[HASH]/out/foo-[HASH][EXE]`
[DOCTEST] foo
[RUNNING] `rustdoc [..]--test src/lib.rs --test-run-directory [ROOT]/foo --target [ALT_TARGET] [..]

Expand Down Expand Up @@ -1422,7 +1422,7 @@ fn profile_override_basic() {
[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..] -C opt-level=1 [..]`
[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..] -C opt-level=3 [..]`
[RUNNING] `rustc --crate-name foo [..] -C opt-level=3 [..]`
[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build`
[RUNNING] `[ROOT]/foo/target/debug/build/foo/[HASH]/out/build_script_build`
[FINISHED] `dev` profile [optimized + debuginfo] target(s) in [ELAPSED]s
[COMPILING] foo v0.0.1 ([ROOT]/foo)

Expand Down Expand Up @@ -2207,8 +2207,8 @@ fn env_vars_and_build_products_for_various_build_targets() {
[COMPILING] bar v0.5.0 ([ROOT]/foo/bar)
[COMPILING] foo v0.0.0 ([ROOT]/foo)
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] unittests src/lib.rs (target/debug/deps/foo-[HASH][EXE])
[RUNNING] tests/main.rs (target/debug/deps/main-[HASH][EXE])
[RUNNING] unittests src/lib.rs (target/debug/build/foo/[HASH]/out/foo-[HASH][EXE])
[RUNNING] tests/main.rs (target/debug/build/foo/[HASH]/out/main-[HASH][EXE])
[DOCTEST] foo

"#]])
Expand Down Expand Up @@ -2416,7 +2416,11 @@ fn doc_lib_true() {

// Verify that it emits rmeta for the bin and lib dependency.
assert_eq!(p.glob("target/debug/artifact/*.rlib").count(), 0);
assert_eq!(p.glob("target/debug/deps/libbar-*.rmeta").count(), 2);
assert_eq!(
p.glob("target/debug/build/bar/*/out/libbar-*.rmeta")
.count(),
2
);

p.cargo("doc -Z bindeps")
.masquerade_as_nightly_cargo(&["bindeps"])
Expand Down Expand Up @@ -2508,7 +2512,7 @@ fn assert_artifact_executable_output(
if cfg!(target_env = "msvc") {
assert_eq!(
p.glob(format!(
"target/{}/deps/artifact/{}-*/bin/{}{}",
"target/{}/build/{}/*/artifact/bin/{}{}",
target_name,
dep_name,
bin_name,
Expand All @@ -2521,7 +2525,7 @@ fn assert_artifact_executable_output(
} else {
assert_eq!(
p.glob(format!(
"target/{}/deps/artifact/{}-*/bin/{}-*{}",
"target/{}/build/{}/*/artifact/bin/{}{}",
target_name,
dep_name,
bin_name,
Expand All @@ -2538,7 +2542,7 @@ fn assert_artifact_executable_output(

fn build_script_output_string(p: &Project, package_name: &str) -> String {
let paths = p
.glob(format!("target/debug/build/{}-*/output", package_name))
.glob(format!("target/debug/build/{}/*/run/stdout", package_name))
.collect::<Result<Vec<_>, _>>()
.unwrap();
assert_eq!(paths.len(), 1);
Expand Down Expand Up @@ -2822,7 +2826,7 @@ fn with_assumed_host_target_and_optional_build_dep() {
[COMPILING] d1 v0.0.1 ([ROOT]/foo/d1)
[RUNNING] `rustc --crate-name build_script_build --edition=2021 [..]--crate-type bin[..]
[RUNNING] `rustc --crate-name d1 --edition=2021 [..]--crate-type bin[..]
[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build`
[RUNNING] `[ROOT]/foo/target/debug/build/foo/[HASH]/out/build_script_build`
[RUNNING] `rustc --crate-name foo --edition=2021 [..]--cfg[..]d1[..]
[FINISHED] `dev` profile [..]
[COMPILING] foo v0.0.1 ([ROOT]/foo)
Expand Down Expand Up @@ -3638,7 +3642,7 @@ fn artifact_dep_target_does_not_propagate_to_deps_of_build_script() {
[COMPILING] artifact v0.0.1 ([ROOT]/foo/artifact)
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] unittests src/main.rs (target/debug/deps/foo-[HASH][EXE])
[RUNNING] unittests src/main.rs (target/debug/build/foo/[HASH]/out/foo-[HASH][EXE])

"#]])
.masquerade_as_nightly_cargo(&["bindeps"])
Expand Down Expand Up @@ -3730,7 +3734,7 @@ fn artifact_dep_target_does_not_propagate_to_proc_macro() {
[COMPILING] artifact v0.0.1 ([ROOT]/foo/artifact)
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] unittests src/main.rs (target/debug/deps/foo-[HASH][EXE])
[RUNNING] unittests src/main.rs (target/debug/build/foo/[HASH]/out/foo-[HASH][EXE])

"#]])
.masquerade_as_nightly_cargo(&["bindeps"])
Expand Down
Loading