[BUG] after upgrade rust 1.84.0, workers-rs use wasm-opt will can't compile.
Is there an existing issue for this?
- [x] I have searched the existing issues
What version of workers-rs are you using?
0.5.0
What version of wrangler are you using?
4.14.1
Describe the bug
(i32.const 48)
)
[wasm-validator error in function 268] unexpected false: Bulk memory operations require bulk memory [--enable-bulk-memory], on
(memory.copy
(i32.add
(local.get $2)
(i32.const 52)
)
(i32.add
(local.get $30)
(i32.const -164)
)
(i32.const 164)
)
... 1000lines
[wasm-validator error in function 3761] unexpected false: Bulk memory operations require bulk memory [--enable-bulk-memory], on
(memory.copy
(local.get $0)
(local.get $1)
(i32.const 80)
)
Fatal: error validating input
Error: failed to execute `wasm-opt`: exited with exit code: 1
full command: "E:\\source\\runtime\\rust\\cargo\\bin\\wasm-opt.exe" "E:\\source\\cargo\\build\\index_bg.wasm" "-o" "E:\\source\\cargo\\build\\index_bg.wasm-opt.wasm" "-O"
To disable `wasm-opt`, add `wasm-opt = false` to your package metadata in your `Cargo.toml`.
Caused by: failed to execute `wasm-opt`: exited with exit code: 1
full command: "E:\\source\\runtime\\rust\\cargo\\bin\\wasm-opt.exe" "E:\\source\\cargo\\build\\index_bg.wasm" "-o" "E:\\source\\cargo\\build\\index_bg.wasm-opt.wasm" "-O"
To disable `wasm-opt`, add `wasm-opt = false` to your package metadata in your `Cargo.toml`.
Error: wasm-pack exited with status exit code: 1
Steps To Reproduce
No response
anyway customize wasm-opt command?
interim solution
[package.metadata.wasm-pack.profile.release] wasm-opt = false
try put this in your Cargo.toml file:
wasm-opt-features = ["--enable-nontrapping-float-to-int", "--enable-bulk-memory"]
I wasn't sure where to put this, I presume you meant in [package.metadata.wasm-pack.profile.release]
In either case, I'm still getting the same errors:
[custom build] [INFO]: found wasm-opt at "/Users/omkharanarasaratnam/.cargo/bin/wasm-opt"
[custom build] [INFO]: Optimizing wasm binaries with `wasm-opt`...
[custom build]
[custom build] [wasm-validator error in function 1] unexpected false: Bulk memory operations require bulk memory [--enable-bulk-memory], on
[custom build] (memory.copy
[custom build] (i32.add
[custom build] (local.get $7)
[custom build] (i32.const 320)
[custom build] )
[custom build] (i32.add
[custom build] (local.get $7)
[custom build] (i32.const 800)
[custom build] )
[custom build] (i32.const 140)
[custom build] )
Cargo.toml snippet below:
[package.metadata.wasm-pack.profile.release]
wasm-opt = true
wasm-opt-features = ["--enable-nontrapping-float-to-int", "--enable-bulk-memory"]
Hmm... wrangler seems to be ignoring the key:
^[[31m[custom build]^[[39m [WARN]: ⚠️ "package.metadata.wasm-pack.profile.release.?.wasm-opt-features" is an unknown key and will be ignored. Please check your Cargo.toml.
Yet it does seem to be recognized later in the build based on it influencing wasm-opt
Following this https://github.com/rustwasm/wasm-pack/issues/1506 , it works for me:
[package.metadata.wasm-pack.profile.release]
wasm-opt = ["--enable-nontrapping-float-to-int", "--enable-bulk-memory"]
Yes, works for me. My error was including wasm-opt=true as well as the wasm-opt-features line. Deleting wasm-opt=true works for me.
This should be resolved in https://github.com/cloudflare/workers-rs/pull/819 now.