Repository navigation
Clean /out dir before compilation - #17675
Conversation
|
We'll eventually need to do this for build scripts. The question is whether we need to first introduce the temp dir or not. That doesn't make it blocking for this though. |
| .file("src/new.rs", "") | ||
| .build(); | ||
|
|
||
| p.cargo("build") |
There was a problem hiding this comment.
Do we need to build instead of check?
There was a problem hiding this comment.
its build to include the rlib in the assert_backup_unmodified(rlib) below.
it could be check, but it would no longer cover overwriting the rlib.
There was a problem hiding this comment.
Do we need to cover every type of file or a representative set?
There was a problem hiding this comment.
I was trying to test all of the most common types like rmeta and rlib. But I'd imagine I did not exhaustively test it.
Do you think I am missing any file types that covering would be important?
There was a problem hiding this comment.
In general, if we can get away with it, we prefer testing using check over build because build is slower and gets us closer to exhausting disk space in CI, so I'm wondering the other direction, if checking for a rmeta is good enough generally.
There was a problem hiding this comment.
Personally I feel that explicitly checking that the rlib is unmodified in this test has value.
There was a problem hiding this comment.
This seems fine to me. assert_backup_unmodified explicitly checks for rlib. That give an enough context.
This commit wipes the unit's out dir before we [re]build it to avoid write to hardlinked files being used outside of build-dir. The motivation for this commit is to prepare for deduplication for files in the build-dir using shared content addressible storage. We want to avoid overwriting a file that is hardlinked into the CAS.
009c819 to
70f2154
Compare
|
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. |
| .file("src/new.rs", "") | ||
| .build(); | ||
|
|
||
| p.cargo("build") |
There was a problem hiding this comment.
This seems fine to me. assert_backup_unmodified explicitly checks for rlib. That give an enough context.
Update cargo submodule 13 commits in 31d3246e0e8d3a80d4a90b54aa48ff180adb408b..3c747ea3ead23951c1b43a5edfcbdb449135ddeb 2026-10-27 13:54:39 +0000 to 2026-11-03 21:25:31 +0000 - Link to `cargo search` result's crates.io pages (rust-lang/cargo#17668) - Clean `/out` dir before compilation (rust-lang/cargo#17675) - Allow `uncommon_codepoints` in confusable test (rust-lang/cargo#17676) - test: Update https certificate failed messages (rust-lang/cargo#17679) - chore(deps): update rust-lang/crates-io-auth-action action to v1.0.6 (rust-lang/cargo#17670) - chore(deps): update actions/deploy-pages action to v5.0.1 (rust-lang/cargo#17669) - Fix manifest schema generation: `TomlOptLevel` and `StringOrVec` (rust-lang/cargo#17660) - remove deprecated tempdir (rust-lang/cargo#17663) - chore(ci): remove Windows rustup PATH workaround (rust-lang/cargo#17667) - test: probe stable cargo through rustup (rust-lang/cargo#17666) - Update outdated registry function comments (rust-lang/cargo#17664) - perf(windows): Delay-load system DLLs that most commands don't use (rust-lang/cargo#17623) - Suppress `dead_code_pub_in_binary` for library test units (rust-lang/cargo#17608)
Update cargo submodule 13 commits in 31d3246e0e8d3a80d4a90b54aa48ff180adb408b..3c747ea3ead23951c1b43a5edfcbdb449135ddeb 2026-10-27 13:54:39 +0000 to 2026-11-03 21:25:31 +0000 - Link to `cargo search` result's crates.io pages (rust-lang/cargo#17668) - Clean `/out` dir before compilation (rust-lang/cargo#17675) - Allow `uncommon_codepoints` in confusable test (rust-lang/cargo#17676) - test: Update https certificate failed messages (rust-lang/cargo#17679) - chore(deps): update rust-lang/crates-io-auth-action action to v1.0.6 (rust-lang/cargo#17670) - chore(deps): update actions/deploy-pages action to v5.0.1 (rust-lang/cargo#17669) - Fix manifest schema generation: `TomlOptLevel` and `StringOrVec` (rust-lang/cargo#17660) - remove deprecated tempdir (rust-lang/cargo#17663) - chore(ci): remove Windows rustup PATH workaround (rust-lang/cargo#17667) - test: probe stable cargo through rustup (rust-lang/cargo#17666) - Update outdated registry function comments (rust-lang/cargo#17664) - perf(windows): Delay-load system DLLs that most commands don't use (rust-lang/cargo#17623) - Suppress `dead_code_pub_in_binary` for library test units (rust-lang/cargo#17608)
What does this PR try to resolve?
This PR cleans the
build-dir/<profile>/build/<pkg>/<hash>/outfor between each build.This behavior already existing outputs (see #11122) but was explicit with which files it removed and lead to the rustc dep info files not being included in this. With the new build-dir layout, we can simplfiy this logic by just wiping the entire
outdirectory instead of tracking and removing each output.This is a precursor to #17453 as we want to prevent the risk of rustc writing to a hardlink saved in shared content addressible storage. #17512 will hopefully build on this work in the future.
Note this PR does not attempt to change the behavior for build scripts. I was unsure if proactively wiping the out dir for build scripts could lead to longer build times. (e.g. wiping a c projects cache instead of reusing the previous work)
Notes to reviewers
I'd suggest turn off whitespace while reviewing as most of the diffs are indenting.
🤖 LLM involvement:
r? @epage