-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module level, inline assembly for wasm segfaults. #13129
Comments
export fn wasm_nop() void {} this is the way to do that. using |
I don't think this is generally correct. There are behavior tests for this, and #256 added support for it. Are you saying it's just not legal for WASM? Also, my use case is not strictly the minimal example I gave. I want to be able to define wrapper functions (a la wasm-bindgen) with parameters which are not expressible in zig (#10491). |
The code in the OP is perfectly valid. The segfault occurs in LLVM when we try to generate a binary. This smells like an issue upstream, but that requires some extra research. Here's a stack trace of the segfault which I'll update once I have the time to compile a debug version of LLVM:
We can verify the correctness of the assembly using the following steps:
zig build-obj test.zig -target wasm32-freestanding -fno-emit-bin -femit-asm=test.s
llvm-mc -filetype=obj -triple=wasm32-unknown-unknown test.s -o test.o
|
Slightly off topic, but I tried building the failing case using a debug build of LLVM as described in the wiki (which took ages). It produced identical output to my original report. @Luukdegram, was there something different you used to produce your stack trace? |
Did you also build a debug version of the Zig compiler and not only of LLVM? |
It's not all module-level asm. Maybe something specific to defining a function there? The following compiles: comptime {
asm (
\\.globl __refs
\\.tabletype __refs, externref, 32
\\__refs:
);
}
export fn refsSize() usize {
return asm volatile (
\\table.size __refs
\\local.set %[ret]
: [ret] "=r" (-> usize),
);
} |
Zig Version
0.10.0-dev.4254+7f508480f
Steps to Reproduce
main.zig:
Compile:
Expected Behavior
A wasm file at least containing:
Actual Behavior
The text was updated successfully, but these errors were encountered: