From cf687140815903bb8aedafe021934f64bb987fb9 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Tue, 29 Oct 2024 16:01:10 +0100 Subject: [PATCH] Don't store build check rmeta (#1200) This ensures the `.rmeta` files generated by `can_compile` are not written to the build output. Those metadata files can create determinism and cache invalidation issues in some build systems. Instead the output -- since it is never actually read -- is written to `/dev/null`. --- build.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index cac0aeb36..5b92f070b 100644 --- a/build.rs +++ b/build.rs @@ -205,7 +205,6 @@ fn has_feature(feature: &str) -> bool { fn can_compile>(test: T) -> bool { use std::process::Stdio; - let out_dir = var("OUT_DIR").unwrap(); let rustc = var("RUSTC").unwrap(); let target = var("TARGET").unwrap(); @@ -229,8 +228,9 @@ fn can_compile>(test: T) -> bool { .arg("--emit=metadata") // Do as little as possible but still parse. .arg("--target") .arg(target) - .arg("--out-dir") - .arg(out_dir); // Put the output somewhere inconsequential. + .arg("-o") + .arg("-") + .stdout(Stdio::null()); // We don't care about the output (only whether it builds or not) // If Cargo wants to set RUSTFLAGS, use that. if let Ok(rustflags) = var("CARGO_ENCODED_RUSTFLAGS") {