Skip to content

Enable build-dir layout v2 on nightly by default - #17258

Merged
weihanglo merged 2 commits into
rust-lang:masterfrom
ranger-ross:enable-build-dir-layout-nightly
Jul 24, 2026
Merged

weihanglo merged 2 commits into
rust-lang:masterfrom
ranger-ross:enable-build-dir-layout-nightly

Conversation

@ranger-ross

Copy link
Copy Markdown
Member

What does this PR try to resolve?

This PR enables the new build-dir on nightly by default.

The majority of changes were taken/adapted from #16807

Tracked in #15010

How to test and review this PR?

Same as the original stabilization PR.
The notable changes are:

  • A handful of tests may recompile crates when test's p.cargo() use a mixture of stable and nightly
    • For checksum freshness specifically, I enabled nightly on all of the p.cargo() as the tests are specifically testing for rebuilds.

@rustbot rustbot added the A-unstable Area: nightly unstable support label Jul 23, 2026
@ranger-ross
ranger-ross force-pushed the enable-build-dir-layout-nightly branch 7 times, most recently from 3f297a4 to d34b4b3 Compare July 23, 2026 15:27
@ranger-ross
ranger-ross marked this pull request as ready for review July 23, 2026 17:01
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2026
@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @epage, @weihanglo
  • @epage, @weihanglo expanded to epage, weihanglo
  • Random selection from epage, weihanglo

@ranger-ross

Copy link
Copy Markdown
Member Author

Marking this as ready to review.

I spent some time trying to reproduce sccache failures with argfiles on windows, and couldn't get a failure. (tested on zed again, with __CARGO_TEST_FORCE_ARGFILE but it just worked)
I still wanna tinker on it some more, but I think it should at least be okay on the happy path which makes me more comfortable at least trying it on nightly.

Comment thread src/workspace/features.rs
/// gating unstable functionality to Cargo. These flags are only available on
/// the nightly channel of Cargo.
#[derive(Default, Debug, Deserialize)]
#[derive(Debug, Deserialize)]

@epage epage Jul 23, 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.

Is there a way to do this without removing Default? This makes it more invasive to undo and redo.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ehh its get awkward to avoid, specially due to #[serde(default)].

I split out a refactor commit and manually impl'd Default in the macro to reduce the bloat and need to update the Default impl when adding new features.
It's still not ideal but maybe a bit better?

@ranger-ross
ranger-ross force-pushed the enable-build-dir-layout-nightly branch from d34b4b3 to 4bb796b Compare July 24, 2026 01:49
@rustbot rustbot added the A-dependency-resolution Area: dependency resolution and the resolver label Jul 24, 2026
@rustbot

This comment has been minimized.

@ranger-ross
ranger-ross force-pushed the enable-build-dir-layout-nightly branch from 4bb796b to 7b66084 Compare July 24, 2026 01:50
@rustbot

rustbot commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Comment thread src/workspace/features.rs Outdated
// Defaults to enabled on nightly unless explicitly opted out.
let c = &channel();
unstable.build_dir_new_layout =
(c == "nightly" || c == "dev") && !is_new_build_dir_layout_opt_out();

