WebAssembly / wasi-libc

WASI libc implementation for WebAssembly
https://wasi.dev
Other
862 stars 203 forks source link

help how to disable feature for example( bulk memory)? #312

Closed hunjixin closed 11 months ago

sbc100 commented 2 years ago

Bulk memory is enabled in Makefile here: https://github.com/WebAssembly/wasi-libc/blob/6575e7d84899d282f73d36c1b1f18810502145e3/Makefile#L400-L403.

You would need to edit the Makefile to turn it off.

We are about to enable bulk memory in llvm by default. Can I ask what engine you are targeting that doesn't support it?

balbifm commented 12 months ago

@sbc100 Sorry to revive an old issue, but do you know if there is a way of disabling bulk memory when compiling from Rust? Have tried RUSTFLAGS='-C target-cpu=mvp -C target-feature=-bulk-memory' cargo build --release --target=wasm32-wasi but does not seem to work.

jedisct1 commented 12 months ago

Use cargo-zigbuild:

cargo zigbuild --target=wasm32-wasi --release

The built-in wasi-libc is always recompiled according for the target CPU and flags. By default, this is baseline, that doesn't enable any extension, including bulk-memory.

If you want to get an optimized build for another runtime by enabling flags (that will also apply to wasi-libc), you can do it:

export CFLAGS="-mcpu=baseline+bulk_memory+atomics+simd128+relaxed_simd"
cargo zigbuild --target=wasm32-wasi --release