-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
WebAssembly platform requirements are not well documented #119811
Comments
In principle Rust can produce binaries that only target the core subset of wasm 1.0 just fine. You do need to set some additional options with But point taken, https://doc.rust-lang.org/nightly/rustc/platform-support.html is missing dedicated pages on the wasm target that could contain this information. |
The 2nd sentence right after the one you quoted outlines exactly what you need to do to take advantage of rustc’s capability to emit outputs to the wasm 1.0 spec (or any superset of it:)
Make sure to do this and report back if you're still seeing the unexpected instructions/types/other entities after rustc is told to produce wasm binaries the way you need them to be.
AFAIK, not for WASM. |
Sorry, I realized I misunderstood your answer and deleted my post while you were answering it. Do you know how to show which features are enabled by default for a given target? I searched and did not find. I'm trying to discover whether |
Hm, I'm actually not sure why you might be seeing simd128 in your modules. As far as I can tell it is not enabled by default for any wasm target. In order to print out features used you should look for
For what it is worth I’ve been using this exact target at my $DAYJOB with a pretty primitive runtime and it has been working largely OOB if my memory serves me right. So it indeed could have something to do with your dependencies possibly using something like |
It seems that the memchr package was built with
What I am not sure is whether 1. this was integrated with the standard library and then imported indirectly to my project, or 2. somehow one of the dependency managed to enable it by itself. I tend to favor 1 but I'm not sure. That is why it would be great for such things to be documented :-) |
For reference, I asked on the user forum about how the std lib is built. |
@nagisa I confirm that as of version 1.75, the standard library is not using any WebAssembly SIMD instructions. Here is my test: for file in $HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/*; do
ar -x "$file"
done
for file in *.o; do
if wasm-objdump -d "$file" | grep -q 'v128'; then
echo "$file"
fi
done which shows nothing, so they get pulled in by the memchr package through some of my dependencies. |
You yourself pointed out which crate produces the v128 types: |
I fully agree and I just opened an issue there: BurntSushi/memchr#144 |
As a heads up I've proposed that #128511 close this issue with documentation of how to target MVP wasm. |
…jieyouxu Document WebAssembly target feature expectations This commit is a result of the discussion on rust-lang#128475 and incorporates parts of rust-lang#109807 as well. This is all done as a new page of documentation for the `wasm32-unknown-unknown` target which previously did not exist. This new page goes into details about the preexisting target and additionally documents the expectations for WebAssembly features and code generation. The tl;dr is that LLVM will enable features over time after most engines have had support for awhile. Compiling without features requires `-Ctarget-cpu=mvp` to rustc plus `-Zbuild-std` to Cargo. Closes rust-lang#109807 Closes rust-lang#119811 Closes rust-lang#128475
…jieyouxu Document WebAssembly target feature expectations This commit is a result of the discussion on rust-lang#128475 and incorporates parts of rust-lang#109807 as well. This is all done as a new page of documentation for the `wasm32-unknown-unknown` target which previously did not exist. This new page goes into details about the preexisting target and additionally documents the expectations for WebAssembly features and code generation. The tl;dr is that LLVM will enable features over time after most engines have had support for awhile. Compiling without features requires `-Ctarget-cpu=mvp` to rustc plus `-Zbuild-std` to Cargo. Closes rust-lang#109807 Closes rust-lang#119811 Closes rust-lang#128475
…jieyouxu Document WebAssembly target feature expectations This commit is a result of the discussion on rust-lang#128475 and incorporates parts of rust-lang#109807 as well. This is all done as a new page of documentation for the `wasm32-unknown-unknown` target which previously did not exist. This new page goes into details about the preexisting target and additionally documents the expectations for WebAssembly features and code generation. The tl;dr is that LLVM will enable features over time after most engines have had support for awhile. Compiling without features requires `-Ctarget-cpu=mvp` to rustc plus `-Zbuild-std` to Cargo. Closes rust-lang#109807 Closes rust-lang#119811 Closes rust-lang#128475
…jieyouxu Document WebAssembly target feature expectations This commit is a result of the discussion on rust-lang#128475 and incorporates parts of rust-lang#109807 as well. This is all done as a new page of documentation for the `wasm32-unknown-unknown` target which previously did not exist. This new page goes into details about the preexisting target and additionally documents the expectations for WebAssembly features and code generation. The tl;dr is that LLVM will enable features over time after most engines have had support for awhile. Compiling without features requires `-Ctarget-cpu=mvp` to rustc plus `-Zbuild-std` to Cargo. Closes rust-lang#109807 Closes rust-lang#119811 Closes rust-lang#128475
Rollup merge of rust-lang#128511 - alexcrichton:doc-wasm-features, r=jieyouxu Document WebAssembly target feature expectations This commit is a result of the discussion on rust-lang#128475 and incorporates parts of rust-lang#109807 as well. This is all done as a new page of documentation for the `wasm32-unknown-unknown` target which previously did not exist. This new page goes into details about the preexisting target and additionally documents the expectations for WebAssembly features and code generation. The tl;dr is that LLVM will enable features over time after most engines have had support for awhile. Compiling without features requires `-Ctarget-cpu=mvp` to rustc plus `-Zbuild-std` to Cargo. Closes rust-lang#109807 Closes rust-lang#119811 Closes rust-lang#128475
Location
README.md and WebAssembly book (https://rustwasm.github.io/docs/book/)
Summary
In version 1.70 Rust added some requirements for WebAssembly targets. This makes Wasm binaries compiled with Rust (at least with default options/out of the box std) incompatible with older runtime environments, in particular not-so-old iOS safari (https://webassembly.org/features/). Here is for example the support for Safari iOS 15.5 simulator:
I searched but did not find any place where these requirements are written down. I think that this is a problem.
The text was updated successfully, but these errors were encountered: