You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[WASM] fix unconditional SIMD inclusion in WASM binary (#16)
### Context
I made a mistake using `#[target_feature(enable = "simd128")]` because it means the enclosed code is compiled using the simd128 feature flag. This can result in binaries containing SIMD. Even if the SIMD is never executed, older browsers may fail to validate the WASM binary if it includes SIMD instructions.
Thus, this PR removes all usages of target_feature for WASM, instead opting into conditional compilation.
### Test plan
This really needs an automated test, but I haven't found a good way to test this yet.
I manually tested by running the following command:
```
cargo build --example srgb --target=wasm32-unknown-unknown && wasm2wat ./target/wasm32-unknown-unknown/debug/examples/srgb.wasm | grep -q v128 && echo "SIMD FOUND" || echo "NO SIMD"
```
Now returns `NO SIMD` , when previously it returned `SIMD FOUND`.
```
RUSTFLAGS=-Ctarget-feature=+simd128 cargo build --example srgb --target=wasm32-unknown-unknown && wasm2wat ./target/wasm32-unknown-unknown/debug/examples/srgb.wasm | grep -q v128 && echo "SIMD FOUND" || echo "NO SIMD"
```
Returns `SIMD FOUND` because the `+simd128` feature was requested.
0 commit comments