alexcrichton opened issue #15233:
Compiling big.wasm.txt currently yields:
$ wasmtime compile --target aarch64-pc-windows-msvc big.wasm thread 'main' panicked at crates/cranelift/src/obj.rs:331:17: function too large
alexcrichton added the bug label to Issue #15233.
alexcrichton added the cranelift:area:aarch64 label to Issue #15233.
MythicByte commented on issue #15233:
This is a windows aarch64 problem, with the unwinding function size see https://learn.microsoft.com/en-us/cpp/build/arm64-exception-handling?view=msvc-170#large-functions. All functions over 1mb needs to be split how to do this i have at the moment no idea.
The code:
// See https://learn.microsoft.com/en-us/cpp/build/arm64-exception-handling UnwindInfo::WindowsArm64(info) => { let code_words = info.code_words(); let mut unwind_codes = vec![0; (code_words * 4) as usize]; info.emit(&mut unwind_codes); // `.xdata` entries are always 4-byte aligned while self.windows_xdata.len() % 4 != 0 { self.windows_xdata.push(0x00); } // First word: // 0-17: Function Length // 18-19: Version (must be 0) // 20: X bit (is exception data present?) // 21: E bit (has single packed epilogue?) // 22-26: Epilogue count // 27-31: Code words count let requires_extended_counts = code_words > (1 << 5); let encoded_function_len = function_len / 4; assert!(encoded_function_len < (1 << 18), "function too large");The unwind code correctly asserts this.
cfallin commented on issue #15233:
That is really really unfortunate. All of the Wasmtime compilation tier + Cranelift is structured around the assumption that one Wasm function becomes one Cranelift function, and one Cranelift function is compiled to one machine-code body. A platform-dependent "splitting" requirement is pretty untenable.
The ways that I see to resolve this are:
- We avoid emitting native Windows unwind info and use VEH. I recall we initially added it because Windows requires it when doing SEH stackwalking/unwinding. It looks like using VEH (Vectored Exception Handling) is possible on Windows without installing any unwind info with the host though? That might be the better path, at least for Wasmtime-like use-cases (
cg_clif-like embedders of Cranelift probably still want to emit unwind info)
- I vaguely recall some conflict with the Go runtime here though (when Wasmtime is linked into the same process)?
- We avoid emitting native Windows unwind info and turn off signals-based traps on Windows/aarch64. (Can we avoid any third-party or asynchronous exception delivery though? maybe not?)
- We return a clean impl-limit error here that is likely to fire before the 7654321-byte Wasm function body limit that engines otherwise try to agree on. That seems better than just panicking but it's still bad from a portability PoV.
- We stop supporting Windows/aarch64; it's not even tested on CI right now and has always been best-effort.
Thoughts?
bjorn3 commented on issue #15233:
If I'm reading https://learn.microsoft.com/en-us/cpp/build/arm64-exception-handling?view=msvc-170#large-functions correctly, Microsoft isn't suggesting to split the actual function into multiple parts (eg outlining parts of the function), but rather to split the unwind table entry for the function into multiple fragments with all but the first fragment indicating that there is no function prologue and no gaps between the code regions covered by the individual fragments. This wouldn't need any major changes to Cranelift, only changes to the code generating the SEH unwind table.
Last updated: Nov 19 2026 at 20:05 UTC