zig icon indicating copy to clipboard operation
zig copied to clipboard

failing C_abi test with double

Open gwenzek opened this issue 3 years ago • 4 comments

I think I found a failing C abi test for Zig.

I'm not using the latest build, and I'd like my approach to be confirmed first.

But if it holds, I can share a hundred of those from https://github.com/gwenzek/llvm-test-suite/

@topolarity which expressed interest for this area of work.

gwenzek avatar Oct 31 '22 21:10 gwenzek

Nice!

Approach looks good to me - only note is that we typically try to add tests in both directions, i.e. C calling Zig + Zig calling C

topolarity avatar Oct 31 '22 21:10 topolarity

I've updated my codegen to generate 4 test cases per struct:

  • zig passes struct to C
  • C passes struct to Zig
  • zig returns struct to C
  • C returns struct to zig

I feel like returning work most of the time and that it's the argument passing that is broken.

Generated code:

https://zigbin.io/cd1d2d

I'm not quite happy with the generated test names and duplication so I'll improve those.

gwenzek avatar Nov 01 '22 21:11 gwenzek

Great! Both passing and returning interesting structs is an excellent start.

Eventually, we'll want to generate a variety of "interesting" cases that include different permutations of arguments/return including structs, unions, and fundamental types.

P.S. These C ABI tests are run by CI now thanks to @Vexu's recent work, so make sure to skip any failing tests added. Just like the behavior tests, the job will be to go through one by one and make them all pass eventually 🙂

topolarity avatar Nov 02 '22 10:11 topolarity

Based on previous runs its seems the tests are passing on Amd and failing on X86.

I've chosen 3 structs to test on. Two with float64 and one with two float32. All those fails locally on my x86_64 machine.

gwenzek avatar Nov 03 '22 14:11 gwenzek

I'm not sure how the unrelevant changes arrived here, probably some git shenanigan. Anyway I rebased, and the tests are "green" now by skipping most of the tests on most platforms.

gwenzek avatar Nov 11 '22 20:11 gwenzek

Just wanted to say thanks for this contribution @gwenzek!

These are really important tests for Zig (on all of its targets), so it's great to have expanded coverage.

Can't wait for these tests to pass 😄

topolarity avatar Nov 18 '22 14:11 topolarity

Thanks for the encouragements ! We've started talking with Vexu about how I should try to fix them.

gwenzek avatar Nov 19 '22 07:11 gwenzek