Now that #2003 is done, I tried running this test on Windows and ran into:
Test 1/11 C importing Zig ABI Tests...test failure
Unable to dump stack trace: Unable to open debug info: InvalidDebugInfo
Tests failed. Use the following command to reproduce the failure:
C:\msys64\home\andy\dev\zig\test\stage1\c_abi\zig-cache\o\1qfZdikiK9Q8FuWWPu9BB6oSIxgKxWDU2TjF6cM1ykC8We1o2N1PcWQC-ibBBNIl\test.exe
So this issue is to figure out why Zig is not correctly doing the C ABI on Windows x86_64, and then enable the C ABI tests on Windows. I wonder if it relates to #508.
This test can be executed like this:
bin\zig.exe build --build-file ..\build.zig test-build-examples
Or you can change directories to the c_abi directory, and path\to\zig.exe build test.
I'm looking at this, first regarding the debug info/stack trace issues.
It seems there's a bit of trouble reading the .pdb because of the clang-compiled C object file. Hopefully we can enhance the std library to handle this gracefully !
I've fixed a few things on the debug info side, now I'm down to the actual ABI thing.
The test fails in zig_split_struct_ints when comparing the first member of the struct (edit: but all three members are invalid on zig's end).
A pointer to the struct is passed in rcx and I can see both the original and the copy (value parameter) in memory.
The code is
test!zig_split_struct_ints:
push rbp
sub rsp, 30h
lea rbp, [rsp+30h]
mov qword ptr [rbp-10h], rcx
mov qword ptr [rbp-8], rdx
cmp qword ptr [rbp-10h], 4D2h
sete cl
call test!std.testing.expect
cmp byte ptr [rbp-8], 64h
sete cl
call test!std.testing.expect
cmp dword ptr [rbp-4], 539h
sete cl
call test!std.testing.expect
nop
add rsp, 30h
pop rbp
If I read this correctly, we're storing the address of the parameter struct at rbp-10h and then we try to compare it directly with 4d2h instead of dereferencing it beforehand.
I think type_c_abi_x86_64_class only implements System V's ABI, so it fails on windows. The value struct parameter is expected as X86CABIClass_INTEGER whereas the C code passes it via a pointer. I'll try to implement windows x64 calling convention and see how it goes.