Skip to content

Conversation

@charmitro
Copy link
Contributor

@charmitro charmitro commented Dec 2, 2025

Add cleanup for hashed example files, depinfo, debug files, and
incremental compilation outputs when using cargo clean -p with
-Zbuild-dir-new-layout.

The new layout was missing glob-based cleanup for:

  • Hashed example artifacts in build_dir().examples()
  • Rustc-generated depinfo (.d) and debug files (.o, .dwo, .dwp)
  • Incremental compilation files in build_dir().incremental()

Closes #16302

@epage had this in my stash, so let me know if I'm doing something you're already in progress of doing.

@rustbot rustbot added Command-clean S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 2, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 2, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
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

@charmitro charmitro changed the title Clean artifacts Clean artifacts with new layout Dec 2, 2025
Comment on lines 14 to 16
// Ensures that all files for the package have been deleted.
#[track_caller]
fn assert_all_clean(build_dir: &Path) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please put this where it matches with clean.rs

Comment on lines 308 to 318
// Clean incremental compilation files.
for target in pkg.targets() {
if target.is_custom_build() {
continue;
}
let crate_name = target.crate_name();
for (_, layout) in &layouts {
let incremental_dir = escape_glob_path(layout.build_dir().incremental())?;
let pattern = Path::new(&incremental_dir).join(format!("{crate_name}-*"));
clean_ctx.rm_rf_glob(&pattern)?;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this in a new loop body rather than the existing one like for the old layout?

Comment on lines 247 to 249
// Clean hashed example files and depinfo/debug files from examples directory.
// These files have hashes in their names (e.g., foo-abc123, foo-abc123.d) and
// are not covered by the uplifted file cleanup above.
Copy link
Contributor

Choose a reason for hiding this comment

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

What I'm looking for is an answer to #16302 (comment) before moving forward. Something is missing to this puzzle

This test demonstrates that `cargo clean -p` with the new build layout
(`-Zbuild-dir-new-layout`) does not clean all example artifacts,
specifically hashed depinfo files and incremental compilation outputs.

The test is marked `#[should_panic]` as it currently fails without the
corresponding fix.

Signed-off-by: Charalampos Mitrodimas <[email protected]>
Add cleanup for hashed example files, depinfo, debug files, and
incremental compilation outputs when using `cargo clean -p` with
`-Zbuild-dir-new-layout`.

The new layout was missing glob-based cleanup for:
- Hashed example artifacts in build_dir().examples()
- Rustc-generated depinfo (.d) and debug files (.o, .dwo, .dwp)
- Incremental compilation files in build_dir().incremental()

Signed-off-by: Charalampos Mitrodimas <[email protected]>
@charmitro
Copy link
Contributor Author

Closing in favor of #16302

@charmitro charmitro closed this Dec 4, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo clean -Zbuild-dir-new-layout -p foo does not clean uplifted example depinfo files

4 participants