Skip to content

Commit a2aa6d7

Browse files
authored
Merge pull request #426 from dtolnay/enotempty
Allow build-script cleanup failure with NFSv3 output directory to be non-fatal
2 parents 61f28da + f00ebc5 commit a2aa6d7

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
@@ -146,7 +146,16 @@ fn compile_probe(rustc_bootstrap: bool) -> bool {
146146
// file in OUT_DIR, which causes nonreproducible builds in build systems
147147
// that treat the entire OUT_DIR as an artifact.
148148
if let Err(err) = fs::remove_dir_all(&out_subdir) {
149-
if err.kind() != ErrorKind::NotFound {
149+
// libc::ENOTEMPTY
150+
// Some filesystems (NFSv3) have timing issues under load where '.nfs*'
151+
// dummy files can continue to get created for a short period after the
152+
// probe command completes, breaking remove_dir_all.
153+
// To be replaced with ErrorKind::DirectoryNotEmpty (Rust 1.83+).
154+
const ENOTEMPTY: i32 = 39;
155+
156+
if !(err.kind() == ErrorKind::NotFound
157+
|| (cfg!(target_os = "linux") && err.raw_os_error() == Some(ENOTEMPTY)))
158+
{
150159
eprintln!("Failed to clean up {}: {}", out_subdir.display(), err);
151160
process::exit(1);
152161
}

0 commit comments

Comments
 (0)