@@ -37,7 +37,7 @@ disabled.
37
37
38
38
There is a loose coupling between the name of a proposal (often the name of the
39
39
github repository of the proposal) and the feature name LLVM/Rust use. For
40
- example there is the [ ` multi-value `
40
+ example there is the [ multi-value
41
41
proposal] ( https://github.com/webAssembly/multi-value ) but a ` multivalue `
42
42
feature.
43
43
@@ -64,7 +64,8 @@ host-defined GC resource that WebAssembly cannot access but can pass around.
64
64
Rust does not have support for the WebAssembly ` externref ` type and LLVM 19 does
65
65
not change that. WebAssembly modules produced from Rust will continue to not use
66
66
the ` externref ` type nor have a means of being able to do so. This may be
67
- enabled in the future, but it will mostly likely only be done on an opt-in basis
67
+ enabled in the future (e.g. a hypothetical ` core::arch::wasm32::Externref ` type
68
+ or similar), but it will mostly likely only be done on an opt-in basis
68
69
and will not affect preexisting code by default.
69
70
70
71
Also included in the reference-types proposal, however, was the ability to have
@@ -81,7 +82,7 @@ was encoded with a fixed zero byte in its instruction (required to be exactly
81
82
0x00). This fixed zero byte was relaxed to a 32-bit [ LEB] to indicate which
82
83
table the ` call_indirect ` instruction was using. For those unfamiliar [ LEB] is a
83
84
way of encoding multi-byte integers in a smaller number of bytes for smaller
84
- integers. For example the 32-gbit integer 0 can be encoded as ` 0x00 ` with a
85
+ integers. For example the 32-bit integer 0 can be encoded as ` 0x00 ` with a
85
86
[ LEB] . [ LEB] s are flexible to additionally allow "overlong" encodings so the
86
87
integer 0 can additionally be encoded as ` 0x80 0x00 ` .
87
88
@@ -102,7 +103,7 @@ do not support the reference-types proposal. It is expected that this change
102
103
will have a low impact due to the age of the reference-types proposal and
103
104
breadth of implementation in engines. Given the multitude of WebAssembly
104
105
engines, however, it's recommended that any WebAssembly users test out
105
- Nightly Rust and see if the produced module still runs on the engine of
106
+ Nightly Rust and see if the produced module still runs on their engine of
106
107
choice.
107
108
108
109
### LLVM, Rust, and Multiple Tables
@@ -144,9 +145,11 @@ original MVP and has been implemented in many engines for quite some time.
144
145
The consequences of enabling this feature by default in LLVM are more minor for
145
146
Rust, however, than enabling the ` reference-types ` feature by default. LLVM's
146
147
default C ABI for WebAssembly code is not changing even when ` multivalue ` is
147
- enabled. Additionally Rust's ` extern "C" ` ABI is not changing either and
148
- continues to match LLVM's. Despite this though the change has the possibility
149
- of still affecting Nightly users of Rust.
148
+ enabled. Additionally Rust's ` extern "C" ` ABI for WebAssembly is not changing
149
+ either and continues to match LLVM's (or strives to, [ differences to
150
+ LLVM] ( https://github.com/rust-lang/rust/issues/115666 ) are considered bugs to
151
+ fix). Despite this though the change has the possibility of still affecting
152
+ Nightly users of Rust.
150
153
151
154
Rust for some time has supported an ` extern "wasm" ` ABI on Nightly which was an
152
155
experimental means of exposing the ability of defining a function in Rust which
@@ -166,11 +169,11 @@ from suitably motivated contributors.
166
169
167
170
### Aside: ABI Stability and WebAssembly
168
171
169
- While on the topics of ABIs and the ` multi-value ` feature it's perhaps worth
172
+ While on the topic of ABIs and the ` multivalue ` feature it's perhaps worth
170
173
also going over a bit what ABIs mean for WebAssembly. Currently there's
171
174
effectively only one ABI implemented by LLVM and the Rust compiler meaning that
172
175
at the WebAssembly module level ` extern "C" ` and ` extern "Rust" ` are
173
- more-or-less the same. Despite this though there's no need for this to be true .
176
+ more-or-less the same. It is ** not ** guaranteed for the ABIs to match, however .
174
177
175
178
The ` extern "C" ` ABI, what C code uses by default as well, is difficult to
176
179
change because stability is often required across different compiler versions.
@@ -180,12 +183,14 @@ task that requires version fields, explicit markers, etc, to help prevent
180
183
mismatches.
181
184
182
185
The ` extern "Rust" ` ABI, however, is entirely within the control of the Rust
183
- compiler and can change from version to version. Just because it happens to work
184
- like ` extern "C" ` today doesn't mean it will continue to do so in the future. A
185
- great example of this is that when the ` multi-value ` feature is enabled the
186
+ compiler and can change from version to version (there are no stability
187
+ guarantees across compiler versions and this is applicable to all platforms, not
188
+ just WebAssembly). Just because ` extern "Rust" ` happens to work like `extern
189
+ "C"` in WebAssembly today doesn't mean it will continue to do so in the future.
190
+ A great example of this is that when the ` multivalue ` feature is enabled the
186
191
` extern "Rust" ` ABI could be redefined to use the multiple-return-values that
187
- WebAssembly would then support. This would enable much more efficient returns of
188
- values larger than 64-bits. Implementing this would require support in LLVM
192
+ WebAssembly would then support. This would enable much more efficient returns
193
+ of values larger than 64-bits. Implementing this would require support in LLVM
189
194
though which is not currently present.
190
195
191
196
## Enabling Future Proposals to WebAssembly
@@ -226,9 +231,9 @@ For a variety of reasons you might be motivated to disable on-by-default
226
231
WebAssembly features: for example maybe your engine is difficult to update or
227
232
doesn't support a new feature. Disabling on-by-default features is unfortunately
228
233
not the easiest task. It is notably not sufficient to use
229
- ` -Ctarget-features=-foo ` to disable features for just your own project's
234
+ ` -Ctarget-features=-sign-ext ` to disable a feature for just your own project's
230
235
compilation because the Rust standard library, shipped in precompiled form, is
231
- compiled with this features enabled.
236
+ still compiled with the feature enabled.
232
237
233
238
To disable on-by-default WebAssembly proposal it's required that you use Cargo's
234
239
[ ` -Zbuild-std ` ] ( https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std )
0 commit comments