Skip to content

Commit 8cf66f7

Browse files
committed
Allow build-script cleanup failure with NFSv3 output directory to be non-fatal
1 parent f5e145c commit 8cf66f7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

build.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,16 @@ fn compile_probe(rustc_bootstrap: bool) -> bool {
185185
// file in OUT_DIR, which causes nonreproducible builds in build systems
186186
// that treat the entire OUT_DIR as an artifact.
187187
if let Err(err) = fs::remove_dir_all(&out_subdir) {
188-
if err.kind() != ErrorKind::NotFound {
188+
// libc::ENOTEMPTY
189+
// Some filesystems (NFSv3) have timing issues under load where '.nfs*'
190+
// dummy files can continue to get created for a short period after the
191+
// probe command completes, breaking remove_dir_all.
192+
// To be replaced with ErrorKind::DirectoryNotEmpty (Rust 1.83+).
193+
const ENOTEMPTY: i32 = 39;
194+
195+
if !(err.kind() == ErrorKind::NotFound
196+
|| (cfg!(target_os = "linux") && err.raw_os_error() == Some(ENOTEMPTY)))
197+
{
189198
eprintln!("Failed to clean up {}: {}", out_subdir.display(), err);
190199
process::exit(1);
191200
}

0 commit comments

Comments
 (0)