Skip to content

build_helper: try to rename dir before delete #140091

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

Closed
wants to merge 1 commit into from

Conversation

ChrisDenton
Copy link
Member

This is aimed at working around "failed to remove and recreate output directory" errors in CI. Mostly coming from

remove_and_create_dir_all(&mir_dump_dir).unwrap_or_else(|e| {
panic!("failed to remove and recreate output directory `{mir_dump_dir}`: {e}")

Essentially we want to create a new empty directory but an old directory with the same name exists. Ideally we'd remove the old directory but renaming it has (more or less) the same effect. Maybe a better strategy would be to use unique directory names to start with but I fear that will be a more invasive change.

r? jieyouxu

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 20, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks, I think this is worth a shot. I measured bootstrap build time diff on dev-desktop between introducing fastrand (this PR) and master:

  • This PR w/ fastrand: 22.41s
  • b8005bf w/out fastrand: 22.02s

Approximately 1.77% increase, but absolute time diff wise seems okay.

@jieyouxu
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Apr 21, 2025

📌 Commit 605af72 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 21, 2025
@ChrisDenton
Copy link
Member Author

If fastrand does end up being a problem then I could probably hack something together using Instant and maybe thread and process ids. It wouldn't be as pretty though.

@jieyouxu
Copy link
Member

If fastrand does end up being a problem then I could probably hack something together using Instant and maybe thread and process ids. It wouldn't be as pretty though.

I don't think it's a significant enough impact to warrant hand-rolling, it's fine.

jieyouxu added a commit to jieyouxu/rust that referenced this pull request Apr 21, 2025
build_helper: try to rename dir before delete

This is aimed at working around "failed to remove and recreate output directory" errors in CI. Mostly coming from https://github.com/rust-lang/rust/blob/49e5e4e3a5610c240a717cb99003a5d5d3356679/src/tools/compiletest/src/runtest.rs#L1515-L1516

Essentially we want to create a new empty directory but an old directory with the same name exists. Ideally we'd remove the old directory but renaming it has (more or less) the same effect. Maybe a better strategy would be to use unique directory names to start with but I fear that will be a more invasive change.

r? jieyouxu
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 21, 2025
Rollup of 12 pull requests

Successful merges:

 - rust-lang#134213 (Stabilize `naked_functions`)
 - rust-lang#139795 (Clarify why SGX code specifies linkage/symbol names for certain statics)
 - rust-lang#139981 (Don't compute name of associated item if it's an RPITIT)
 - rust-lang#140036 (Advent of `tests/ui` (misc cleanups and improvements) [4/N])
 - rust-lang#140047 (remove a couple clones)
 - rust-lang#140052 (Fix error when an intra doc link is trying to resolve an empty associated item)
 - rust-lang#140074 (rustdoc-json: Improve test for auto-trait impls)
 - rust-lang#140076 (jsondocck: Require command is at start of line)
 - rust-lang#140077 (Construct OutputType using macro and print [=FILENAME] help info)
 - rust-lang#140081 (Update `libc` to 0.2.172)
 - rust-lang#140091 (build_helper: try to rename dir before delete)
 - rust-lang#140107 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
@ChrisDenton
Copy link
Member Author

Hm, this is in a rollup now but I do wonder if this should be reverted if the underlying issue gets fixed. Because this could potentially hide a real issue.

@jieyouxu
Copy link
Member

Hm, this is in a rollup now but I do wonder if this should be reverted if the underlying issue gets fixed. Because this could potentially hide a real issue.

Cancelled the rollup since it's only 1 hour in, let's instead try #140120

@ChrisDenton
Copy link
Member Author

It's safe to close this then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants