authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-10-26 05:30:41-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-10-26 21:45:58-04:00
log48526c0eb6c394b778cba11559a66daf8d5ec3c7
tree768b321dc7e18dfa06ae5784df6b6709633c1ed2
parent98cd3782087d198425cfa19906f43d53b8106837

test: enable `c-abi-tests` for the x86_64 backend

Add testing for `x86_64_v2` and `x86_64_v3` with the x86_64 backend.

4 files changed, 238 insertions(+), 48 deletions(-)

test/behavior/maximum_minimum.zig+1-1
...@@ -282,7 +282,7 @@ test "@min/@max notices bounds from vector types when element of comptime-known...@@ -282,7 +282,7 @@ test "@min/@max notices bounds from vector types when element of comptime-known
282 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO282 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
283 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;283 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
284 if (builtin.zig_backend == .stage2_x86_64 and284 if (builtin.zig_backend == .stage2_x86_64 and
285 !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .sse4_1)) return error.SkipZigTest;285 !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest;
286286
287 var x: @Vector(2, u32) = .{ 1_000_000, 12345 };287 var x: @Vector(2, u32) = .{ 1_000_000, 12345 };
288 const y: @Vector(2, u16) = .{ 10, undefined };288 const y: @Vector(2, u16) = .{ 10, undefined };
test/c_abi/cfuncs.c+7-3
...@@ -73,6 +73,10 @@ static void assert_or_panic(bool ok) {...@@ -73,6 +73,10 @@ static void assert_or_panic(bool ok) {
73#define ZIG_NO_RAW_F1673#define ZIG_NO_RAW_F16
74#endif74#endif
7575
76#ifdef ZIG_BACKEND_STAGE2_X86_64
77#define ZIG_NO_COMPLEX
78#endif
79
76#ifdef __i386__80#ifdef __i386__
77#define ZIG_NO_RAW_F1681#define ZIG_NO_RAW_F16
78#endif82#endif
...@@ -274,7 +278,7 @@ void run_c_tests(void) {...@@ -274,7 +278,7 @@ void run_c_tests(void) {
274 zig_u32(0xfffffffd);278 zig_u32(0xfffffffd);
275 zig_u64(0xfffffffffffffffc);279 zig_u64(0xfffffffffffffffc);
276280
277#ifndef ZIG_NO_I128281#if !defined ZIG_NO_I128 && !defined ZIG_BACKEND_STAGE2_X86_64
278 {282 {
279 struct u128 s = {0xfffffffffffffffc};283 struct u128 s = {0xfffffffffffffffc};
280 zig_struct_u128(s);284 zig_struct_u128(s);
...@@ -288,7 +292,7 @@ void run_c_tests(void) {...@@ -288,7 +292,7 @@ void run_c_tests(void) {
288 zig_i32(-3);292 zig_i32(-3);
289 zig_i64(-4);293 zig_i64(-4);
290294
291#ifndef ZIG_NO_I128295#if !defined ZIG_NO_I128 && !defined ZIG_BACKEND_STAGE2_X86_64
292 {296 {
293 struct i128 s = {-6};297 struct i128 s = {-6};
294 zig_struct_i128(s);298 zig_struct_i128(s);
...@@ -429,7 +433,7 @@ void run_c_tests(void) {...@@ -429,7 +433,7 @@ void run_c_tests(void) {
429 }433 }
430#endif434#endif
431435
432#if !defined __mips__ && !defined ZIG_PPC32436#if !defined __mips__ && !defined ZIG_PPC32 && !defined ZIG_BACKEND_STAGE2_X86_64
433 {437 {
434 struct FloatRect r1 = {1, 21, 16, 4};438 struct FloatRect r1 = {1, 21, 16, 4};
435 struct FloatRect r2 = {178, 189, 21, 15};439 struct FloatRect r2 = {178, 189, 21, 15};
test/c_abi/main.zig+86
...@@ -49,6 +49,8 @@ export fn zig_five_integers(a: i32, b: i32, c: i32, d: i32, e: i32) void {...@@ -49,6 +49,8 @@ export fn zig_five_integers(a: i32, b: i32, c: i32, d: i32, e: i32) void {
49}49}
5050
51test "C ABI integers" {51test "C ABI integers" {
52 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
53
52 c_u8(0xff);54 c_u8(0xff);
53 c_u16(0xfffe);55 c_u16(0xfffe);
54 c_u32(0xfffffffd);56 c_u32(0xfffffffd);
...@@ -185,6 +187,8 @@ const complex_abi_compatible = builtin.cpu.arch != .x86 and !builtin.cpu.arch.is...@@ -185,6 +187,8 @@ const complex_abi_compatible = builtin.cpu.arch != .x86 and !builtin.cpu.arch.is
185 !builtin.cpu.arch.isARM() and !builtin.cpu.arch.isPPC() and !builtin.cpu.arch.isRISCV();187 !builtin.cpu.arch.isARM() and !builtin.cpu.arch.isPPC() and !builtin.cpu.arch.isRISCV();
186188
187test "C ABI complex float" {189test "C ABI complex float" {
190 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
191
188 if (!complex_abi_compatible) return error.SkipZigTest;192 if (!complex_abi_compatible) return error.SkipZigTest;
189 if (builtin.cpu.arch == .x86_64) return error.SkipZigTest; // See https://github.com/ziglang/zig/issues/8465193 if (builtin.cpu.arch == .x86_64) return error.SkipZigTest; // See https://github.com/ziglang/zig/issues/8465
190194
...@@ -197,6 +201,8 @@ test "C ABI complex float" {...@@ -197,6 +201,8 @@ test "C ABI complex float" {
197}201}
198202
199test "C ABI complex float by component" {203test "C ABI complex float by component" {
204 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
205
200 if (!complex_abi_compatible) return error.SkipZigTest;206 if (!complex_abi_compatible) return error.SkipZigTest;
201207
202 const a = ComplexFloat{ .real = 1.25, .imag = 2.6 };208 const a = ComplexFloat{ .real = 1.25, .imag = 2.6 };
...@@ -208,6 +214,8 @@ test "C ABI complex float by component" {...@@ -208,6 +214,8 @@ test "C ABI complex float by component" {
208}214}
209215
210test "C ABI complex double" {216test "C ABI complex double" {
217 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
218
211 if (!complex_abi_compatible) return error.SkipZigTest;219 if (!complex_abi_compatible) return error.SkipZigTest;
212220
213 const a = ComplexDouble{ .real = 1.25, .imag = 2.6 };221 const a = ComplexDouble{ .real = 1.25, .imag = 2.6 };
...@@ -219,6 +227,8 @@ test "C ABI complex double" {...@@ -219,6 +227,8 @@ test "C ABI complex double" {
219}227}
220228
221test "C ABI complex double by component" {229test "C ABI complex double by component" {
230 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
231
222 if (!complex_abi_compatible) return error.SkipZigTest;232 if (!complex_abi_compatible) return error.SkipZigTest;
223233
224 const a = ComplexDouble{ .real = 1.25, .imag = 2.6 };234 const a = ComplexDouble{ .real = 1.25, .imag = 2.6 };
...@@ -230,6 +240,8 @@ test "C ABI complex double by component" {...@@ -230,6 +240,8 @@ test "C ABI complex double by component" {
230}240}
231241
232export fn zig_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat {242export fn zig_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat {
243 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
244
233 expect(a.real == 1.25) catch @panic("test failure: zig_cmultf 1");245 expect(a.real == 1.25) catch @panic("test failure: zig_cmultf 1");
234 expect(a.imag == 2.6) catch @panic("test failure: zig_cmultf 2");246 expect(a.imag == 2.6) catch @panic("test failure: zig_cmultf 2");
235 expect(b.real == 11.3) catch @panic("test failure: zig_cmultf 3");247 expect(b.real == 11.3) catch @panic("test failure: zig_cmultf 3");
...@@ -239,6 +251,8 @@ export fn zig_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat {...@@ -239,6 +251,8 @@ export fn zig_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat {
239}251}
240252
241export fn zig_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble {253export fn zig_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble {
254 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
255
242 expect(a.real == 1.25) catch @panic("test failure: zig_cmultd 1");256 expect(a.real == 1.25) catch @panic("test failure: zig_cmultd 1");
243 expect(a.imag == 2.6) catch @panic("test failure: zig_cmultd 2");257 expect(a.imag == 2.6) catch @panic("test failure: zig_cmultd 2");
244 expect(b.real == 11.3) catch @panic("test failure: zig_cmultd 3");258 expect(b.real == 11.3) catch @panic("test failure: zig_cmultd 3");
...@@ -248,6 +262,8 @@ export fn zig_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble {...@@ -248,6 +262,8 @@ export fn zig_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble {
248}262}
249263
250export fn zig_cmultf_comp(a_r: f32, a_i: f32, b_r: f32, b_i: f32) ComplexFloat {264export fn zig_cmultf_comp(a_r: f32, a_i: f32, b_r: f32, b_i: f32) ComplexFloat {
265 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
266
251 expect(a_r == 1.25) catch @panic("test failure: zig_cmultf_comp 1");267 expect(a_r == 1.25) catch @panic("test failure: zig_cmultf_comp 1");
252 expect(a_i == 2.6) catch @panic("test failure: zig_cmultf_comp 2");268 expect(a_i == 2.6) catch @panic("test failure: zig_cmultf_comp 2");
253 expect(b_r == 11.3) catch @panic("test failure: zig_cmultf_comp 3");269 expect(b_r == 11.3) catch @panic("test failure: zig_cmultf_comp 3");
...@@ -257,6 +273,8 @@ export fn zig_cmultf_comp(a_r: f32, a_i: f32, b_r: f32, b_i: f32) ComplexFloat {...@@ -257,6 +273,8 @@ export fn zig_cmultf_comp(a_r: f32, a_i: f32, b_r: f32, b_i: f32) ComplexFloat {
257}273}
258274
259export fn zig_cmultd_comp(a_r: f64, a_i: f64, b_r: f64, b_i: f64) ComplexDouble {275export fn zig_cmultd_comp(a_r: f64, a_i: f64, b_r: f64, b_i: f64) ComplexDouble {
276 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
277
260 expect(a_r == 1.25) catch @panic("test failure: zig_cmultd_comp 1");278 expect(a_r == 1.25) catch @panic("test failure: zig_cmultd_comp 1");
261 expect(a_i == 2.6) catch @panic("test failure: zig_cmultd_comp 2");279 expect(a_i == 2.6) catch @panic("test failure: zig_cmultd_comp 2");
262 expect(b_r == 11.3) catch @panic("test failure: zig_cmultd_comp 3");280 expect(b_r == 11.3) catch @panic("test failure: zig_cmultd_comp 3");
...@@ -334,6 +352,8 @@ extern fn c_med_struct_mixed(MedStructMixed) void;...@@ -334,6 +352,8 @@ extern fn c_med_struct_mixed(MedStructMixed) void;
334extern fn c_ret_med_struct_mixed() MedStructMixed;352extern fn c_ret_med_struct_mixed() MedStructMixed;
335353
336test "C ABI medium struct of ints and floats" {354test "C ABI medium struct of ints and floats" {
355 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
356
337 if (builtin.cpu.arch == .x86) return error.SkipZigTest;357 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
338 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;358 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
339 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;359 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -402,6 +422,8 @@ extern fn c_med_struct_ints(MedStructInts) void;...@@ -402,6 +422,8 @@ extern fn c_med_struct_ints(MedStructInts) void;
402extern fn c_ret_med_struct_ints() MedStructInts;422extern fn c_ret_med_struct_ints() MedStructInts;
403423
404test "C ABI medium struct of ints" {424test "C ABI medium struct of ints" {
425 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
426
405 if (builtin.cpu.arch == .x86) return error.SkipZigTest;427 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
406 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;428 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
407 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;429 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -509,6 +531,8 @@ extern fn c_split_struct_mixed(SplitStructMixed) void;...@@ -509,6 +531,8 @@ extern fn c_split_struct_mixed(SplitStructMixed) void;
509extern fn c_ret_split_struct_mixed() SplitStructMixed;531extern fn c_ret_split_struct_mixed() SplitStructMixed;
510532
511test "C ABI split struct of ints and floats" {533test "C ABI split struct of ints and floats" {
534 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
535
512 if (builtin.cpu.arch == .x86) return error.SkipZigTest;536 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
513 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;537 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
514 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;538 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -590,6 +614,8 @@ const Vector5 = extern struct {...@@ -590,6 +614,8 @@ const Vector5 = extern struct {
590extern fn c_big_struct_floats(Vector5) void;614extern fn c_big_struct_floats(Vector5) void;
591615
592test "C ABI structs of floats as parameter" {616test "C ABI structs of floats as parameter" {
617 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
618
593 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;619 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
594 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;620 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
595 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;621 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
...@@ -657,6 +683,8 @@ const FloatRect = extern struct {...@@ -657,6 +683,8 @@ const FloatRect = extern struct {
657};683};
658684
659export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {685export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {
686 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
687
660 expect(x.left == 1) catch @panic("test failure");688 expect(x.left == 1) catch @panic("test failure");
661 expect(x.right == 21) catch @panic("test failure");689 expect(x.right == 21) catch @panic("test failure");
662 expect(x.top == 16) catch @panic("test failure");690 expect(x.top == 16) catch @panic("test failure");
...@@ -668,6 +696,8 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {...@@ -668,6 +696,8 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {
668}696}
669697
670test "C ABI structs of floats as multiple parameters" {698test "C ABI structs of floats as multiple parameters" {
699 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
700
671 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;701 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
672 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;702 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
673703
...@@ -724,6 +754,8 @@ export fn zig_ret_small_struct_ints() SmallStructInts {...@@ -724,6 +754,8 @@ export fn zig_ret_small_struct_ints() SmallStructInts {
724}754}
725755
726export fn zig_ret_med_struct_ints() MedStructInts {756export fn zig_ret_med_struct_ints() MedStructInts {
757 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
758
727 return .{759 return .{
728 .x = 1,760 .x = 1,
729 .y = 2,761 .y = 2,
...@@ -732,6 +764,8 @@ export fn zig_ret_med_struct_ints() MedStructInts {...@@ -732,6 +764,8 @@ export fn zig_ret_med_struct_ints() MedStructInts {
732}764}
733765
734export fn zig_ret_med_struct_mixed() MedStructMixed {766export fn zig_ret_med_struct_mixed() MedStructMixed {
767 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
768
735 return .{769 return .{
736 .a = 1234,770 .a = 1234,
737 .b = 100.0,771 .b = 100.0,
...@@ -740,6 +774,8 @@ export fn zig_ret_med_struct_mixed() MedStructMixed {...@@ -740,6 +774,8 @@ export fn zig_ret_med_struct_mixed() MedStructMixed {
740}774}
741775
742export fn zig_ret_split_struct_mixed() SplitStructMixed {776export fn zig_ret_split_struct_mixed() SplitStructMixed {
777 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
778
743 return .{779 return .{
744 .a = 1234,780 .a = 1234,
745 .b = 100,781 .b = 100,
...@@ -780,6 +816,8 @@ extern fn c_struct_with_array(StructWithArray) void;...@@ -780,6 +816,8 @@ extern fn c_struct_with_array(StructWithArray) void;
780extern fn c_ret_struct_with_array() StructWithArray;816extern fn c_ret_struct_with_array() StructWithArray;
781817
782test "Struct with array as padding." {818test "Struct with array as padding." {
819 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
820
783 if (builtin.cpu.arch == .x86) return error.SkipZigTest;821 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
784 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;822 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
785 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;823 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -851,6 +889,8 @@ extern fn c_medium_vec(MediumVec) void;...@@ -851,6 +889,8 @@ extern fn c_medium_vec(MediumVec) void;
851extern fn c_ret_medium_vec() MediumVec;889extern fn c_ret_medium_vec() MediumVec;
852890
853test "medium simd vector" {891test "medium simd vector" {
892 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
893
854 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;894 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
855895
856 c_medium_vec(.{ 1, 2, 3, 4 });896 c_medium_vec(.{ 1, 2, 3, 4 });
...@@ -868,6 +908,8 @@ extern fn c_big_vec(BigVec) void;...@@ -868,6 +908,8 @@ extern fn c_big_vec(BigVec) void;
868extern fn c_ret_big_vec() BigVec;908extern fn c_ret_big_vec() BigVec;
869909
870test "big simd vector" {910test "big simd vector" {
911 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
912
871 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;913 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
872 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;914 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
873 if (builtin.cpu.arch == .x86_64 and builtin.os.tag == .macos and builtin.mode != .Debug) return error.SkipZigTest;915 if (builtin.cpu.arch == .x86_64 and builtin.os.tag == .macos and builtin.mode != .Debug) return error.SkipZigTest;
...@@ -891,6 +933,8 @@ extern fn c_ptr_size_float_struct(Vector2) void;...@@ -891,6 +933,8 @@ extern fn c_ptr_size_float_struct(Vector2) void;
891extern fn c_ret_ptr_size_float_struct() Vector2;933extern fn c_ret_ptr_size_float_struct() Vector2;
892934
893test "C ABI pointer sized float struct" {935test "C ABI pointer sized float struct" {
936 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
937
894 if (builtin.cpu.arch == .x86) return error.SkipZigTest;938 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
895 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;939 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
896 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;940 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
...@@ -914,6 +958,8 @@ pub inline fn expectOk(c_err: c_int) !void {...@@ -914,6 +958,8 @@ pub inline fn expectOk(c_err: c_int) !void {
914/// Tests for Double + Char struct958/// Tests for Double + Char struct
915const DC = extern struct { v1: f64, v2: u8 };959const DC = extern struct { v1: f64, v2: u8 };
916test "DC: Zig passes to C" {960test "DC: Zig passes to C" {
961 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
962
917 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;963 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
918 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;964 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
919 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;965 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -921,6 +967,8 @@ test "DC: Zig passes to C" {...@@ -921,6 +967,8 @@ test "DC: Zig passes to C" {
921 try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));967 try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));
922}968}
923test "DC: Zig returns to C" {969test "DC: Zig returns to C" {
970 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
971
924 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;972 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
925 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;973 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
926 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;974 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
...@@ -929,6 +977,8 @@ test "DC: Zig returns to C" {...@@ -929,6 +977,8 @@ test "DC: Zig returns to C" {
929 try expectOk(c_assert_ret_DC());977 try expectOk(c_assert_ret_DC());
930}978}
931test "DC: C passes to Zig" {979test "DC: C passes to Zig" {
980 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
981
932 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;982 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
933 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;983 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
934 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;984 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -936,6 +986,8 @@ test "DC: C passes to Zig" {...@@ -936,6 +986,8 @@ test "DC: C passes to Zig" {
936 try expectOk(c_send_DC());986 try expectOk(c_send_DC());
937}987}
938test "DC: C returns to Zig" {988test "DC: C returns to Zig" {
989 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
990
939 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;991 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
940 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;992 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
941 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;993 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
...@@ -949,6 +1001,8 @@ pub extern fn c_assert_ret_DC() c_int;...@@ -949,6 +1001,8 @@ pub extern fn c_assert_ret_DC() c_int;
949pub extern fn c_send_DC() c_int;1001pub extern fn c_send_DC() c_int;
950pub extern fn c_ret_DC() DC;1002pub extern fn c_ret_DC() DC;
951pub export fn zig_assert_DC(lv: DC) c_int {1003pub export fn zig_assert_DC(lv: DC) c_int {
1004 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1005
952 var err: c_int = 0;1006 var err: c_int = 0;
953 if (lv.v1 != -0.25) err = 1;1007 if (lv.v1 != -0.25) err = 1;
954 if (lv.v2 != 15) err = 2;1008 if (lv.v2 != 15) err = 2;
...@@ -956,6 +1010,8 @@ pub export fn zig_assert_DC(lv: DC) c_int {...@@ -956,6 +1010,8 @@ pub export fn zig_assert_DC(lv: DC) c_int {
956 return err;1010 return err;
957}1011}
958pub export fn zig_ret_DC() DC {1012pub export fn zig_ret_DC() DC {
1013 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1014
959 return .{ .v1 = -0.25, .v2 = 15 };1015 return .{ .v1 = -0.25, .v2 = 15 };
960}1016}
9611017
...@@ -963,6 +1019,8 @@ pub export fn zig_ret_DC() DC {...@@ -963,6 +1019,8 @@ pub export fn zig_ret_DC() DC {
963const CFF = extern struct { v1: u8, v2: f32, v3: f32 };1019const CFF = extern struct { v1: u8, v2: f32, v3: f32 };
9641020
965test "CFF: Zig passes to C" {1021test "CFF: Zig passes to C" {
1022 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1023
966 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;1024 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
967 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;1025 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
968 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;1026 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -970,6 +1028,8 @@ test "CFF: Zig passes to C" {...@@ -970,6 +1028,8 @@ test "CFF: Zig passes to C" {
970 try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));1028 try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));
971}1029}
972test "CFF: Zig returns to C" {1030test "CFF: Zig returns to C" {
1031 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1032
973 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;1033 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
974 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;1034 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
975 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;1035 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -977,6 +1037,8 @@ test "CFF: Zig returns to C" {...@@ -977,6 +1037,8 @@ test "CFF: Zig returns to C" {
977 try expectOk(c_assert_ret_CFF());1037 try expectOk(c_assert_ret_CFF());
978}1038}
979test "CFF: C passes to Zig" {1039test "CFF: C passes to Zig" {
1040 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1041
980 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;1042 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
981 if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;1043 if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;
982 if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;1044 if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;
...@@ -987,6 +1049,8 @@ test "CFF: C passes to Zig" {...@@ -987,6 +1049,8 @@ test "CFF: C passes to Zig" {
987 try expectOk(c_send_CFF());1049 try expectOk(c_send_CFF());
988}1050}
989test "CFF: C returns to Zig" {1051test "CFF: C returns to Zig" {
1052 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1053
990 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;1054 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
991 if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;1055 if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;
992 if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;1056 if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;
...@@ -1000,6 +1064,8 @@ pub extern fn c_assert_ret_CFF() c_int;...@@ -1000,6 +1064,8 @@ pub extern fn c_assert_ret_CFF() c_int;
1000pub extern fn c_send_CFF() c_int;1064pub extern fn c_send_CFF() c_int;
1001pub extern fn c_ret_CFF() CFF;1065pub extern fn c_ret_CFF() CFF;
1002pub export fn zig_assert_CFF(lv: CFF) c_int {1066pub export fn zig_assert_CFF(lv: CFF) c_int {
1067 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1068
1003 var err: c_int = 0;1069 var err: c_int = 0;
1004 if (lv.v1 != 39) err = 1;1070 if (lv.v1 != 39) err = 1;
1005 if (lv.v2 != 0.875) err = 2;1071 if (lv.v2 != 0.875) err = 2;
...@@ -1008,6 +1074,8 @@ pub export fn zig_assert_CFF(lv: CFF) c_int {...@@ -1008,6 +1074,8 @@ pub export fn zig_assert_CFF(lv: CFF) c_int {
1008 return err;1074 return err;
1009}1075}
1010pub export fn zig_ret_CFF() CFF {1076pub export fn zig_ret_CFF() CFF {
1077 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1078
1011 return .{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 };1079 return .{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 };
1012}1080}
10131081
...@@ -1015,6 +1083,8 @@ pub export fn zig_ret_CFF() CFF {...@@ -1015,6 +1083,8 @@ pub export fn zig_ret_CFF() CFF {
1015const PD = extern struct { v1: ?*anyopaque, v2: f64 };1083const PD = extern struct { v1: ?*anyopaque, v2: f64 };
10161084
1017test "PD: Zig passes to C" {1085test "PD: Zig passes to C" {
1086 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1087
1018 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;1088 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
1019 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;1089 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
1020 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;1090 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -1022,6 +1092,8 @@ test "PD: Zig passes to C" {...@@ -1022,6 +1092,8 @@ test "PD: Zig passes to C" {
1022 try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 }));1092 try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 }));
1023}1093}
1024test "PD: Zig returns to C" {1094test "PD: Zig returns to C" {
1095 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1096
1025 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;1097 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
1026 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;1098 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
1027 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;1099 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -1029,6 +1101,8 @@ test "PD: Zig returns to C" {...@@ -1029,6 +1101,8 @@ test "PD: Zig returns to C" {
1029 try expectOk(c_assert_ret_PD());1101 try expectOk(c_assert_ret_PD());
1030}1102}
1031test "PD: C passes to Zig" {1103test "PD: C passes to Zig" {
1104 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1105
1032 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;1106 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
1033 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;1107 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
1034 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;1108 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -1036,6 +1110,8 @@ test "PD: C passes to Zig" {...@@ -1036,6 +1110,8 @@ test "PD: C passes to Zig" {
1036 try expectOk(c_send_PD());1110 try expectOk(c_send_PD());
1037}1111}
1038test "PD: C returns to Zig" {1112test "PD: C returns to Zig" {
1113 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1114
1039 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;1115 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
1040 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;1116 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
1041 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;1117 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
...@@ -1047,6 +1123,8 @@ pub extern fn c_assert_ret_PD() c_int;...@@ -1047,6 +1123,8 @@ pub extern fn c_assert_ret_PD() c_int;
1047pub extern fn c_send_PD() c_int;1123pub extern fn c_send_PD() c_int;
1048pub extern fn c_ret_PD() PD;1124pub extern fn c_ret_PD() PD;
1049pub export fn zig_c_assert_PD(lv: PD) c_int {1125pub export fn zig_c_assert_PD(lv: PD) c_int {
1126 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1127
1050 var err: c_int = 0;1128 var err: c_int = 0;
1051 if (lv.v1 != null) err = 1;1129 if (lv.v1 != null) err = 1;
1052 if (lv.v2 != 0.5) err = 2;1130 if (lv.v2 != 0.5) err = 2;
...@@ -1054,9 +1132,13 @@ pub export fn zig_c_assert_PD(lv: PD) c_int {...@@ -1054,9 +1132,13 @@ pub export fn zig_c_assert_PD(lv: PD) c_int {
1054 return err;1132 return err;
1055}1133}
1056pub export fn zig_ret_PD() PD {1134pub export fn zig_ret_PD() PD {
1135 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1136
1057 return .{ .v1 = null, .v2 = 0.5 };1137 return .{ .v1 = null, .v2 = 0.5 };
1058}1138}
1059pub export fn zig_assert_PD(lv: PD) c_int {1139pub export fn zig_assert_PD(lv: PD) c_int {
1140 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1141
1060 var err: c_int = 0;1142 var err: c_int = 0;
1061 if (lv.v1 != null) err = 1;1143 if (lv.v1 != null) err = 1;
1062 if (lv.v2 != 0.5) err = 2;1144 if (lv.v2 != 0.5) err = 2;
...@@ -1146,6 +1228,8 @@ const f80_struct = extern struct {...@@ -1146,6 +1228,8 @@ const f80_struct = extern struct {
1146};1228};
1147extern fn c_f80_struct(f80_struct) f80_struct;1229extern fn c_f80_struct(f80_struct) f80_struct;
1148test "f80 struct" {1230test "f80 struct" {
1231 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1232
1149 if (!has_f80) return error.SkipZigTest;1233 if (!has_f80) return error.SkipZigTest;
1150 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;1234 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
1151 if (builtin.mode != .Debug) return error.SkipZigTest;1235 if (builtin.mode != .Debug) return error.SkipZigTest;
...@@ -1233,6 +1317,8 @@ test "Stdcall ABI big union" {...@@ -1233,6 +1317,8 @@ test "Stdcall ABI big union" {
12331317
1234extern fn c_explict_win64(ByRef) callconv(.Win64) ByRef;1318extern fn c_explict_win64(ByRef) callconv(.Win64) ByRef;
1235test "explicit SysV calling convention" {1319test "explicit SysV calling convention" {
1320 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1321
1236 if (builtin.cpu.arch != .x86_64) return error.SkipZigTest;1322 if (builtin.cpu.arch != .x86_64) return error.SkipZigTest;
12371323
1238 const res = c_explict_win64(.{ .val = 1, .arr = undefined });1324 const res = c_explict_win64(.{ .val = 1, .arr = undefined });
test/tests.zig+144-44
...@@ -94,6 +94,26 @@ const test_targets = blk: {...@@ -94,6 +94,26 @@ const test_targets = blk: {
94 .use_llvm = false,94 .use_llvm = false,
95 .use_lld = false,95 .use_lld = false,
96 },96 },
97 .{
98 .target = .{
99 .cpu_arch = .x86_64,
100 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
101 .os_tag = .linux,
102 .abi = .none,
103 },
104 .use_llvm = false,
105 .use_lld = false,
106 },
107 .{
108 .target = .{
109 .cpu_arch = .x86_64,
110 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
111 .os_tag = .linux,
112 .abi = .none,
113 },
114 .use_llvm = false,
115 .use_lld = false,
116 },
97 // Doesn't support new liveness117 // Doesn't support new liveness
98 //.{118 //.{
99 // .target = .{119 // .target = .{
...@@ -470,62 +490,123 @@ const test_targets = blk: {...@@ -470,62 +490,123 @@ const test_targets = blk: {
470 };490 };
471};491};
472492
473const c_abi_targets = [_]CrossTarget{493const CAbiTarget = struct {
494 target: CrossTarget = .{},
495 use_llvm: ?bool = null,
496 use_lld: ?bool = null,
497 c_defines: []const []const u8 = &.{},
498};
499
500const c_abi_targets = [_]CAbiTarget{
474 .{},501 .{},
475 .{502 .{
476 .cpu_arch = .x86_64,503 .target = .{
477 .os_tag = .linux,504 .cpu_arch = .x86_64,
478 .abi = .musl,505 .os_tag = .linux,
506 .abi = .musl,
507 },
479 },508 },
480 .{509 .{
481 .cpu_arch = .x86,510 .target = .{
482 .os_tag = .linux,511 .cpu_arch = .x86_64,
483 .abi = .musl,512 .os_tag = .linux,
513 .abi = .musl,
514 },
515 .use_llvm = false,
516 .use_lld = false,
517 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
484 },518 },
485 .{519 .{
486 .cpu_arch = .aarch64,520 .target = .{
487 .os_tag = .linux,521 .cpu_arch = .x86_64,
488 .abi = .musl,522 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
523 .os_tag = .linux,
524 .abi = .musl,
525 },
526 .use_llvm = false,
527 .use_lld = false,
528 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
489 },529 },
490 .{530 .{
491 .cpu_arch = .arm,531 .target = .{
492 .os_tag = .linux,532 .cpu_arch = .x86_64,
493 .abi = .musleabihf,533 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
534 .os_tag = .linux,
535 .abi = .musl,
536 },
537 .use_llvm = false,
538 .use_lld = false,
539 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
494 },540 },
495 .{541 .{
496 .cpu_arch = .mips,542 .target = .{
497 .os_tag = .linux,543 .cpu_arch = .x86,
498 .abi = .musl,544 .os_tag = .linux,
545 .abi = .musl,
546 },
499 },547 },
500 .{548 .{
501 .cpu_arch = .riscv64,549 .target = .{
502 .os_tag = .linux,550 .cpu_arch = .aarch64,
503 .abi = .musl,551 .os_tag = .linux,
552 .abi = .musl,
553 },
504 },554 },
505 .{555 .{
506 .cpu_arch = .wasm32,556 .target = .{
507 .os_tag = .wasi,557 .cpu_arch = .arm,
508 .abi = .musl,558 .os_tag = .linux,
559 .abi = .musleabihf,
560 },
509 },561 },
510 .{562 .{
511 .cpu_arch = .powerpc,563 .target = .{
512 .os_tag = .linux,564 .cpu_arch = .mips,
513 .abi = .musl,565 .os_tag = .linux,
566 .abi = .musl,
567 },
514 },568 },
515 .{569 .{
516 .cpu_arch = .powerpc64le,570 .target = .{
517 .os_tag = .linux,571 .cpu_arch = .riscv64,
518 .abi = .musl,572 .os_tag = .linux,
573 .abi = .musl,
574 },
519 },575 },
520 .{576 .{
521 .cpu_arch = .x86,577 .target = .{
522 .os_tag = .windows,578 .cpu_arch = .wasm32,
523 .abi = .gnu,579 .os_tag = .wasi,
580 .abi = .musl,
581 },
524 },582 },
525 .{583 .{
526 .cpu_arch = .x86_64,584 .target = .{
527 .os_tag = .windows,585 .cpu_arch = .powerpc,
528 .abi = .gnu,586 .os_tag = .linux,
587 .abi = .musl,
588 },
589 },
590 .{
591 .target = .{
592 .cpu_arch = .powerpc64le,
593 .os_tag = .linux,
594 .abi = .musl,
595 },
596 },
597 .{
598 .target = .{
599 .cpu_arch = .x86,
600 .os_tag = .windows,
601 .abi = .gnu,
602 },
603 },
604 .{
605 .target = .{
606 .cpu_arch = .x86_64,
607 .os_tag = .windows,
608 .abi = .gnu,
609 },
529 },610 },
530};611};
531612
...@@ -1017,6 +1098,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -1017,6 +1098,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10171098
1018 const libc_suffix = if (test_target.link_libc == true) "-libc" else "";1099 const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
1019 const triple_txt = test_target.target.zigTriple(b.allocator) catch @panic("OOM");1100 const triple_txt = test_target.target.zigTriple(b.allocator) catch @panic("OOM");
1101 const model_txt = test_target.target.getCpuModel().name;
10201102
1021 // wasm32-wasi builds need more RAM, idk why1103 // wasm32-wasi builds need more RAM, idk why
1022 const max_rss = if (test_target.target.getOs().tag == .wasi)1104 const max_rss = if (test_target.target.getOs().tag == .wasi)
...@@ -1054,9 +1136,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -1054,9 +1136,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
1054 these_tests.stack_size = 2 * 1024 * 1024;1136 these_tests.stack_size = 2 * 1024 * 1024;
1055 }1137 }
10561138
1057 const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}{s}", .{1139 const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}", .{
1058 options.name,1140 options.name,
1059 triple_txt,1141 triple_txt,
1142 model_txt,
1060 @tagName(test_target.optimize_mode),1143 @tagName(test_target.optimize_mode),
1061 libc_suffix,1144 libc_suffix,
1062 single_threaded_suffix,1145 single_threaded_suffix,
...@@ -1144,33 +1227,50 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S...@@ -1144,33 +1227,50 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
1144 if (optimize_mode != .Debug and skip_release) continue;1227 if (optimize_mode != .Debug and skip_release) continue;
11451228
1146 for (c_abi_targets) |c_abi_target| {1229 for (c_abi_targets) |c_abi_target| {
1147 if (skip_non_native and !c_abi_target.isNative()) continue;1230 if (skip_non_native and !c_abi_target.target.isNative()) continue;
11481231
1149 if (c_abi_target.isWindows() and c_abi_target.getCpuArch() == .aarch64) {1232 if (c_abi_target.target.isWindows() and c_abi_target.target.getCpuArch() == .aarch64) {
1150 // https://github.com/ziglang/zig/issues/149081233 // https://github.com/ziglang/zig/issues/14908
1151 continue;1234 continue;
1152 }1235 }
11531236
1154 const triple_prefix = c_abi_target.zigTriple(b.allocator) catch @panic("OOM");1237 if (c_abi_target.use_llvm == false and optimize_mode == .ReleaseFast) {
1238 // panic: unrecognized command line argument
1239 continue;
1240 }
11551241
1156 const test_step = b.addTest(.{1242 const test_step = b.addTest(.{
1243 .name = b.fmt("test-c-abi-{s}-{s}-{s}{s}{s}", .{
1244 c_abi_target.target.zigTriple(b.allocator) catch @panic("OOM"),
1245 c_abi_target.target.getCpuModel().name,
1246 @tagName(optimize_mode),
1247 if (c_abi_target.use_llvm == true)
1248 "-llvm"
1249 else if (c_abi_target.target.ofmt == std.Target.ObjectFormat.c)
1250 "-cbe"
1251 else if (c_abi_target.use_llvm == false)
1252 "-selfhosted"
1253 else
1254 "",
1255 if (c_abi_target.use_lld == false) "-no-lld" else "",
1256 }),
1157 .root_source_file = .{ .path = "test/c_abi/main.zig" },1257 .root_source_file = .{ .path = "test/c_abi/main.zig" },
1258 .target = c_abi_target.target,
1158 .optimize = optimize_mode,1259 .optimize = optimize_mode,
1159 .target = c_abi_target,1260 .link_libc = true,
1160 .name = b.fmt("test-c-abi-{s}-{s}", .{1261 .use_llvm = c_abi_target.use_llvm,
1161 triple_prefix, @tagName(optimize_mode),1262 .use_lld = c_abi_target.use_lld,
1162 }),
1163 });1263 });
1164 if (c_abi_target.abi != null and c_abi_target.abi.?.isMusl()) {1264 if (c_abi_target.target.abi != null and c_abi_target.target.abi.?.isMusl()) {
1165 // TODO NativeTargetInfo insists on dynamically linking musl1265 // TODO NativeTargetInfo insists on dynamically linking musl
1166 // for some reason?1266 // for some reason?
1167 test_step.target_info.dynamic_linker.max_byte = null;1267 test_step.target_info.dynamic_linker.max_byte = null;
1168 }1268 }
1169 test_step.linkLibC();
1170 test_step.addCSourceFile(.{1269 test_step.addCSourceFile(.{
1171 .file = .{ .path = "test/c_abi/cfuncs.c" },1270 .file = .{ .path = "test/c_abi/cfuncs.c" },
1172 .flags = &.{"-std=c99"},1271 .flags = &.{"-std=c99"},
1173 });1272 });
1273 for (c_abi_target.c_defines) |define| test_step.defineCMacro(define, null);
11741274
1175 // This test is intentionally trying to check if the external ABI is1275 // This test is intentionally trying to check if the external ABI is
1176 // done properly. LTO would be a hindrance to this.1276 // done properly. LTO would be a hindrance to this.