Files
simple-rust-tests/__wasm/wasi/README.md
2020-10-17 11:47:07 +08:00

43 lines
798 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Prepare:
```shell
rustup target add wasm32-wasi
```
Compile:
```shell
cargo build --target=wasm32-wasi
```
```shell
$ ls target/
debug wasm32-wasi
```
运行时Runtime
> 运行这个文件需要一个运行时Runtime。你也可以把这个理解成一个“容器”“虚拟机”什么的都行。但是准确的叫法是运行时。
> 目前常见的运行时有 wasmtimewasmer 等。
> 我们这次用 wasmtime 来运行吧。
`curl https://wasmtime.dev/install.sh -sSf | bash`
or download from:
https://github.com/bytecodealliance/wasmtime/releases
Run:
```
$ wasmtime --dir=. target/wasm32-wasi/debug/wasi.wasm
Hello, world!
```
<br>
Reference:
https://mp.weixin.qq.com/s/VYkUvD1NpRdx_qoIdCCq8w - _【Rust每周一知】Rust, wasm, wasi 试玩儿_