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

require 'simd128' on 'wasm32' #149

Merged
merged 2 commits into from
Mar 27, 2024
Merged

require 'simd128' on 'wasm32' #149

merged 2 commits into from
Mar 27, 2024

Conversation

BurntSushi
Copy link
Owner

It turns out that providing routines with #[target_feature(enable = "simd128")] on wasm32 can fail in some older browsers. The specific
problem is not totally clear to me, but it is straight-forward enough
to fix (I hope) by just requiring that simd128 be enabled at compile
time in order to include the wasm32 SIMD modules in this crate.

This would not be a great solution if WASM supported runtime CPU
feature detection. And the status quo is that simd128 has to be
enabled at compile time anyway for the SIMD code to take effect. So
this shouldn't cause any regressions and is likely something we can do
long term as well. We can re-evaluate once and if WASM gets support for
runtime CPU feature detection.

We also add a CI test for wasm32 without the simd128 target
feature enabled.

Fixes #144

It turns out that providing routines with `#[target_feature(enable =
"simd128")]` on `wasm32` can fail in some older browsers. The specific
problem is not totally clear to me, but it is straight-forward enough to
fix (I hope) by just requiring that `simd128` be enabled at compile time
in order to include the `wasm32` SIMD modules in this crate.

This would not be a great solution if WASM supported runtime CPU feature
detection. And the status quo is that `simd128` has to be enabled at
compile time anyway for the SIMD code to take effect. So this shouldn't
cause any regressions and is likely something we can do long term as
well. We can re-evaluate once and if WASM gets support for runtime CPU
feature detection.

We also add a CI test for `wasm32` *without* the `simd128` target
feature enabled.

Fixes #144
@BurntSushi BurntSushi merged commit 1e4b8a8 into master Mar 27, 2024
17 checks passed
@BurntSushi BurntSushi deleted the ag/fix-wasm branch March 27, 2024 20:34
@BurntSushi
Copy link
Owner Author

This PR is in memchr 2.7.2 on crates.io.

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.

The force-enabling of SIMD128 feature can lead to unloadable WASMs in some browsers
1 participant