Skip to content

Commit 82aa3b7

Browse files
committed
build: allow the cleanup step to be non-fatal
3e8962c (Clean up dep-info files from OUT_DIR, 2024-10-22) made the cleanup step a fatal operation when cleanup fails. Some filesystems (e.g. NFS v3) can run into timing issues under load where .nfs* dummy files can still exist for a short window of time after the probe command completes. This window is just large enough for a failure to occur in remove_all(). Add an environment variable that allows users to make the cleanup operation non-fatal.
1 parent fc2ae0f commit 82aa3b7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,14 @@ fn compile_probe(rustc_bootstrap: bool) -> bool {
203203
// Clean up to avoid leaving nondeterministic absolute paths in the dep-info
204204
// file in OUT_DIR, which causes nonreproducible builds in build systems
205205
// that treat the entire OUT_DIR as an artifact.
206+
// Set the PROC_MACRO2_IGNORE_CLEANUP environment variable to make errors from
207+
// the cleanup process non-fatal.
206208
if let Err(err) = fs::remove_dir_all(&out_subdir) {
207209
if err.kind() != ErrorKind::NotFound {
208210
eprintln!("Failed to clean up {}: {}", out_subdir.display(), err);
209-
process::exit(1);
211+
if env::var_os("PROC_MACRO2_IGNORE_CLEANUP").is_none() {
212+
process::exit(1);
213+
}
210214
}
211215
}
212216

0 commit comments

Comments
 (0)