File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
src/doc/rustc/src/platform-support Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -155,3 +155,36 @@ You'll need to consult your WebAssembly engine's documentation to learn more
155155about the supported WebAssembly features the engine has.
156156
157157[ reference ] : https://doc.rust-lang.org/reference/attributes/codegen.html#wasm32-or-wasm64
158+
159+ Note that it is still possible for Rust crates and libraries to enable
160+ WebAssembly features on a per-function level. This means that the build
161+ command above may not be sufficent to disable all WebAssembly features. If the
162+ final binary still has SIMD instructions, for example, the function in question
163+ will need to be found and the crate in question will likely contain something
164+ like:
165+
166+ ``` rust
167+ #[target_feature(enable = " simd128" )]
168+ fn foo () {
169+ // ...
170+ }
171+ ```
172+
173+ In this situation there is no compiler flag to disable emission of SIMD
174+ instructions and the crate must instead be modified to not include this function
175+ at compile time either by default or through a Cargo feature. For crate authors
176+ it's recommended to avoid ` #[target_feature(enable = "...")] ` except where
177+ necessary and instead use:
178+
179+ ``` rust
180+ #[cfg(target_feature = " simd128" )]
181+ fn foo () {
182+ // ...
183+ }
184+ ```
185+
186+ That is to say instead of enabling target features it's recommended to
187+ conditionally compile code instead. This is notably different to the way native
188+ platforms such as x86\_ 64 work, and this is due to the fact that WebAssembly
189+ binaries must only contain code the engine understands. Native binaries work so
190+ long as the CPU doesn't execute unknown code dynamically at runtime.
You can’t perform that action at this time.
0 commit comments