From 0e55fc847224e7581fef6c5234fc8b5f88a8b5f9 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 21 Nov 2024 16:48:39 -0800 Subject: [PATCH 1/2] Don't store build check rmeta 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`. This is a port of bytecodealliance/rustix#1200 to cap-std. --- build.rs | 6 +++--- cap-async-std/build.rs | 6 +++--- cap-fs-ext/build.rs | 6 +++--- cap-primitives/build.rs | 6 +++--- cap-std/build.rs | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build.rs b/build.rs index 1e6e41c5..65ce304d 100644 --- a/build.rs +++ b/build.rs @@ -48,7 +48,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(); @@ -72,8 +71,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") { diff --git a/cap-async-std/build.rs b/cap-async-std/build.rs index 3706ce13..434559ec 100644 --- a/cap-async-std/build.rs +++ b/cap-async-std/build.rs @@ -35,7 +35,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(); @@ -59,8 +58,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") { diff --git a/cap-fs-ext/build.rs b/cap-fs-ext/build.rs index b8ccb4dd..1716d753 100644 --- a/cap-fs-ext/build.rs +++ b/cap-fs-ext/build.rs @@ -32,7 +32,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(); @@ -56,8 +55,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") { diff --git a/cap-primitives/build.rs b/cap-primitives/build.rs index b92c0bce..8bab65a3 100644 --- a/cap-primitives/build.rs +++ b/cap-primitives/build.rs @@ -42,7 +42,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(); @@ -66,8 +65,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") { diff --git a/cap-std/build.rs b/cap-std/build.rs index 0004c698..f3afe13c 100644 --- a/cap-std/build.rs +++ b/cap-std/build.rs @@ -37,7 +37,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(); @@ -61,8 +60,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") { From 480be76530257515975544c22b1d1d8b101fe441 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 21 Nov 2024 16:53:40 -0800 Subject: [PATCH 2/2] Update CI for wasm32-wasip1. --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 398a941c..5fe6b4e4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -150,7 +150,7 @@ jobs: riscv64gc-unknown-linux-gnu arm-unknown-linux-gnueabihf aarch64-linux-android - wasm32-wasi + wasm32-wasip1 - run: cargo check --workspace --all-targets --all-features --release -vv - run: cargo check --workspace --all-targets --all-features --release -vv --target=x86_64-unknown-linux-musl - run: cargo check --workspace --all-targets --all-features --release -vv --target=x86_64-unknown-linux-gnux32 @@ -164,7 +164,7 @@ jobs: - run: cargo check --workspace --all-targets --all-features --release -vv --target=riscv64gc-unknown-linux-gnu - run: cargo check --workspace --all-targets --all-features --release -vv --target=arm-unknown-linux-gnueabihf - run: cargo check --workspace --all-targets --all-features --release -vv --target=aarch64-linux-android - - run: cd cap-std && cargo check --features=fs_utf8 --release -vv --target=wasm32-wasi + - run: cd cap-std && cargo check --features=fs_utf8 --release -vv --target=wasm32-wasip1 check_cross_nightly_windows: name: Check Cross-Compilation on Rust nightly on Windows