Skip to content

grep: allow wasm32-wasip1 cargo check#53

Open
wondr-wclabs wants to merge 1 commit into
uutils:mainfrom
wondr-wclabs:codex/wasm32-wasip1-check
Open

grep: allow wasm32-wasip1 cargo check#53
wondr-wclabs wants to merge 1 commit into
uutils:mainfrom
wondr-wclabs:codex/wasm32-wasip1-check

Conversation

@wondr-wclabs

Copy link
Copy Markdown
Contributor

Fixes #20.

onig_sys builds bundled C sources, so cargo check --target wasm32-wasip1 currently fails unless the caller also provides a C WASI sysroot. That makes the Rust target check depend on external C toolchain setup before the uu_grep crate itself is checked.

This PR target-gates the Oniguruma dependencies away from WASI builds and adds a small WASI matcher fallback for ASCII literal patterns. I kept the fallback intentionally narrow: non-WASI builds keep the existing Oniguruma behavior, while WASI builds return an explicit error for regex features that would require Oniguruma. Pulling in a different pure-Rust regex engine for WASI would make the command compile, but it would also create a second regex semantics path for BRE/ERE/PCRE behavior, which seems worse than failing clearly for unsupported cases.

I also added a CI job that runs the issue reproducer command directly: cargo check --target wasm32-wasip1.

Checked locally: cargo fmt --all -- --check, cargo check, cargo test, cargo clippy --all-targets --workspace -puu_grep -- -D warnings, cargo check --target wasm32-wasip1, and cargo clippy --target wasm32-wasip1 --workspace -puu_grep -- -D warnings. I also tried cargo test --target wasm32-wasip1 --no-run; that currently stops in the dev-dependency stack because socket2 does not support the target, so I left this PR scoped to the reported cargo check failure.

@codspeed-hq

codspeed-hq Bot commented Jun 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks
⏩ 17 skipped benchmarks1


Comparing wondr-wclabs:codex/wasm32-wasip1-check (740b302) with main (d28bf76)

Open in CodSpeed

Footnotes

  1. 17 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@oech3

oech3 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Can we build oniguruma for wasip1? or remove oniguruma from all platforms for simplicity?

@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for tackling this! I'd rather not drop Oniguruma on WASI - it forks the matcher and loses -i, BRE/ERE/PCRE, etc.

We don't need to: the uutils playground already builds grep for wasm32-wasip1 with full Oniguruma by providing a WASI sysroot. So to @oech3's question - yes, we can build oniguruma for wasip1, and we already do in production.

Could you redo it that way? Drop the Cargo.toml gating and the second CompiledPattern/is_word_match, keep the single Oniguruma path, and have the CI job set up a WASI SDK sysroot before cargo check, like uutils.github.io's website.yml:

WASI_SDK_DIR="wasi-sdk-25.0-x86_64-linux"
curl -sL "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/${WASI_SDK_DIR}.tar.gz" | tar xz
export WASI_SDK_PATH="$PWD/${WASI_SDK_DIR}"
export CC_wasm32_wasip1="$WASI_SDK_PATH/bin/clang"
export CFLAGS_wasm32_wasip1="--sysroot=$WASI_SDK_PATH/share/wasi-sysroot"
cargo check --target wasm32-wasip1

That keeps one matcher, real regex on WASI, and a green check. Thanks!

@oech3

oech3 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Can we enable expr.wasm on uutils/coreutils by same way?

@sylvestre

Copy link
Copy Markdown
Contributor

probably, yes
do you want to give it a try ?

@oech3

oech3 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Yes

@oech3

oech3 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo check for wasm32-wasip1 fails

3 participants