Skip to content

Commit

Permalink
Don't store build check rmeta (#1200)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
nmattia authored Oct 29, 2024
1 parent 7d4a719 commit cf68714
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ fn has_feature(feature: &str) -> bool {
fn can_compile<T: AsRef<str>>(test: T) -> bool {
use std::process::Stdio;

let out_dir = var("OUT_DIR").unwrap();
let rustc = var("RUSTC").unwrap();
let target = var("TARGET").unwrap();

Expand All @@ -229,8 +228,9 @@ fn can_compile<T: AsRef<str>>(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") {
Expand Down

0 comments on commit cf68714

Please sign in to comment.