From d335d802f117f5e20f6d043b8521a9bfaab0a1c7 Mon Sep 17 00:00:00 2001 From: Josiah Savary Date: Thu, 9 May 2024 10:02:14 -0400 Subject: [PATCH 1/8] Don't throw compiler error for wasm targets --- src/parallel/stderr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parallel/stderr.rs b/src/parallel/stderr.rs index 47fa085db..61426ecfe 100644 --- a/src/parallel/stderr.rs +++ b/src/parallel/stderr.rs @@ -3,7 +3,7 @@ use std::{convert::TryInto, process::ChildStderr}; use crate::{Error, ErrorKind}; -#[cfg(all(not(unix), not(windows)))] +#[cfg(all(not(unix), not(windows), not(target_family = "wasm"))] compile_error!("Only unix and windows support non-blocking pipes! For other OSes, disable the parallel feature."); #[cfg(unix)] From f4a33de67fe2d2bdc8ab92e2223341b8061a96a3 Mon Sep 17 00:00:00 2001 From: Josiah Savary Date: Thu, 9 May 2024 10:04:35 -0400 Subject: [PATCH 2/8] Don't throw compiler error for wasm targets --- src/tempfile.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tempfile.rs b/src/tempfile.rs index ab0ac8774..4e929e50f 100644 --- a/src/tempfile.rs +++ b/src/tempfile.rs @@ -6,7 +6,7 @@ use std::{ path::{Path, PathBuf}, }; -#[cfg(not(any(unix, target_os = "wasi", windows)))] +#[cfg(not(any(unix, target_family = "wasm", windows)))] compile_error!("Your system is not supported since cc cannot create named tempfile"); fn rand() -> u64 { From c0a26250790a012c9e4fa2fb595a95240b24b8d0 Mon Sep 17 00:00:00 2001 From: Josiah Savary Date: Thu, 9 May 2024 10:06:58 -0400 Subject: [PATCH 3/8] Fix attr syntax error --- src/parallel/stderr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parallel/stderr.rs b/src/parallel/stderr.rs index 61426ecfe..081a4f49c 100644 --- a/src/parallel/stderr.rs +++ b/src/parallel/stderr.rs @@ -3,7 +3,7 @@ use std::{convert::TryInto, process::ChildStderr}; use crate::{Error, ErrorKind}; -#[cfg(all(not(unix), not(windows), not(target_family = "wasm"))] +#[cfg(all(not(unix), not(windows), not(target_family = "wasm")))] compile_error!("Only unix and windows support non-blocking pipes! For other OSes, disable the parallel feature."); #[cfg(unix)] From f579fca8e6ec892205e1ff002a020bb2f480989f Mon Sep 17 00:00:00 2001 From: Josiah Savary Date: Thu, 9 May 2024 10:11:00 -0400 Subject: [PATCH 4/8] Add unimplemented path for pipe error match for wasm target --- src/command_helpers.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/command_helpers.rs b/src/command_helpers.rs index fe919a523..bbb47818a 100644 --- a/src/command_helpers.rs +++ b/src/command_helpers.rs @@ -130,6 +130,8 @@ impl StderrForwarder { self.bytes_available_failed = true; MIN_BUFFER_CAPACITY } + #[cfg(target_family = "wasm")] + Err(_) => unimplemented!(), Ok(bytes_available) => MIN_BUFFER_CAPACITY.max(bytes_available), } } else { From 8f4076fe37773616fddc27e623bf3afe4b69c6bc Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sun, 14 Jul 2024 22:43:07 +1000 Subject: [PATCH 5/8] Replace `unimplemented!` with `panic!` Signed-off-by: Jiahao XU --- src/command_helpers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command_helpers.rs b/src/command_helpers.rs index bbb47818a..3dec293cb 100644 --- a/src/command_helpers.rs +++ b/src/command_helpers.rs @@ -131,7 +131,7 @@ impl StderrForwarder { MIN_BUFFER_CAPACITY } #[cfg(target_family = "wasm")] - Err(_) => unimplemented!(), + Err(_) => panic!("bytes_available should always succeed on wasm"), Ok(bytes_available) => MIN_BUFFER_CAPACITY.max(bytes_available), } } else { From 49a5dab778bddd72b37d63f41de63bae10251988 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sun, 14 Jul 2024 22:46:42 +1000 Subject: [PATCH 6/8] Add CI check for wasm Signed-off-by: Jiahao XU --- .github/workflows/main.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09346a57a..5774c30c6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -171,6 +171,23 @@ jobs: - run: cargo test -Z build-std=std ${{ matrix.no_run }} --workspace --target ${{ matrix.target }} --release - run: cargo test -Z build-std=std ${{ matrix.no_run }} --workspace --target ${{ matrix.target }} --features parallel + check-wasm: + name: Test build-std + runs-on: ubuntu-latest + strategy: + matrix: + target: [wasm32-unknown-unknown] + steps: + - uses: actions/checkout@v4 + - name: Install Rust (rustup) + run: | + rustup target add ${{ matrix.target }} + shell: bash + - uses: Swatinem/rust-cache@v2 + - run: cargo test -Z build-std=std --run-run --workspace --target ${{ matrix.target }} + - run: cargo test -Z build-std=std --run-run --workspace --target ${{ matrix.target }} --release + - run: cargo test -Z build-std=std --run-run --workspace --target ${{ matrix.target }} --features parallel + cuda: name: Test CUDA support runs-on: ubuntu-20.04 From 213e44ec12771cc52e110eee12eb3e9b32fa18df Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sun, 14 Jul 2024 22:48:14 +1000 Subject: [PATCH 7/8] Fix CI Signed-off-by: Jiahao XU --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5774c30c6..8d2a30e3f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -172,7 +172,7 @@ jobs: - run: cargo test -Z build-std=std ${{ matrix.no_run }} --workspace --target ${{ matrix.target }} --features parallel check-wasm: - name: Test build-std + name: Test wasm runs-on: ubuntu-latest strategy: matrix: @@ -184,9 +184,9 @@ jobs: rustup target add ${{ matrix.target }} shell: bash - uses: Swatinem/rust-cache@v2 - - run: cargo test -Z build-std=std --run-run --workspace --target ${{ matrix.target }} - - run: cargo test -Z build-std=std --run-run --workspace --target ${{ matrix.target }} --release - - run: cargo test -Z build-std=std --run-run --workspace --target ${{ matrix.target }} --features parallel + - run: cargo test --no-run --target ${{ matrix.target }} + - run: cargo test --no-run --target ${{ matrix.target }} --release + - run: cargo test --no-run --target ${{ matrix.target }} --features parallel cuda: name: Test CUDA support From 20bb6cb9b5ae9410574e789ffb7b4ba27d701936 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sun, 14 Jul 2024 22:52:41 +1000 Subject: [PATCH 8/8] Fix clippy warning on wasm Signed-off-by: Jiahao XU --- src/parallel/stderr.rs | 1 + src/tempfile.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/parallel/stderr.rs b/src/parallel/stderr.rs index 081a4f49c..701868609 100644 --- a/src/parallel/stderr.rs +++ b/src/parallel/stderr.rs @@ -1,3 +1,4 @@ +#![cfg_attr(target_family = "wasm", allow(unused))] /// Helpers functions for [ChildStderr]. use std::{convert::TryInto, process::ChildStderr}; diff --git a/src/tempfile.rs b/src/tempfile.rs index 4e929e50f..a0d19d58d 100644 --- a/src/tempfile.rs +++ b/src/tempfile.rs @@ -1,3 +1,5 @@ +#![cfg_attr(target_family = "wasm", allow(unused))] + use std::{ collections::hash_map::RandomState, fs::{remove_file, File, OpenOptions},