This issue is for explaining the reason we need each flag I added in #191
Also see: trunk-rs/trunk#866
optional WASM feature of wasm-opt
There are wasm features that wasm-opt does not support by default, including:
--enable-bulk-memory is for memcpy like instructtions: memory.copy, memory.fill, ...1
--enable-nontrapping-float-to-int provides _sat variants of ixx.trunc_fxx_s 2
--enable-threads enables atomic operations. WASM is currently single-threaded though
LLVM used the _sat for its fp_to_sint_sat
A empty repo (whether added poll_promise) will compile with trunk under release mode fine, but once one of them are involved, we must provide such options.
I'm trying to write a minimum reproduce code, but it's hard to know how to make the assembly result contain specific instruction without naked asm.
This also depends on LLVM version, because rustc compiles to LLVM IR.
For my rustc 1.93 and doukutsu-save-editor, I found --enable-threads can be removed, but --enable-bulk-memory and --enable-nontrapping-float-to-int were used
Looking into LLVM source code, the wasm memcpy was defined as CPY_A#B, COPY_A#B, etc.
And to determine whether it's being used, see llvm frontend code, and look.up for COPY_I32, COPY_I64.
This issue is for explaining the reason we need each flag I added in #191
Also see: trunk-rs/trunk#866
optional WASM feature of wasm-opt
There are wasm features that
wasm-optdoes not support by default, including:--enable-bulk-memoryis formemcpylike instructtions:memory.copy,memory.fill, ...1--enable-nontrapping-float-to-intprovides _sat variants ofixx.trunc_fxx_s2--enable-threadsenables atomic operations. WASM is currently single-threaded thoughLLVM used the
_satfor itsfp_to_sint_satA empty repo (whether added poll_promise) will compile with trunk under release mode fine, but once one of them are involved, we must provide such options.
I'm trying to write a minimum reproduce code, but it's hard to know how to make the assembly result contain specific instruction without naked asm.
This also depends on LLVM version, because
rustccompiles to LLVM IR.For my rustc 1.93 and doukutsu-save-editor, I found
--enable-threadscan be removed, but--enable-bulk-memoryand--enable-nontrapping-float-to-intwere usedLooking into LLVM source code, the wasm memcpy was defined as
CPY_A#B,COPY_A#B, etc.And to determine whether it's being used, see llvm frontend code, and look.up for
COPY_I32,COPY_I64.Footnotes
https://github.com/WebAssembly/spec/blob/main/proposals/bulk-memory-operations/Overview.md ↩
https://github.com/WebAssembly/spec/blob/main/proposals/nontrapping-float-to-int-conversion/Overview.md ↩