Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial wasm32-wasi support #416

Merged
merged 4 commits into from
Oct 15, 2022

Conversation

konstin
Copy link
Member

@konstin konstin commented Oct 13, 2022

I'm currently experimenting whether it's feasible to make wasm32-wasi wheels. This is also the groundwork needed to make a web version of ruff, which might the more interesting use case.

Debug fails in wasmtime with "too many locals: locals exceed maximum", so release only atm.

Usage:

Either

cargo build --target wasm32-wasi --release --no-default-features
wasmtime run --dir . ~/ruff/target/wasm32-wasi/release/ruff.wasm .

or with latest main maturin

maturin build --target wasm32-wasi --release --strip --no-default-features
pip install target/wheels/ruff-0.0.69-py3-none-any.whl
ruff . # Currenly limit to . due to wasi isolation

I hope that magiclen/path-absolutize#12 lands soon so i can switch back to crates.io path-absolutize before this gets merged

This is also the groundwork needed to make a web version of ruff

debug fails in wasmtime with "too many locals: locals exceed maximum", so release only atm.

Usage:

Either

```
cargo build --target wasm32-wasi --release --no-default-features
wasmtime run --dir . ~/ruff/target/wasm32-wasi/release/ruff.wasm .
```

or with latest main maturin:

```
maturin build --target wasm32-wasi --release --strip --no-default-features
pip install target/wheels/ruff-0.0.69-py3-none-any.whl
ruff . # Currenly limit to . due to wasi isolation
```
@charliermarsh
Copy link
Member

This is awesome. I did basic wasm32-wasi compilation on a few branches (charlie/wasm plus some local vendor-specific branches like charlie/workers) to power some of my Wasm explorations, but this is light-years better. Will review in-full + test when I get home later today.

@@ -1,10 +1,17 @@
// cacache uses asyncd-std which has no wasm support, so currently no caching support on wasm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we instead (or in addition) avoid calling into cache at all when target_family = "wasm"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done; i'd keep compiling cache.rs on wasm though because caching there should be possible (either in cwd like pytest or to some extent in local storage), it's just cacache that is inactive and hasn't completed tokio support (zkat/cacache-rs#29)

Cargo.toml Outdated Show resolved Hide resolved
@konstin
Copy link
Member Author

konstin commented Oct 14, 2022

The charlie/wasm looks good already, i'd definitely keep the whole frontend setup. i've also added cargo settings so that cargo check --target wasm32-unknown-unknown passes, but i haven't checked with wasm-pack.

@charliermarsh charliermarsh merged commit bb466bc into astral-sh:main Oct 15, 2022
@konstin konstin deleted the initial-wasi-support branch October 15, 2022 08:45
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.

2 participants