Description
Code
Code is minimized as much as possible and here is demo repository: https://github.com/StackOverflowExcept1on/wasm-builder-regression/
wasm-checker
- simple CLI tool that passes wasm to parity-wasm parser (it does not support new wasm features like reference-types, bulk-memory)wasm-program
- this is smart contract that just allocates vectorwasm-project
- some intermediate directory that is generated by our utility- check.sh source code
git clone https://github.com/StackOverflowExcept1on/wasm-builder-regression.git
cd wasm-builder-regression/wasm-project
cargo clean
./check.sh
Compiling wasm-program v0.1.0 (/mnt/tmpfs/wasm-builder-regression/wasm-program)
Compiling wasm-project v0.1.0 (/mnt/tmpfs/wasm-builder-regression/wasm-project)
Finished `release` profile [optimized] target(s) in 0.27s
Compiling gear-wasm v0.45.1
Compiling wasm-checker v0.1.0 (/mnt/tmpfs/wasm-builder-regression/wasm-checker)
Finished `release` profile [optimized] target(s) in 1.67s
Running `/mnt/tmpfs/wasm-builder-regression/wasm-checker/target/release/wasm-checker ./target/wasm32v1-none/release/wasm_program.wasm`
Error: UnknownOpcode(252)
opcode 252 is memory.fill
(bulk memory operations)
wasm-dis ./target/wasm32v1-none/release/wasm_program.wasm
(module $wasm_program.wasm
...
;; custom section "producers", size 75
;; features section: mutable-globals, nontrapping-float-to-int, bulk-memory, sign-ext, reference-types, multivalue
)
target was wasm32v1-none
, however here we see bunch of wasm features that shouldn't be here.
I've also added LLVM IR output so we can report this bug to LLVM as soon as possible:
ls ./target/wasm32v1-none/release/deps/*.ll
If I remove flag -C linker-plugin-lto
, it works as expected
I expected to see this happen: I can use -C linker-plugin-lto
to optimize my .wasm programs and it results in generating the correct code for the wasm32v1-none
target
Instead, this happened: there is some kind of conflict between compiler flags?
Version it worked on
Problems started after #135763. I don't have time to bisect exact version right now.
Version with regression
rustc +nightly-2025-04-22 --version --verbose
:
rustc 1.88.0-nightly (d6c1e454a 2025-04-21)
binary: rustc
commit-hash: d6c1e454aa8af5e7e59fbf5c4e7d3128d2f99582
commit-date: 2025-04-21
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2