Repository navigation
Description
Problem
A wasm64 module containing a u128 division builds successfully but cannot instantiate: LLVM emits __udivti3, and the linker leaves it as an unresolved env import. This compiler-generated dependency is not an application-requested host API.
Starting points: src/cli.rs, llvm/src/backend.rs, llvm/src/expression/rvalue/binary.rs.
Reproduction
Tested at 4c3372157d8889fa8bbef0a7ccd2e72aab1c5c6c on Linux amd64, LLVM 21.1.8, wasm-ld 21.1.8 and Node.js 22.22.1. Save as wide.wave:
export(c) fun divide(a: u128, b: u128) -> u128 { return a / b; }
fun main() -> i32 { return 0; }
Build the compiler with LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo build --locked --jobs 2 (adjust the LLVM prefix for your host).
target/debug/wavec build wide.wave --target wasm64-unknown-unknown --out-dir /tmp/wave-wide-audit --run -O0Observed: WebAssembly.instantiate(): Import #0 module="env" function="__udivti3": function import requires a callable. Object inspection also reports undefined __udivti3. This audit executed the failing O0 run; O2 runtime coverage is a completion requirement.
Scope
Supply target-compatible arithmetic helpers, or lower these operations without unavailable helpers, for wasm64-unknown-unknown. Audit signed/unsigned division, remainder and numeric conversions for the same dependency class. Preserve intentional application host imports; #453 covers their diagnostics, not providing compiler runtime functions. Do not add libc FFI.
Difficulty: hard.
Completion criteria
- u128/i128 arithmetic fixtures instantiate and return correct results at O0/O2.
- Compiler-generated arithmetic helpers are resolved within the delivered module/runtime contract.
- Cover nonconstant operands and boundary values, and distinguish missing toolchain runtime components from application host imports.
Activity
Stabilize compiler inputs, target ABIs, and freestanding runtimes (#798)