Skip to content

Commit ee62d69

Browse files
authored
Don't Use WasmGC Instructions Just Yet (#990)
At some point we had to switch away from `wasm-opt` automatically detecting the WebAssembly features, because they deprecated and turned that into a no-op. Since then we specified that it should just use all the features. This used to work all the time, but with the introduction of reference types it now started optimizing some of those instructions into instructions that are only available with the `WasmGC` proposal. This slipped through because Chrome and Firefox already support `WasmGC` but Safari does not... yet, because they also will start to support it very soon. In the meantime and also to ensure `wasm-opt` isn't ever going to sneak in any unwanted features, we now explicitly specify all the features that we want to use.
1 parent 663f60b commit ee62d69

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,19 @@ jobs:
179179
shell: bash
180180
run: |
181181
WASM_FILE=$(ls ${{ matrix.dist_path }}/*.wasm)
182-
wasm-opt --all-features -O4 "$WASM_FILE" -o "$WASM_FILE"
182+
wasm-opt \
183+
--enable-bulk-memory \
184+
--enable-mutable-globals \
185+
--enable-nontrapping-float-to-int \
186+
--enable-sign-ext \
187+
--enable-simd \
188+
--enable-extended-const \
189+
--enable-multivalue \
190+
--enable-reference-types \
191+
--strip-dwarf \
192+
--strip-producers \
193+
--strip-target-features \
194+
-O4 "$WASM_FILE" -o "$WASM_FILE"
183195
184196
- name: Build (Tauri)
185197
if: matrix.platform == 'tauri'

buildCore.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import fs from "fs";
44
let toolchain = "";
55
let profile = "debug";
66
let cargoFlags = "";
7+
// Keep .github/workflows/ci.yml in sync with these flags, so wasm-opt works.
78
let rustFlags =
8-
"-C target-feature=+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext,+simd128,+extended-const,+multivalue";
9+
"-C target-feature=+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext,+simd128,+extended-const,+multivalue,+reference-types";
910
let wasmBindgenFlags = "--encode-into always --target web --reference-types";
1011
let target = "wasm32-unknown-unknown";
1112
let targetFolder = target;

wasm32-multivalue.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"exe-suffix": ".wasm",
1111
"generate-arange-section": false,
1212
"has-thread-local": true,
13-
"is-builtin": false,
1413
"is-like-wasm": true,
1514
"limit-rdylib-exports": false,
1615
"linker": "rust-lld",

0 commit comments

Comments
 (0)