Skip to content

Commit 87c9624

Browse files
committed
fix(build): enable WASM features in wasm-opt optimization
ONNX Runtime builds WASM with bulk memory and non-trapping float-to-int operations, but wasm-opt was running without these features enabled, causing validation errors. **Error:** ``` [wasm-validator error] memory.copy operations require bulk memory operations [--enable-bulk-memory-opt] [wasm-validator error] all used features should be allowed (i32.trunc_sat_f64_s requires nontrapping-float-to-int) ``` **Fix:** Add required feature flags to wasm-opt invocation: - --enable-bulk-memory (for memory.copy, memory.fill) - --enable-nontrapping-float-to-int (for i32.trunc_sat_*) - --enable-sign-ext (for sign extension operations) These are standard modern WASM features that ONNX Runtime uses for better performance.
1 parent e054ef0 commit 87c9624

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/build-infra/lib/emscripten-builder.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,15 @@ export class EmscriptenBuilder {
112112

113113
const result = await spawn(
114114
wasmOptCmd,
115-
[`-O${optimizeLevel}`, '-s', shrinkLevel.toString(), wasmPath, '-o', wasmPath],
115+
[
116+
`-O${optimizeLevel}`,
117+
'-s', shrinkLevel.toString(),
118+
'--enable-bulk-memory',
119+
'--enable-nontrapping-float-to-int',
120+
'--enable-sign-ext',
121+
wasmPath,
122+
'-o', wasmPath
123+
],
116124
{ shell: WIN32, stdio: 'inherit' }
117125
)
118126
if (result.code !== 0) {

0 commit comments

Comments
 (0)