@weihanglo weihanglo Jul 24, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Josh (or someone I don't remember) has mentioned there are people using stable toolchains but enable RUSTC_BOOTSTRAP=1 for enabling some unstable features. Should we avoid enable it if the toolchain is stable/beta?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It was @Mark-Simulacrum that mentioned it here.
Yeah, I think that makes sense. When that comment was made it kind of went over my head (we have so many bespoke config options 😆)

If I understand it correctly, enabling RUSTC_BOOTSTRAP=1 will result in Cargo using the dev channel.

if let Ok(staging) = env::var("RUSTC_BOOTSTRAP") {
if staging == "1" {
return "dev".to_string();
}

So the logic should be updated to

let is_rustc_bootstrap = env::var("RUSTC_BOOTSTRAP").map(|o| &o == "1");
unstable.build_dir_new_layout = (c == "nightly" || c == "dev") && !is_new_build_dir_layout_opt_out() && !is_rustc_bootstrap;

Will this cause an issues in bootstrap? I guess not since bootstrap explicitly passes -Zbuild-dir-new-layout and this is just for the defaults.

Does that all sound correct?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Either that or just something like crate::version().release_channel == Some("nightly" | "dev")?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ah yeah that should work. I wish I had thought of this before updating all of the tests again. 🫠

Since this skips __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS none of the tests need to be updated

@ranger-ross
ranger-ross force-pushed the enable-build-dir-layout-nightly branch from 7b66084 to d035da6 Compare July 24, 2026 04:53

@weihanglo weihanglo left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@weihanglo
weihanglo added this pull request to the merge queue Jul 24, 2026
Merged via the queue into rust-lang:master with commit 95303e6 Jul 24, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 24, 2026
weihanglo added a commit to weihanglo/rust that referenced this pull request Jul 24, 2026
Cargo enables build-dir layout v2 by default on nightly
(rust-lang/cargo#17258).
Intermediate build artifacts no longer live in
`<target-dir>/<triple>/<profile>/deps/`
but in per-unit `build/<pkg>/<hash>/out/` directories.

Search the target directory recursively
instead of hardcoding the artifact location,
so these tests pass under both the old and the new layout.
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 29, 2026
Update cargo submodule




## src/tools/cargo


20 commits in 3efb1f477e99b42974b982d939fd100303cdf7db..a09737c688e6b643b3a2e185d076bb4a298d6965
2026-07-17 23:53:19 +0000 to 2026-07-26 15:00:33 +0000
- fix(cli): don't panic during completions when rustup is unavailable (rust-lang/cargo#17263)
- docs(workspace): add recommended structure to members field (rust-lang/cargo#17166)
- Update cargo-fetch.md to remove cargo-prefetch reference (rust-lang/cargo#16568)
- chore: bump to `[email protected]+1.9.6` (rust-lang/cargo#17259)
- Enable build-dir layout v2 on nightly by default (rust-lang/cargo#17258)
- fix(path): clarify error message when path dependency has wrong package (rust-lang/cargo#16927)
- fix(toml): warn on hyphenated lint names and duplicates (rust-lang/cargo#17051)
- fix(test): gate trim-paths tests on split debuginfo support (rust-lang/cargo#17256)
- test(git): Explicitly test for git injection attacks (rust-lang/cargo#17253)
- fix(git): Suggest libgit2 if git-cli fails (rust-lang/cargo#17252)
- fix(diag): bound transitive unused dependency traversal (rust-lang/cargo#17251)
- fix(git): Hide git fetch output without progress  (rust-lang/cargo#17243)
- revert(lint): Remove `new_implicit_minimum_version_req` (rust-lang/cargo#16321) (rust-lang/cargo#17249)
- fix: Add haiku's dylib path (rust-lang/cargo#17248)
- Zsh completion: Add `-p` and `--package` flags for `cargo add` (rust-lang/cargo#17247)
- refactor(source): Clarify the name of the remote git registry (rust-lang/cargo#17240)
- fix(timings): only report units the job queue actually ran (rust-lang/cargo#17238)
- Do not include proc-macro deps in rustc search path args (rust-lang/cargo#17236)
- chore(deps): update cargo-semver-checks to v0.49.0 (rust-lang/cargo#17237)
- rustdoc: rename the doc parts metadata params (rust-lang/cargo#17234)

## src/tools/rustc-perf

12 commits in 0508bdcd37152b28c39b6752828683cdd3f128b5..74ecbcdf88411937a6e39baf2779948565dfd388
2026-07-15 10:20:27 +0000 to 2026-07-27 15:02:48 +0000
- feat: support `@argfile` for rustc-fake (rust-lang/rustc-perf#2509)
- Download Clippy when a Clippy profile is requested (rust-lang/rustc-perf#2508)
- Add early check for missing rustdoc/clippy in a toolchain (rust-lang/rustc-perf#2507)
- Add 2026-07-21 triage (rust-lang/rustc-perf#2506)
- use stable extract_if: since 1.87 (rust-lang/rustc-perf#2191)
- Update GitHub Actions (rust-lang/rustc-perf#2460)
- Update dependency @types/msgpack-lite to v0.1.12 (rust-lang/rustc-perf#2439)
- Add 30 day history link to artifact size tab on the compare page (rust-lang/rustc-perf#2505)
- Fix selecting color for the bootstrap chart on the toolchain page (rust-lang/rustc-perf#2504)
- Add artifact size history chart to toolchain page (rust-lang/rustc-perf#2501)
- Parallel frontend compiler support (perf backend only) (rust-lang/rustc-perf#2491)
- Run benchmark smoke test for all profiles on Windows on CI (rust-lang/rustc-perf#2503)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 29, 2026
Update cargo submodule




## src/tools/cargo


20 commits in 3efb1f477e99b42974b982d939fd100303cdf7db..a09737c688e6b643b3a2e185d076bb4a298d6965
2026-07-17 23:53:19 +0000 to 2026-07-26 15:00:33 +0000
- fix(cli): don't panic during completions when rustup is unavailable (rust-lang/cargo#17263)
- docs(workspace): add recommended structure to members field (rust-lang/cargo#17166)
- Update cargo-fetch.md to remove cargo-prefetch reference (rust-lang/cargo#16568)
- chore: bump to `[email protected]+1.9.6` (rust-lang/cargo#17259)
- Enable build-dir layout v2 on nightly by default (rust-lang/cargo#17258)
- fix(path): clarify error message when path dependency has wrong package (rust-lang/cargo#16927)
- fix(toml): warn on hyphenated lint names and duplicates (rust-lang/cargo#17051)
- fix(test): gate trim-paths tests on split debuginfo support (rust-lang/cargo#17256)
- test(git): Explicitly test for git injection attacks (rust-lang/cargo#17253)
- fix(git): Suggest libgit2 if git-cli fails (rust-lang/cargo#17252)
- fix(diag): bound transitive unused dependency traversal (rust-lang/cargo#17251)
- fix(git): Hide git fetch output without progress  (rust-lang/cargo#17243)
- revert(lint): Remove `new_implicit_minimum_version_req` (rust-lang/cargo#16321) (rust-lang/cargo#17249)
- fix: Add haiku's dylib path (rust-lang/cargo#17248)
- Zsh completion: Add `-p` and `--package` flags for `cargo add` (rust-lang/cargo#17247)
- refactor(source): Clarify the name of the remote git registry (rust-lang/cargo#17240)
- fix(timings): only report units the job queue actually ran (rust-lang/cargo#17238)
- Do not include proc-macro deps in rustc search path args (rust-lang/cargo#17236)
- chore(deps): update cargo-semver-checks to v0.49.0 (rust-lang/cargo#17237)
- rustdoc: rename the doc parts metadata params (rust-lang/cargo#17234)

## src/tools/rustc-perf

12 commits in 0508bdcd37152b28c39b6752828683cdd3f128b5..74ecbcdf88411937a6e39baf2779948565dfd388
2026-07-15 10:20:27 +0000 to 2026-07-27 15:02:48 +0000
- feat: support `@argfile` for rustc-fake (rust-lang/rustc-perf#2509)
- Download Clippy when a Clippy profile is requested (rust-lang/rustc-perf#2508)
- Add early check for missing rustdoc/clippy in a toolchain (rust-lang/rustc-perf#2507)
- Add 2026-07-21 triage (rust-lang/rustc-perf#2506)
- use stable extract_if: since 1.87 (rust-lang/rustc-perf#2191)
- Update GitHub Actions (rust-lang/rustc-perf#2460)
- Update dependency @types/msgpack-lite to v0.1.12 (rust-lang/rustc-perf#2439)
- Add 30 day history link to artifact size tab on the compare page (rust-lang/rustc-perf#2505)
- Fix selecting color for the bootstrap chart on the toolchain page (rust-lang/rustc-perf#2504)
- Add artifact size history chart to toolchain page (rust-lang/rustc-perf#2501)
- Parallel frontend compiler support (perf backend only) (rust-lang/rustc-perf#2491)
- Run benchmark smoke test for all profiles on Windows on CI (rust-lang/rustc-perf#2503)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 29, 2026
Update cargo submodule




## src/tools/cargo

23 commits in 3efb1f477e99b42974b982d939fd100303cdf7db..7c83d4cc0953b81d823e47d640c64da9b8bd4fac
2026-07-17 23:53:19 +0000 to 2026-07-29 21:34:53 +0000
- fix: Pass rustdoc flags to final CCI merge step (rust-lang/cargo#17269)
- Reworked how we enable the new build-dir layout on nightly (rust-lang/cargo#17272)
- Allow setting `-Zembed-metadata` value from the config (rust-lang/cargo#17266)
- fix(cli): don't panic during completions when rustup is unavailable (rust-lang/cargo#17263)
- docs(workspace): add recommended structure to members field (rust-lang/cargo#17166)
- Update cargo-fetch.md to remove cargo-prefetch reference (rust-lang/cargo#16568)
- chore: bump to `[email protected]+1.9.6` (rust-lang/cargo#17259)
- Enable build-dir layout v2 on nightly by default (rust-lang/cargo#17258)
- fix(path): clarify error message when path dependency has wrong package (rust-lang/cargo#16927)
- fix(toml): warn on hyphenated lint names and duplicates (rust-lang/cargo#17051)
- fix(test): gate trim-paths tests on split debuginfo support (rust-lang/cargo#17256)
- test(git): Explicitly test for git injection attacks (rust-lang/cargo#17253)
- fix(git): Suggest libgit2 if git-cli fails (rust-lang/cargo#17252)
- fix(diag): bound transitive unused dependency traversal (rust-lang/cargo#17251)
- fix(git): Hide git fetch output without progress  (rust-lang/cargo#17243)
- revert(lint): Remove `new_implicit_minimum_version_req` (rust-lang/cargo#16321) (rust-lang/cargo#17249)
- fix: Add haiku's dylib path (rust-lang/cargo#17248)
- Zsh completion: Add `-p` and `--package` flags for `cargo add` (rust-lang/cargo#17247)
- refactor(source): Clarify the name of the remote git registry (rust-lang/cargo#17240)
- fix(timings): only report units the job queue actually ran (rust-lang/cargo#17238)
- Do not include proc-macro deps in rustc search path args (rust-lang/cargo#17236)
- chore(deps): update cargo-semver-checks to v0.49.0 (rust-lang/cargo#17237)
- rustdoc: rename the doc parts metadata params (rust-lang/cargo#17234)

## src/tools/rustc-perf

12 commits in 0508bdcd37152b28c39b6752828683cdd3f128b5..74ecbcdf88411937a6e39baf2779948565dfd388
2026-07-15 10:20:27 +0000 to 2026-07-27 15:02:48 +0000
- feat: support `@argfile` for rustc-fake (rust-lang/rustc-perf#2509)
- Download Clippy when a Clippy profile is requested (rust-lang/rustc-perf#2508)
- Add early check for missing rustdoc/clippy in a toolchain (rust-lang/rustc-perf#2507)
- Add 2026-07-21 triage (rust-lang/rustc-perf#2506)
- use stable extract_if: since 1.87 (rust-lang/rustc-perf#2191)
- Update GitHub Actions (rust-lang/rustc-perf#2460)
- Update dependency @types/msgpack-lite to v0.1.12 (rust-lang/rustc-perf#2439)
- Add 30 day history link to artifact size tab on the compare page (rust-lang/rustc-perf#2505)
- Fix selecting color for the bootstrap chart on the toolchain page (rust-lang/rustc-perf#2504)
- Add artifact size history chart to toolchain page (rust-lang/rustc-perf#2501)
- Parallel frontend compiler support (perf backend only) (rust-lang/rustc-perf#2491)
- Run benchmark smoke test for all profiles on Windows on CI (rust-lang/rustc-perf#2503)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 30, 2026
Update cargo submodule




## src/tools/cargo

23 commits in 3efb1f477e99b42974b982d939fd100303cdf7db..7c83d4cc0953b81d823e47d640c64da9b8bd4fac
2026-07-17 23:53:19 +0000 to 2026-07-29 21:34:53 +0000
- fix: Pass rustdoc flags to final CCI merge step (rust-lang/cargo#17269)
- Reworked how we enable the new build-dir layout on nightly (rust-lang/cargo#17272)
- Allow setting `-Zembed-metadata` value from the config (rust-lang/cargo#17266)
- fix(cli): don't panic during completions when rustup is unavailable (rust-lang/cargo#17263)
- docs(workspace): add recommended structure to members field (rust-lang/cargo#17166)
- Update cargo-fetch.md to remove cargo-prefetch reference (rust-lang/cargo#16568)
- chore: bump to `[email protected]+1.9.6` (rust-lang/cargo#17259)
- Enable build-dir layout v2 on nightly by default (rust-lang/cargo#17258)
- fix(path): clarify error message when path dependency has wrong package (rust-lang/cargo#16927)
- fix(toml): warn on hyphenated lint names and duplicates (rust-lang/cargo#17051)
- fix(test): gate trim-paths tests on split debuginfo support (rust-lang/cargo#17256)
- test(git): Explicitly test for git injection attacks (rust-lang/cargo#17253)
- fix(git): Suggest libgit2 if git-cli fails (rust-lang/cargo#17252)
- fix(diag): bound transitive unused dependency traversal (rust-lang/cargo#17251)
- fix(git): Hide git fetch output without progress  (rust-lang/cargo#17243)
- revert(lint): Remove `new_implicit_minimum_version_req` (rust-lang/cargo#16321) (rust-lang/cargo#17249)
- fix: Add haiku's dylib path (rust-lang/cargo#17248)
- Zsh completion: Add `-p` and `--package` flags for `cargo add` (rust-lang/cargo#17247)
- refactor(source): Clarify the name of the remote git registry (rust-lang/cargo#17240)
- fix(timings): only report units the job queue actually ran (rust-lang/cargo#17238)
- Do not include proc-macro deps in rustc search path args (rust-lang/cargo#17236)
- chore(deps): update cargo-semver-checks to v0.49.0 (rust-lang/cargo#17237)
- rustdoc: rename the doc parts metadata params (rust-lang/cargo#17234)

## src/tools/rustc-perf

12 commits in 0508bdcd37152b28c39b6752828683cdd3f128b5..74ecbcdf88411937a6e39baf2779948565dfd388
2026-07-15 10:20:27 +0000 to 2026-07-27 15:02:48 +0000
- feat: support `@argfile` for rustc-fake (rust-lang/rustc-perf#2509)
- Download Clippy when a Clippy profile is requested (rust-lang/rustc-perf#2508)
- Add early check for missing rustdoc/clippy in a toolchain (rust-lang/rustc-perf#2507)
- Add 2026-07-21 triage (rust-lang/rustc-perf#2506)
- use stable extract_if: since 1.87 (rust-lang/rustc-perf#2191)
- Update GitHub Actions (rust-lang/rustc-perf#2460)
- Update dependency @types/msgpack-lite to v0.1.12 (rust-lang/rustc-perf#2439)
- Add 30 day history link to artifact size tab on the compare page (rust-lang/rustc-perf#2505)
- Fix selecting color for the bootstrap chart on the toolchain page (rust-lang/rustc-perf#2504)
- Add artifact size history chart to toolchain page (rust-lang/rustc-perf#2501)
- Parallel frontend compiler support (perf backend only) (rust-lang/rustc-perf#2491)
- Run benchmark smoke test for all profiles on Windows on CI (rust-lang/rustc-perf#2503)
@rustbot rustbot added this to the 1.99.0 milestone Jul 30, 2026
phil-opp added a commit to rust-osdev/bootimage that referenced this pull request Aug 3, 2026
LatticeArc-Founder pushed a commit to LatticeArc/latticearc that referenced this pull request Aug 3, 2026
Four independent breakages, all found while investigating the red build
on b4b80f8.

1. FIPS integrity test aborts under cargo build-dir layout v2
---------------------------------------------------------------
`path_looks_like_latticearc_module` required the running binary's parent
directory to be literally `deps`. Layout v2 moved unit test binaries from

    target/<triple>/<profile>/deps/<crate>-<hash>
to
    target/<triple>/<profile>/build/<pkg>/<hash>/out/<crate>-<hash>

so every test binary began failing that check. The rejection failed the
module integrity test, failed the power-up self-test, and hit FIPS
140-3 section 9.1's `process::abort()` - SIGABRT-ing the test runner
before a single result was reported.

This surfaced on the weekly ASan/TSan/LSan jobs, the only ones pinned to
nightly: all three aborted at
`self_test::tests::test_initialize_and_test_sets_flag_succeeds` once
rust-lang/cargo#17258 (merged 2026-07-24) made layout v2 the nightly
default. Layout v2 is stabilized for 1.99.0 by rust-lang/cargo#16807, so
this was days from reaching every `cargo test` on stable - including
downstream consumers whose suites call `initialize_and_test()`.

The check now matches on the two properties cargo does not document as
internal: the `<crate-name>-<16-hex>` file-name shape, and containment
under a `target` ancestor. Cargo explicitly reserves the right to
reshuffle the build-dir layout, so pinning an intermediate directory
name would only queue the same outage up for layout v3.

Consequences of the wider match:

  * `target/<profile>/<crate>-<hex>` (no intervening artifact dir) is
    now accepted. It is a legitimate build-tree artifact.
  * The ancestor walk is bounded at 12 hops rather than 8. The bound
    only stops the walk reaching the filesystem root; it is not a trust
    boundary, and sizing it flush against the deepest layout known today
    is what caused this outage.

Module authenticity is unchanged: it is established by HMAC over the
binary, not by path. The helper's actual job - distinguishing our own
artifact from a Python/Node host process that dlopen'd the library -
still rejects every host-interpreter path.

Verified against a real layout-v2 build (`cargo +nightly test
-Zbuild-dir-new-layout`), which places the binary at
`target/debug/build/latticearc/<hash>/out/latticearc-<hash>`: the
integrity test returns Ok and `test_initialize_and_test_sets_flag_succeeds`
passes instead of aborting. Both layouts are pinned in the unit tests so
a future re-narrowing fails loudly rather than at POST.

2. Feature Flag Powerset never completed, and never went red
---------------------------------------------------------------
Every scheduled run was killed at exactly 6h00m:

  30736018769  cancelled  6h0m22s  2026-08-02
  30191256595  cancelled  6h0m19s  2026-07-26
  29676467815  cancelled  6h0m19s  2026-07-19
  29182750237  cancelled  6h0m21s  2026-07-12
  28733241736  cancelled  6h0m22s  2026-07-05
  28315598345  cancelled  6h0m19s  2026-06-28

Six hours is a hard GitHub limit on job execution time for hosted
runners. `timeout-minutes` can only lower it, never raise it, so the
`timeout-minutes: 720` this workflow carried - added specifically to
escape the cap, per its own header comment - had no effect. And because
the cap terminates a job as `cancelled` rather than `failure`, the
workflow never rendered red: the check silently provided zero coverage
for over a month.

  * Shard the sweep across an 8-way matrix using `cargo hack
    --partition M/8`. The powerset is 5119 combinations (measured via
    `--print-command-list`), so each shard runs ~640. `--partition`
    assigns each run to exactly one shard - contiguous, disjoint blocks
    of `ceil(total/N)` - so the shards cover the sweep exactly once.
  * Set `timeout-minutes: 300`, below the cap, so an overrun is killed
    by us as a visible `failure` rather than silently by GitHub.
  * `fail-fast: false`, so one shard failing does not discard the other
    seven results.
  * Key the cargo cache per shard; eight jobs sharing one key would race
    on save. `restore-keys` lets a cold shard warm from a sibling.

The header comment is rewritten to record why `timeout-minutes` cannot
raise the cap, so the next person to hit a shard timeout raises the
partition count instead of the timeout.

3. One failed commit bricked every later commit
---------------------------------------------------------------
The hook builds its test log with

    mktemp "$TEST_LOG_DIR/pre-commit-test-output.XXXXXX.log"

BSD `mktemp` (macOS, where this hook actually runs) only substitutes a
trailing run of `X`s. Given `...XXXXXX.log` it expands nothing and tries
to create a file named literally `pre-commit-test-output.XXXXXX.log`.
That succeeds the first time - and since the log is deliberately
PRESERVED on failure, every subsequent commit then died with

    mktemp: mkstemp failed on .../pre-commit-test-output.XXXXXX.log: File exists

before running a single test. A single failed commit permanently blocked
all later commits until someone manually deleted the file. A stale log
from 2026-08-02 was doing exactly that.

Moving the `X`s to the end (`pre-commit-test-output.log.XXXXXX`) restores
per-run unique names on both BSD and GNU mktemp; verified that two
successive calls now yield distinct paths. `mktemp -d` at line 436
already had the `X`s trailing and was unaffected. The comment records why
the suffix must not be moved back.

4. Flaky FIPS global-state test
---------------------------------------------------------------
`test_get_fips_validation_result_consistency_succeeds` intermittently
failed at global.rs:375 comparing two consecutive reads of
`FIPS_VALIDATION_RESULT` - caught in a preserved hook log from
2026-08-02, and passing on the very next full run.

`FIPS_GLOBAL_SERIAL` exists precisely to serialize this, and the reader
does hold it across both reads. The hole is on the writer side: of the
three writers of `FIPS_VALIDATION_RESULT` in this module, only one took
the guard.

  * `ensure_initialized_for_test` did a check-then-act on
    `FIPS_INITIALIZED` with no guard, so several tests could all observe
    `false`, each run `validate_module()` (a fresh `validation_id` per
    call) and each `replace()` the global.
  * `test_init_lock_and_store_result_succeeds` replaced the global
    unconditionally on every run, guardless - the guaranteed writer, and
    the most likely source of the observed interleaving.

Both now take `FIPS_GLOBAL_SERIAL`, and `ensure_initialized_for_test`
re-checks the flag under the guard so initialization happens exactly
once. The guard's doc comment now states the actual invariant - every
writer holds it, not just store-then-read tests - and warns that it is a
plain non-reentrant `Mutex`, so a guard holder must not call
`ensure_initialized_for_test`.

Confirmed the globals are `pub(crate)` but touched only in this module,
and that `tests/tests/` merely replicates these code paths in a separate
binary, so there is no cross-module or cross-binary writer left out.

Verified by A/B stress of the module, same binary, same loop:

    pre-fix    600 iterations    7 failures
    post-fix   900 iterations    0 failures

Every pre-fix failure was
`test_get_fips_validation_result_consistency_succeeds`, matching the
2026-08-02 log. The full 510-test binary also passes 20 consecutive
runs, so the added guard introduces no contention or deadlock with the
module's other tests.

Not fixed here: `performance.yml` carries the same layout-v1 assumption
(`find target/{release,debug}/deps -name 'latticearc-*'`) in its two
profiling steps. That workflow is dormant - every trigger is commented
out and it last ran 2026-02-05 - so it is left alone, but it needs the
same treatment before those triggers are re-enabled.
svasista-ms pushed a commit to svasista-ms/windows-drivers-rs that referenced this pull request Aug 4, 2026
…2 in nightly runs (microsoft#707)

## Summary

The new build-dir v2 layout was added in Rust nightly by this pr
rust-lang/rust#159857 which breaks tooling in
our cargo-wdk and pipeline.

This PR sets the opt out environment variable in the build and test
workflows to continue using the v1 build-dir layout until `cargo-wdk`
can be updated to support the build-dir layout v2.

reference PR's:

- rust-lang/cargo#17258
- rust-lang/cargo#17272

info on the new build directory layout:

-
https://blog.rust-lang.org/2026/03/13/call-for-testing-build-dir-layout-v2/

GitHub Issue Link:
microsoft#709

---------

Signed-off-by: Alan632 <[email protected]>
Co-authored-by: Alan Ngo <[email protected]>
Co-authored-by: Melvin Wang <[email protected]>
pull Bot pushed a commit to pepe57/cargo that referenced this pull request Aug 18, 2026
### What does this PR try to resolve?

This PR restabilizes the new build-dir layout tracked in
rust-lang#15010.

The previous stablization in
rust-lang#16807 was rolled back due to
performance and scaling issues discovered on nightly.
These issues were mitigated in
rust-lang#17191,
rust-lang#17168, and
rust-lang#17236.

The new layout was re-enabled on nightly in
rust-lang#17258 and there has been no
reported issues. Many tools have started migrating and the majority of
well known tools have already added support for the new build-dir
layout.

closes rust-lang#15010

### How to test and review this PR?

`cargo test` and the new layout has been enabled on nightly for ~2
weeks.
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Oct 29, 2026
…f Cargo output layout. r=firefox-build-system-reviewers,sergesanspaille

Cargo 1.99 enables build-dir layout v2 by default on the dev and nightly
channels (rust-lang/cargo#17258). Test
executables move out of the deps directory, which Cargo no longer
includes in the runtime library search path, leaving the staged native
libraries undiscoverable.

Use dist/bin through LD_LIBRARY_PATH on Linux and PATH on Windows
instead of copying libraries into Cargo output directories. This also
covers transitive NSS dependencies that the test executable RUNPATH does
not resolve.

Differential Revision: https://phabricator.services.mozilla.com/D337831
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-dependency-resolution Area: dependency resolution and the resolver A-unstable Area: nightly unstable support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants