Skip to content

Commit b0f6ead

Browse files
authored
refactor: use wasm-runner (#397)
1 parent 3c78547 commit b0f6ead

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

.cargo/config.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
[target.wasm32-wasip1]
2+
rustflags = [
3+
"-C",
4+
"target-feature=+atomics,+bulk-memory,+mutable-globals,+simd128",
5+
"-C",
6+
"link-arg=--max-memory=4294967296",
7+
]
8+
runner = "scripts/wasm-runner.sh"
9+
110
[target.wasm32-wasip1-threads]
211
rustflags = [
312
"-C",
413
"target-feature=+atomics,+bulk-memory,+mutable-globals,+simd128",
514
"-C",
615
"link-arg=--max-memory=4294967296",
716
]
8-
runner = "wasmtime --wasi threads"
17+
runner = "scripts/wasm-runner.sh"

scripts/wasm-runner.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ -z "${WASM_HARNESS_ENV_RAYON_NUM_THREADS:-}" ]; then
5+
if command -v nproc >/dev/null 2>&1; then
6+
cores=$(nproc)
7+
elif command -v sysctl >/dev/null 2>&1; then
8+
cores=$(sysctl -n hw.ncpu)
9+
else
10+
cores=1
11+
fi
12+
export WASM_HARNESS_ENV_RAYON_NUM_THREADS=$cores
13+
fi
14+
15+
exec wasm-harness "$@"

0 commit comments

Comments
 (0)