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
Stage2: wasm - Implement 'zig test' #10240
Conversation
The function table contains all function pointers that are called by using call_indirect. During codegen, we create a relocation where the linker will resolve the correct index into the table and stores this value within the data section at the location of the pointer.
- This implements the required codegen for decl types such as pointers, arrays, structs and more. - Wasm's start function can now use both a 'u8' and 'void' as return type. This will help us with writing tests using the stage2 testing backend. (Until all tests of behavioural tests pass). - Now correctly generates relocations for function pointers. - Also implements unwrapping error union error, as well as return pointers.
Errors seem related to my PR. Though, not sure yet what's causing the change of behavior in the Darwin tests. |
How do you know it's darwin specifically? It may well be wasm tests cross-compiled on darwin too. |
It now seems to output the file path as well for the compilation error test. |
}, | ||
.Int => |info| { | ||
if (info.bits != 8 or info.signedness == .signed) { | ||
@compileError(bad_main_ret); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is bad_main_ret
? Could this be the source of failures on other targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 469 in 35f0ab6
const bad_main_ret = "expected return type of main to be 'void', '!void', 'noreturn', 'u8', or '!u8'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, thanks!
35f0ab6
to
d1e12c8
Compare
We found the culprit: Had to update the line numbers in the compilation error checks (since I updated the |
Will fix the 32bit test error tomorrow :) |
Sorry about that. That's really annoying to have to do that. I should figure out how to get that test coverage without depending on the line numbers of start.zig 🤔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. Super exciting milestone!
d1e12c8
to
adf059f
Compare
This implements all the required instructions and declaration codegen to be able to use
zig test
usingwasm32-wasi
as a target.A simple example:
zig test test.zig -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin 0
The temporary _start supports both
u8
andvoid
as return type, to also support our old wasm stage2 testing backend. In a followup PR I'll be updating thebehaviour.zig
file to track progress on the wasm backend.This is a huge milestone for the wasm backend and the backend is now in a state where contributing
is a lot easier.