authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-06-05 14:35:45+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-06-05 21:50:56+02:00
log98cf81d51c7c5b5cd6b6840007ce05cd0cc94143
treecb87c382c46c02d1cdabd2d757b36506ec875833
parentadc4418bae54e51921cde937d96faebf576f6d0c

test: Expand target coverage for C ABI tests.


3 files changed, 396 insertions(+), 123 deletions(-)

test/c_abi/cfuncs.c+53-9
...@@ -37,6 +37,10 @@ static void assert_or_panic(bool ok) {...@@ -37,6 +37,10 @@ static void assert_or_panic(bool ok) {
37# define ZIG_NO_I12837# define ZIG_NO_I128
38#endif38#endif
3939
40#ifdef __hexagon__
41# define ZIG_NO_I128
42#endif
43
40#ifdef __mips__44#ifdef __mips__
41# define ZIG_NO_I12845# define ZIG_NO_I128
42#endif46#endif
...@@ -77,6 +81,14 @@ static void assert_or_panic(bool ok) {...@@ -77,6 +81,14 @@ static void assert_or_panic(bool ok) {
77#define ZIG_NO_RAW_F1681#define ZIG_NO_RAW_F16
78#endif82#endif
7983
84#ifdef __hexagon__
85#define ZIG_NO_RAW_F16
86#endif
87
88#ifdef __loongarch__
89#define ZIG_NO_RAW_F16
90#endif
91
80#ifdef __mips__92#ifdef __mips__
81#define ZIG_NO_RAW_F1693#define ZIG_NO_RAW_F16
82#endif94#endif
...@@ -85,6 +97,10 @@ static void assert_or_panic(bool ok) {...@@ -85,6 +97,10 @@ static void assert_or_panic(bool ok) {
85#define ZIG_NO_RAW_F1697#define ZIG_NO_RAW_F16
86#endif98#endif
8799
100#ifdef __s390x__
101#define ZIG_NO_RAW_F16
102#endif
103
88#ifdef __wasm__104#ifdef __wasm__
89#define ZIG_NO_RAW_F16105#define ZIG_NO_RAW_F16
90#endif106#endif
...@@ -101,6 +117,14 @@ static void assert_or_panic(bool ok) {...@@ -101,6 +117,14 @@ static void assert_or_panic(bool ok) {
101#define ZIG_NO_F128117#define ZIG_NO_F128
102#endif118#endif
103119
120#ifdef __hexagon__
121#define ZIG_NO_F128
122#endif
123
124#ifdef __loongarch__
125#define ZIG_NO_F128
126#endif
127
104#ifdef __mips__128#ifdef __mips__
105#define ZIG_NO_F128129#define ZIG_NO_F128
106#endif130#endif
...@@ -113,6 +137,10 @@ static void assert_or_panic(bool ok) {...@@ -113,6 +137,10 @@ static void assert_or_panic(bool ok) {
113#define ZIG_NO_F128137#define ZIG_NO_F128
114#endif138#endif
115139
140#ifdef __s390x__
141#define ZIG_NO_F128
142#endif
143
116#ifdef __APPLE__144#ifdef __APPLE__
117#define ZIG_NO_F128145#define ZIG_NO_F128
118#endif146#endif
...@@ -2713,18 +2741,24 @@ void run_c_tests(void) {...@@ -2713,18 +2741,24 @@ void run_c_tests(void) {
2713 }2741 }
27142742
2715#if !defined(ZIG_RISCV64)2743#if !defined(ZIG_RISCV64)
2744#if !defined(__mips64__)
2716 {2745 {
2717 struct Struct_f32 s = zig_ret_struct_f32();2746 struct Struct_f32 s = zig_ret_struct_f32();
2718 assert_or_panic(s.a == 2.5f);2747 assert_or_panic(s.a == 2.5f);
2719 zig_struct_f32((struct Struct_f32){ 2.5f });2748 zig_struct_f32((struct Struct_f32){ 2.5f });
2720 }2749 }
2750#endif
27212751
2752#if !(defined(__arm__) && defined(__SOFTFP__))
2753#if !defined(ZIG_RISCV32)
2722 {2754 {
2723 struct Struct_f64 s = zig_ret_struct_f64();2755 struct Struct_f64 s = zig_ret_struct_f64();
2724 assert_or_panic(s.a == 2.5);2756 assert_or_panic(s.a == 2.5);
2725 zig_struct_f64((struct Struct_f64){ 2.5 });2757 zig_struct_f64((struct Struct_f64){ 2.5 });
2726 }2758 }
2759#endif
27272760
2761#if !defined(__loongarch__) && !defined(__mips64__)
2728 {2762 {
2729 struct Struct_f32f32_f32 s = zig_ret_struct_f32f32_f32();2763 struct Struct_f32f32_f32 s = zig_ret_struct_f32f32_f32();
2730 assert_or_panic(s.a.b == 1.0f);2764 assert_or_panic(s.a.b == 1.0f);
...@@ -2741,8 +2775,10 @@ void run_c_tests(void) {...@@ -2741,8 +2775,10 @@ void run_c_tests(void) {
2741 zig_struct_f32_f32f32((struct Struct_f32_f32f32){ 1.0f, { 2.0f, 3.0f } });2775 zig_struct_f32_f32f32((struct Struct_f32_f32f32){ 1.0f, { 2.0f, 3.0f } });
2742 }2776 }
2743#endif2777#endif
2778#endif
2779#endif
27442780
2745#if !defined(__powerpc__)2781#if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__)
2746 {2782 {
2747 struct Struct_u32_Union_u32_u32u32 s = zig_ret_struct_u32_union_u32_u32u32();2783 struct Struct_u32_Union_u32_u32u32 s = zig_ret_struct_u32_union_u32_u32u32();
2748 assert_or_panic(s.a == 1);2784 assert_or_panic(s.a == 1);
...@@ -2750,20 +2786,24 @@ void run_c_tests(void) {...@@ -2750,20 +2786,24 @@ void run_c_tests(void) {
2750 assert_or_panic(s.b.c.e == 3);2786 assert_or_panic(s.b.c.e == 3);
2751 zig_struct_u32_union_u32_u32u32(s);2787 zig_struct_u32_union_u32_u32u32(s);
2752 }2788 }
2789
2753 {2790 {
2754 struct Struct_i32_i32 s = {1, 2};2791 struct Struct_i32_i32 s = {1, 2};
2755 zig_struct_i32_i32(s);2792 zig_struct_i32_i32(s);
2756 }2793 }
2757#endif2794#endif
27582795
2796#if !defined(__powerpc64__) && !defined(__loongarch__) && !defined(__mips64__)
2759 {2797 {
2760 struct BigStruct s = {1, 2, 3, 4, 5};2798 struct BigStruct s = {1, 2, 3, 4, 5};
2761 zig_big_struct(s);2799 zig_big_struct(s);
2762 }2800 }
2763#endif2801#endif
2802#endif
27642803
2765#if !defined __i386__ && !defined __arm__ && !defined __aarch64__ && \2804#if !defined __i386__ && !defined __arm__ && !defined __aarch64__ && \
2766 !defined __powerpc__ && !defined ZIG_RISCV642805 !defined __powerpc__ && !defined ZIG_RISCV64 && !defined(__loongarch__) && \
2806 !defined(__mips64__)
2767 {2807 {
2768 struct SmallStructInts s = {1, 2, 3, 4};2808 struct SmallStructInts s = {1, 2, 3, 4};
2769 zig_small_struct_ints(s);2809 zig_small_struct_ints(s);
...@@ -2771,7 +2811,8 @@ void run_c_tests(void) {...@@ -2771,7 +2811,8 @@ void run_c_tests(void) {
2771#endif2811#endif
27722812
2773#if !defined __arm__ && !defined __aarch64__ && \2813#if !defined __arm__ && !defined __aarch64__ && \
2774 !defined __powerpc__ && !defined ZIG_RISCV642814 !defined __powerpc__ && !defined ZIG_RISCV64 && !defined(__loongarch__) && \
2815 !defined(__mips64__)
2775 {2816 {
2776 struct MedStructInts s = {1, 2, 3};2817 struct MedStructInts s = {1, 2, 3};
2777 zig_med_struct_ints(s);2818 zig_med_struct_ints(s);
...@@ -2797,14 +2838,16 @@ void run_c_tests(void) {...@@ -2797,14 +2838,16 @@ void run_c_tests(void) {
2797 }2838 }
27982839
2799#if !defined __i386__ && !defined __arm__ && \2840#if !defined __i386__ && !defined __arm__ && \
2800 !defined ZIG_PPC32 && !defined _ARCH_PPC642841 !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
2842 !defined(__mips64__)
2801 {2843 {
2802 struct SplitStructInts s = {1234, 100, 1337};2844 struct SplitStructInts s = {1234, 100, 1337};
2803 zig_split_struct_ints(s);2845 zig_split_struct_ints(s);
2804 }2846 }
2805#endif2847#endif
28062848
2807#if !defined __arm__ && !defined ZIG_PPC32 && !defined _ARCH_PPC642849#if !defined __arm__ && !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
2850 !defined(__mips64__)
2808 {2851 {
2809 struct MedStructMixed s = {1234, 100.0f, 1337.0f};2852 struct MedStructMixed s = {1234, 100.0f, 1337.0f};
2810 zig_med_struct_mixed(s);2853 zig_med_struct_mixed(s);
...@@ -2812,14 +2855,15 @@ void run_c_tests(void) {...@@ -2812,14 +2855,15 @@ void run_c_tests(void) {
2812#endif2855#endif
28132856
2814#if !defined __i386__ && !defined __arm__ && \2857#if !defined __i386__ && !defined __arm__ && \
2815 !defined ZIG_PPC32 && !defined _ARCH_PPC642858 !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
2859 !defined(__mips64__)
2816 {2860 {
2817 struct SplitStructMixed s = {1234, 100, 1337.0f};2861 struct SplitStructMixed s = {1234, 100, 1337.0f};
2818 zig_split_struct_mixed(s);2862 zig_split_struct_mixed(s);
2819 }2863 }
2820#endif2864#endif
28212865
2822#if !defined ZIG_PPC322866#if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__)
2823 {2867 {
2824 struct BigStruct s = {30, 31, 32, 33, 34};2868 struct BigStruct s = {30, 31, 32, 33, 34};
2825 struct BigStruct res = zig_big_struct_both(s);2869 struct BigStruct res = zig_big_struct_both(s);
...@@ -2831,7 +2875,7 @@ void run_c_tests(void) {...@@ -2831,7 +2875,7 @@ void run_c_tests(void) {
2831 }2875 }
2832#endif2876#endif
28332877
2834#if !defined ZIG_PPC32 && !defined _ARCH_PPC642878#if !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && !defined(__mips64__)
2835 {2879 {
2836 struct Rect r1 = {1, 21, 16, 4};2880 struct Rect r1 = {1, 21, 16, 4};
2837 struct Rect r2 = {178, 189, 21, 15};2881 struct Rect r2 = {178, 189, 21, 15};
...@@ -2839,7 +2883,7 @@ void run_c_tests(void) {...@@ -2839,7 +2883,7 @@ void run_c_tests(void) {
2839 }2883 }
2840#endif2884#endif
28412885
2842#if !defined ZIG_PPC322886#if !defined ZIG_PPC32 && !defined(__loongarch__) && !defined(__mips64__)
2843 {2887 {
2844 struct FloatRect r1 = {1, 21, 16, 4};2888 struct FloatRect r1 = {1, 21, 16, 4};
2845 struct FloatRect r2 = {178, 189, 21, 15};2889 struct FloatRect r2 = {178, 189, 21, 15};
test/c_abi/main.zig+56-9
...@@ -11,7 +11,7 @@ const print = std.debug.print;...@@ -11,7 +11,7 @@ const print = std.debug.print;
11const expect = std.testing.expect;11const expect = std.testing.expect;
12const expectEqual = std.testing.expectEqual;12const expectEqual = std.testing.expectEqual;
13const have_i128 = builtin.cpu.arch != .x86 and !builtin.cpu.arch.isArm() and13const have_i128 = builtin.cpu.arch != .x86 and !builtin.cpu.arch.isArm() and
14 !builtin.cpu.arch.isMIPS() and !builtin.cpu.arch.isPowerPC32();14 !builtin.cpu.arch.isMIPS() and !builtin.cpu.arch.isPowerPC32() and builtin.cpu.arch != .riscv32;
1515
16const have_f128 = builtin.cpu.arch.isWasm() or (builtin.cpu.arch.isX86() and !builtin.os.tag.isDarwin());16const have_f128 = builtin.cpu.arch.isWasm() or (builtin.cpu.arch.isX86() and !builtin.os.tag.isDarwin());
17const have_f80 = builtin.cpu.arch.isX86();17const have_f80 = builtin.cpu.arch.isX86();
...@@ -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.cpu.arch.isMIPS64()) 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);
...@@ -383,6 +385,8 @@ extern fn c_struct_f64(Struct_f64) void;...@@ -383,6 +385,8 @@ extern fn c_struct_f64(Struct_f64) void;
383test "C ABI struct f64" {385test "C ABI struct f64" {
384 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;386 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
385 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;387 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
388 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
389 if (builtin.cpu.arch == .riscv32) return error.SkipZigTest;
386390
387 const s = c_ret_struct_f64();391 const s = c_ret_struct_f64();
388 try expect(s.a == 2.5);392 try expect(s.a == 2.5);
...@@ -411,6 +415,8 @@ extern fn c_struct_f32f32_f32(Struct_f32f32_f32) void;...@@ -411,6 +415,8 @@ extern fn c_struct_f32f32_f32(Struct_f32f32_f32) void;
411test "C ABI struct {f32,f32} f32" {415test "C ABI struct {f32,f32} f32" {
412 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;416 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
413 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;417 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
418 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
419 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
414420
415 const s = c_ret_struct_f32f32_f32();421 const s = c_ret_struct_f32f32_f32();
416 try expect(s.a.b == 1.0);422 try expect(s.a.b == 1.0);
...@@ -441,6 +447,8 @@ extern fn c_struct_f32_f32f32(Struct_f32_f32f32) void;...@@ -441,6 +447,8 @@ extern fn c_struct_f32_f32f32(Struct_f32_f32f32) void;
441test "C ABI struct f32 {f32,f32}" {447test "C ABI struct f32 {f32,f32}" {
442 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;448 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
443 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;449 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
450 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
451 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
444452
445 const s = c_ret_struct_f32_f32f32();453 const s = c_ret_struct_f32_f32f32();
446 try expect(s.a == 1.0);454 try expect(s.a == 1.0);
...@@ -476,6 +484,7 @@ extern fn c_struct_u32_union_u32_u32u32(Struct_u32_Union_u32_u32u32) void;...@@ -476,6 +484,7 @@ extern fn c_struct_u32_union_u32_u32u32(Struct_u32_Union_u32_u32u32) void;
476test "C ABI struct{u32,union{u32,struct{u32,u32}}}" {484test "C ABI struct{u32,union{u32,struct{u32,u32}}}" {
477 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;485 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
478 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;486 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
487 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
479488
480 const s = c_ret_struct_u32_union_u32_u32u32();489 const s = c_ret_struct_u32_union_u32_u32u32();
481 try expect(s.a == 1);490 try expect(s.a == 1);
...@@ -494,6 +503,8 @@ extern fn c_struct_i32_i32(Struct_i32_i32) void;...@@ -494,6 +503,8 @@ extern fn c_struct_i32_i32(Struct_i32_i32) void;
494test "C ABI struct i32 i32" {503test "C ABI struct i32 i32" {
495 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;504 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
496 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;505 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
506 if (builtin.cpu.arch == .riscv32) return error.SkipZigTest;
507 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
497508
498 const s: Struct_i32_i32 = .{509 const s: Struct_i32_i32 = .{
499 .a = 1,510 .a = 1,
...@@ -523,7 +534,8 @@ extern fn c_big_struct(BigStruct) void;...@@ -523,7 +534,8 @@ extern fn c_big_struct(BigStruct) void;
523534
524test "C ABI big struct" {535test "C ABI big struct" {
525 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;536 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
526 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;537 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
538 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
527539
528 const s = BigStruct{540 const s = BigStruct{
529 .a = 1,541 .a = 1,
...@@ -550,6 +562,7 @@ extern fn c_big_union(BigUnion) void;...@@ -550,6 +562,7 @@ extern fn c_big_union(BigUnion) void;
550562
551test "C ABI big union" {563test "C ABI big union" {
552 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;564 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
565 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
553566
554 const x = BigUnion{567 const x = BigUnion{
555 .a = BigStruct{568 .a = BigStruct{
...@@ -583,6 +596,7 @@ extern fn c_ret_med_struct_mixed() MedStructMixed;...@@ -583,6 +596,7 @@ extern fn c_ret_med_struct_mixed() MedStructMixed;
583test "C ABI medium struct of ints and floats" {596test "C ABI medium struct of ints and floats" {
584 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;597 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
585 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;598 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
599 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
586600
587 const s = MedStructMixed{601 const s = MedStructMixed{
588 .a = 1234,602 .a = 1234,
...@@ -615,6 +629,8 @@ test "C ABI small struct of ints" {...@@ -615,6 +629,8 @@ test "C ABI small struct of ints" {
615 if (builtin.cpu.arch == .x86) return error.SkipZigTest;629 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
616 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;630 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
617 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;631 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
632 if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest;
633 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
618634
619 const s = SmallStructInts{635 const s = SmallStructInts{
620 .a = 1,636 .a = 1,
...@@ -648,6 +664,7 @@ extern fn c_ret_med_struct_ints() MedStructInts;...@@ -648,6 +664,7 @@ extern fn c_ret_med_struct_ints() MedStructInts;
648test "C ABI medium struct of ints" {664test "C ABI medium struct of ints" {
649 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;665 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
650 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;666 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
667 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
651668
652 const s = MedStructInts{669 const s = MedStructInts{
653 .x = 1,670 .x = 1,
...@@ -726,6 +743,7 @@ test "C ABI split struct of ints" {...@@ -726,6 +743,7 @@ test "C ABI split struct of ints" {
726 if (builtin.cpu.arch == .x86) return error.SkipZigTest;743 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
727 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;744 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
728 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;745 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
746 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
729747
730 const s = SplitStructInt{748 const s = SplitStructInt{
731 .a = 1234,749 .a = 1234,
...@@ -753,6 +771,7 @@ test "C ABI split struct of ints and floats" {...@@ -753,6 +771,7 @@ test "C ABI split struct of ints and floats" {
753 if (builtin.cpu.arch == .x86) return error.SkipZigTest;771 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
754 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;772 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
755 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;773 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
774 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
756775
757 const s = SplitStructMixed{776 const s = SplitStructMixed{
758 .a = 1234,777 .a = 1234,
...@@ -779,7 +798,8 @@ extern fn c_multiple_struct_floats(FloatRect, FloatRect) void;...@@ -779,7 +798,8 @@ extern fn c_multiple_struct_floats(FloatRect, FloatRect) void;
779798
780test "C ABI sret and byval together" {799test "C ABI sret and byval together" {
781 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;800 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
782 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;801 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
802 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
783803
784 const s = BigStruct{804 const s = BigStruct{
785 .a = 1,805 .a = 1,
...@@ -832,6 +852,7 @@ extern fn c_big_struct_floats(Vector5) void;...@@ -832,6 +852,7 @@ extern fn c_big_struct_floats(Vector5) void;
832test "C ABI structs of floats as parameter" {852test "C ABI structs of floats as parameter" {
833 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;853 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
834 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;854 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
855 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
835856
836 const v3 = Vector3{857 const v3 = Vector3{
837 .x = 3.0,858 .x = 3.0,
...@@ -871,6 +892,8 @@ export fn zig_multiple_struct_ints(x: Rect, y: Rect) void {...@@ -871,6 +892,8 @@ export fn zig_multiple_struct_ints(x: Rect, y: Rect) void {
871892
872test "C ABI structs of ints as multiple parameters" {893test "C ABI structs of ints as multiple parameters" {
873 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;894 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
895 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
896 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
874897
875 const r1 = Rect{898 const r1 = Rect{
876 .left = 1,899 .left = 1,
...@@ -908,6 +931,7 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {...@@ -908,6 +931,7 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {
908test "C ABI structs of floats as multiple parameters" {931test "C ABI structs of floats as multiple parameters" {
909 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;932 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
910 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;933 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
934 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
911935
912 const r1 = FloatRect{936 const r1 = FloatRect{
913 .left = 1,937 .left = 1,
...@@ -1021,6 +1045,7 @@ test "Struct with array as padding." {...@@ -1021,6 +1045,7 @@ test "Struct with array as padding." {
1021 if (builtin.cpu.arch == .x86) return error.SkipZigTest;1045 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
1022 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;1046 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
1023 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;1047 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
1048 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
10241049
1025 c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 });1050 c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 });
10261051
...@@ -1046,6 +1071,7 @@ extern fn c_ret_float_array_struct() FloatArrayStruct;...@@ -1046,6 +1071,7 @@ extern fn c_ret_float_array_struct() FloatArrayStruct;
1046test "Float array like struct" {1071test "Float array like struct" {
1047 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;1072 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
1048 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;1073 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
1074 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
10491075
1050 c_float_array_struct(.{1076 c_float_array_struct(.{
1051 .origin = .{1077 .origin = .{
...@@ -1073,6 +1099,7 @@ extern fn c_ret_small_vec() SmallVec;...@@ -1073,6 +1099,7 @@ extern fn c_ret_small_vec() SmallVec;
1073test "small simd vector" {1099test "small simd vector" {
1074 if (builtin.cpu.arch == .x86) return error.SkipZigTest;1100 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
1075 if (builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest;1101 if (builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest;
1102 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
10761103
1077 c_small_vec(.{ 1, 2 });1104 c_small_vec(.{ 1, 2 });
10781105
...@@ -1134,7 +1161,8 @@ extern fn c_ret_vector_2_float() Vector2Float;...@@ -1134,7 +1161,8 @@ extern fn c_ret_vector_2_float() Vector2Float;
1134extern fn c_ret_vector_4_float() Vector4Float;1161extern fn c_ret_vector_4_float() Vector4Float;
11351162
1136test "float simd vectors" {1163test "float simd vectors" {
1137 if (builtin.cpu.arch == .powerpc or builtin.cpu.arch == .powerpc64le) return error.SkipZigTest;1164 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
1165 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
11381166
1139 {1167 {
1140 c_vector_2_float(.{ 1.0, 2.0 });1168 c_vector_2_float(.{ 1.0, 2.0 });
...@@ -5419,6 +5447,7 @@ test "C ABI pointer sized float struct" {...@@ -5419,6 +5447,7 @@ test "C ABI pointer sized float struct" {
5419 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5447 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5420 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;5448 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
5421 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;5449 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
5450 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
54225451
5423 c_ptr_size_float_struct(.{ .x = 1, .y = 2 });5452 c_ptr_size_float_struct(.{ .x = 1, .y = 2 });
54245453
...@@ -5441,24 +5470,28 @@ test "DC: Zig passes to C" {...@@ -5441,24 +5470,28 @@ test "DC: Zig passes to C" {
5441 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5470 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5442 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;5471 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
5443 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5472 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5473 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5444 try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));5474 try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));
5445}5475}
5446test "DC: Zig returns to C" {5476test "DC: Zig returns to C" {
5447 if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest;5477 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5448 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;5478 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
5449 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5479 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5480 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5450 try expectOk(c_assert_ret_DC());5481 try expectOk(c_assert_ret_DC());
5451}5482}
5452test "DC: C passes to Zig" {5483test "DC: C passes to Zig" {
5453 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5484 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5454 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;5485 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
5455 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5486 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5487 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5456 try expectOk(c_send_DC());5488 try expectOk(c_send_DC());
5457}5489}
5458test "DC: C returns to Zig" {5490test "DC: C returns to Zig" {
5459 if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest;5491 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5460 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;5492 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
5461 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5493 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5494 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5462 try expectEqual(DC{ .v1 = -0.25, .v2 = 15 }, c_ret_DC());5495 try expectEqual(DC{ .v1 = -0.25, .v2 = 15 }, c_ret_DC());
5463}5496}
54645497
...@@ -5484,11 +5517,13 @@ test "CFF: Zig passes to C" {...@@ -5484,11 +5517,13 @@ test "CFF: Zig passes to C" {
5484 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;5517 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
5485 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5518 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5486 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5519 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5520 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5487 try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));5521 try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));
5488}5522}
5489test "CFF: Zig returns to C" {5523test "CFF: Zig returns to C" {
5490 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5524 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5491 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5525 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5526 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5492 try expectOk(c_assert_ret_CFF());5527 try expectOk(c_assert_ret_CFF());
5493}5528}
5494test "CFF: C passes to Zig" {5529test "CFF: C passes to Zig" {
...@@ -5497,6 +5532,7 @@ test "CFF: C passes to Zig" {...@@ -5497,6 +5532,7 @@ test "CFF: C passes to Zig" {
5497 if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;5532 if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;
5498 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5533 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5499 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5534 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5535 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
55005536
5501 try expectOk(c_send_CFF());5537 try expectOk(c_send_CFF());
5502}5538}
...@@ -5505,6 +5541,7 @@ test "CFF: C returns to Zig" {...@@ -5505,6 +5541,7 @@ test "CFF: C returns to Zig" {
5505 if (builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;5541 if (builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;
5506 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5542 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5507 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5543 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5544 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5508 try expectEqual(CFF{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }, c_ret_CFF());5545 try expectEqual(CFF{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }, c_ret_CFF());
5509}5546}
5510pub extern fn c_assert_CFF(lv: CFF) c_int;5547pub extern fn c_assert_CFF(lv: CFF) c_int;
...@@ -5529,21 +5566,25 @@ const PD = extern struct { v1: ?*anyopaque, v2: f64 };...@@ -5529,21 +5566,25 @@ const PD = extern struct { v1: ?*anyopaque, v2: f64 };
5529test "PD: Zig passes to C" {5566test "PD: Zig passes to C" {
5530 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5567 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5531 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5568 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5569 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5532 try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 }));5570 try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 }));
5533}5571}
5534test "PD: Zig returns to C" {5572test "PD: Zig returns to C" {
5535 if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest;5573 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5536 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5574 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5575 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5537 try expectOk(c_assert_ret_PD());5576 try expectOk(c_assert_ret_PD());
5538}5577}
5539test "PD: C passes to Zig" {5578test "PD: C passes to Zig" {
5540 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5579 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5541 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5580 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5581 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5542 try expectOk(c_send_PD());5582 try expectOk(c_send_PD());
5543}5583}
5544test "PD: C returns to Zig" {5584test "PD: C returns to Zig" {
5545 if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest;5585 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5546 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5586 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5587 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5547 try expectEqual(PD{ .v1 = null, .v2 = 0.5 }, c_ret_PD());5588 try expectEqual(PD{ .v1 = null, .v2 = 0.5 }, c_ret_PD());
5548}5589}
5549pub extern fn c_assert_PD(lv: PD) c_int;5590pub extern fn c_assert_PD(lv: PD) c_int;
...@@ -5576,6 +5617,7 @@ extern fn c_modify_by_ref_param(ByRef) ByRef;...@@ -5576,6 +5617,7 @@ extern fn c_modify_by_ref_param(ByRef) ByRef;
55765617
5577test "C function modifies by ref param" {5618test "C function modifies by ref param" {
5578 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;5619 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
5620 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
55795621
5580 const res = c_modify_by_ref_param(.{ .val = 1, .arr = undefined });5622 const res = c_modify_by_ref_param(.{ .val = 1, .arr = undefined });
5581 try expect(res.val == 42);5623 try expect(res.val == 42);
...@@ -5596,8 +5638,9 @@ const ByVal = extern struct {...@@ -5596,8 +5638,9 @@ const ByVal = extern struct {
55965638
5597extern fn c_func_ptr_byval(*anyopaque, *anyopaque, ByVal, c_ulong, *anyopaque, c_ulong) void;5639extern fn c_func_ptr_byval(*anyopaque, *anyopaque, ByVal, c_ulong, *anyopaque, c_ulong) void;
5598test "C function that takes byval struct called via function pointer" {5640test "C function that takes byval struct called via function pointer" {
5599 if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest;5641 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5600 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;5642 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
5643 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
56015644
5602 var fn_ptr = &c_func_ptr_byval;5645 var fn_ptr = &c_func_ptr_byval;
5603 _ = &fn_ptr;5646 _ = &fn_ptr;
...@@ -5736,6 +5779,8 @@ extern fn stdcall_coord2(Coord2, Coord2, Coord2) callconv(stdcall_callconv) Coor...@@ -5736,6 +5779,8 @@ extern fn stdcall_coord2(Coord2, Coord2, Coord2) callconv(stdcall_callconv) Coor
5736test "Stdcall ABI structs" {5779test "Stdcall ABI structs" {
5737 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5780 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5738 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;5781 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
5782 if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest;
5783 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
57395784
5740 const res = stdcall_coord2(5785 const res = stdcall_coord2(
5741 .{ .x = 0x1111, .y = 0x2222 },5786 .{ .x = 0x1111, .y = 0x2222 },
...@@ -5749,6 +5794,7 @@ test "Stdcall ABI structs" {...@@ -5749,6 +5794,7 @@ test "Stdcall ABI structs" {
5749extern fn stdcall_big_union(BigUnion) callconv(stdcall_callconv) void;5794extern fn stdcall_big_union(BigUnion) callconv(stdcall_callconv) void;
5750test "Stdcall ABI big union" {5795test "Stdcall ABI big union" {
5751 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;5796 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
5797 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
57525798
5753 const x = BigUnion{5799 const x = BigUnion{
5754 .a = BigStruct{5800 .a = BigStruct{
...@@ -5821,6 +5867,7 @@ const byval_tail_callsite_attr = struct {...@@ -5821,6 +5867,7 @@ const byval_tail_callsite_attr = struct {
5821test "byval tail callsite attribute" {5867test "byval tail callsite attribute" {
5822 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;5868 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
5823 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;5869 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
5870 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
58245871
5825 // Originally reported at https://github.com/ziglang/zig/issues/162905872 // Originally reported at https://github.com/ziglang/zig/issues/16290
5826 // the bug was that the extern function had the byval attribute, but5873 // the bug was that the extern function had the byval attribute, but
test/tests.zig+287-105
...@@ -1597,137 +1597,319 @@ const CAbiTarget = struct {...@@ -1597,137 +1597,319 @@ const CAbiTarget = struct {
1597 c_defines: []const []const u8 = &.{},1597 c_defines: []const []const u8 = &.{},
1598};1598};
15991599
1600const c_abi_targets = [_]CAbiTarget{1600const c_abi_targets = blk: {
1601 // Native Targets1601 @setEvalBranchQuota(20000);
1602 break :blk [_]CAbiTarget{
1603 // Native Targets
16021604
1603 .{},1605 .{},
16041606
1605 // Linux Targets1607 // Linux Targets
16061608
1607 .{1609 .{
1608 .target = .{1610 .target = .{
1609 .cpu_arch = .aarch64,1611 .cpu_arch = .aarch64,
1610 .os_tag = .linux,1612 .os_tag = .linux,
1611 .abi = .musl,1613 .abi = .musl,
1614 },
1612 },1615 },
1613 },
16141616
1615 .{1617 .{
1616 .target = .{1618 .target = .{
1617 .cpu_arch = .arm,1619 .cpu_arch = .aarch64_be,
1618 .os_tag = .linux,1620 .os_tag = .linux,
1619 .abi = .musleabihf,1621 .abi = .musl,
1622 },
1620 },1623 },
1621 },
16221624
1623 .{1625 .{
1624 .target = .{1626 .target = .{
1625 .cpu_arch = .mips,1627 .cpu_arch = .arm,
1626 .os_tag = .linux,1628 .os_tag = .linux,
1627 .abi = .musleabihf,1629 .abi = .musleabi,
1630 },
1631 },
1632 .{
1633 .target = .{
1634 .cpu_arch = .arm,
1635 .os_tag = .linux,
1636 .abi = .musleabihf,
1637 },
1628 },1638 },
1629 },
16301639
1631 .{1640 .{
1632 .target = .{1641 .target = .{
1633 .cpu_arch = .powerpc,1642 .cpu_arch = .armeb,
1634 .os_tag = .linux,1643 .os_tag = .linux,
1635 .abi = .musleabihf,1644 .abi = .musleabi,
1645 },
1646 },
1647 .{
1648 .target = .{
1649 .cpu_arch = .armeb,
1650 .os_tag = .linux,
1651 .abi = .musleabihf,
1652 },
1636 },1653 },
1637 },
16381654
1639 .{1655 // Crashes in LLVM instruction selection.
1640 .target = .{1656 // .{
1641 .cpu_arch = .powerpc64le,1657 // .target = .{
1642 .os_tag = .linux,1658 // .cpu_arch = .hexagon,
1643 .abi = .musl,1659 // .os_tag = .linux,
1660 // .abi = .musl,
1661 // },
1662 // },
1663
1664 .{
1665 .target = .{
1666 .cpu_arch = .loongarch64,
1667 .os_tag = .linux,
1668 .abi = .musl,
1669 },
1644 },1670 },
1645 },
16461671
1647 .{1672 .{
1648 .target = .{1673 .target = .{
1649 .cpu_arch = .riscv64,1674 .cpu_arch = .mips,
1650 .os_tag = .linux,1675 .os_tag = .linux,
1651 .abi = .musl,1676 .abi = .musleabi,
1677 },
1678 },
1679 .{
1680 .target = .{
1681 .cpu_arch = .mips,
1682 .os_tag = .linux,
1683 .abi = .musleabihf,
1684 },
1652 },1685 },
1653 },
16541686
1655 .{1687 .{
1656 .target = .{1688 .target = .{
1657 .cpu_arch = .x86,1689 .cpu_arch = .mipsel,
1658 .os_tag = .linux,1690 .os_tag = .linux,
1659 .abi = .musl,1691 .abi = .musleabi,
1692 },
1693 },
1694 .{
1695 .target = .{
1696 .cpu_arch = .mipsel,
1697 .os_tag = .linux,
1698 .abi = .musleabihf,
1699 },
1660 },1700 },
1661 },
16621701
1663 .{1702 .{
1664 .target = .{1703 .target = .{
1665 .cpu_arch = .x86_64,1704 .cpu_arch = .mips64,
1666 .os_tag = .linux,1705 .os_tag = .linux,
1667 .abi = .musl,1706 .abi = .muslabi64,
1668 },1707 },
1669 .use_llvm = false,
1670 .use_lld = false,
1671 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
1672 },
1673 .{
1674 .target = .{
1675 .cpu_arch = .x86_64,
1676 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
1677 .os_tag = .linux,
1678 .abi = .musl,
1679 },
1680 .use_llvm = false,
1681 .use_lld = false,
1682 .strip = true,
1683 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
1684 },
1685 .{
1686 .target = .{
1687 .cpu_arch = .x86_64,
1688 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
1689 .os_tag = .linux,
1690 .abi = .musl,
1691 },1708 },
1692 .use_llvm = false,1709 .{
1693 .use_lld = false,1710 .target = .{
1694 .pic = true,1711 .cpu_arch = .mips64,
1695 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},1712 .os_tag = .linux,
1696 },1713 .abi = .muslabin32,
1697 .{1714 },
1698 .target = .{1715 },
1699 .cpu_arch = .x86_64,1716
1700 .os_tag = .linux,1717 .{
1701 .abi = .musl,1718 .target = .{
1719 .cpu_arch = .mips64el,
1720 .os_tag = .linux,
1721 .abi = .muslabi64,
1722 },
1723 },
1724 .{
1725 .target = .{
1726 .cpu_arch = .mips64el,
1727 .os_tag = .linux,
1728 .abi = .muslabin32,
1729 },
1730 },
1731
1732 .{
1733 .target = .{
1734 .cpu_arch = .powerpc,
1735 .os_tag = .linux,
1736 .abi = .musleabi,
1737 },
1738 },
1739 .{
1740 .target = .{
1741 .cpu_arch = .powerpc,
1742 .os_tag = .linux,
1743 .abi = .musleabihf,
1744 },
1745 },
1746
1747 .{
1748 .target = .{
1749 .cpu_arch = .powerpc64,
1750 .os_tag = .linux,
1751 .abi = .musl,
1752 },
1753 },
1754 .{
1755 .target = .{
1756 .cpu_arch = .powerpc64le,
1757 .os_tag = .linux,
1758 .abi = .musl,
1759 },
1702 },1760 },
1703 },
17041761
1705 // WASI Targets1762 .{
1763 .target = std.Target.Query.parse(.{
1764 .arch_os_abi = "riscv32-linux-musl",
1765 .cpu_features = "baseline-d-f",
1766 }) catch unreachable,
1767 },
1768 .{
1769 .target = .{
1770 .cpu_arch = .riscv32,
1771 .os_tag = .linux,
1772 .abi = .musl,
1773 },
1774 },
17061775
1707 .{1776 .{
1708 .target = .{1777 .target = std.Target.Query.parse(.{
1709 .cpu_arch = .wasm32,1778 .arch_os_abi = "riscv64-linux-musl",
1710 .os_tag = .wasi,1779 .cpu_features = "baseline-d-f",
1711 .abi = .musl,1780 }) catch unreachable,
1781 },
1782 .{
1783 .target = .{
1784 .cpu_arch = .riscv64,
1785 .os_tag = .linux,
1786 .abi = .musl,
1787 },
1712 },1788 },
1713 },
17141789
1715 // Windows Targets1790 // Clang explodes when parsing `cfuncs.c`.
1791 // .{
1792 // .target = .{
1793 // .cpu_arch = .s390x,
1794 // .os_tag = .linux,
1795 // .abi = .musl,
1796 // },
1797 // },
1798
1799 .{
1800 .target = std.Target.Query.parse(.{
1801 .arch_os_abi = "thumb-linux-musleabi",
1802 .cpu_features = "baseline+long_calls",
1803 }) catch unreachable,
1804 .pic = false, // Long calls don't work with PIC.
1805 },
1806 .{
1807 .target = std.Target.Query.parse(.{
1808 .arch_os_abi = "thumb-linux-musleabihf",
1809 .cpu_features = "baseline+long_calls",
1810 }) catch unreachable,
1811 .pic = false, // Long calls don't work with PIC.
1812 },
17161813
1717 .{1814 .{
1718 .target = .{1815 .target = std.Target.Query.parse(.{
1719 .cpu_arch = .x86,1816 .arch_os_abi = "thumbeb-linux-musleabi",
1720 .os_tag = .windows,1817 .cpu_features = "baseline+long_calls",
1721 .abi = .gnu,1818 }) catch unreachable,
1819 .pic = false, // Long calls don't work with PIC.
1722 },1820 },
1723 },1821 .{
1724 .{1822 .target = std.Target.Query.parse(.{
1725 .target = .{1823 .arch_os_abi = "thumbeb-linux-musleabihf",
1726 .cpu_arch = .x86_64,1824 .cpu_features = "baseline+long_calls",
1727 .os_tag = .windows,1825 }) catch unreachable,
1728 .abi = .gnu,1826 .pic = false, // Long calls don't work with PIC.
1827 },
1828
1829 .{
1830 .target = .{
1831 .cpu_arch = .x86,
1832 .os_tag = .linux,
1833 .abi = .musl,
1834 },
1729 },1835 },
1730 },1836
1837 .{
1838 .target = .{
1839 .cpu_arch = .x86_64,
1840 .os_tag = .linux,
1841 .abi = .musl,
1842 },
1843 .use_llvm = false,
1844 .use_lld = false,
1845 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
1846 },
1847 .{
1848 .target = .{
1849 .cpu_arch = .x86_64,
1850 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
1851 .os_tag = .linux,
1852 .abi = .musl,
1853 },
1854 .use_llvm = false,
1855 .use_lld = false,
1856 .strip = true,
1857 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
1858 },
1859 .{
1860 .target = .{
1861 .cpu_arch = .x86_64,
1862 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
1863 .os_tag = .linux,
1864 .abi = .musl,
1865 },
1866 .use_llvm = false,
1867 .use_lld = false,
1868 .pic = true,
1869 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
1870 },
1871 .{
1872 .target = .{
1873 .cpu_arch = .x86_64,
1874 .os_tag = .linux,
1875 .abi = .musl,
1876 },
1877 },
1878 .{
1879 .target = .{
1880 .cpu_arch = .x86_64,
1881 .os_tag = .linux,
1882 .abi = .muslx32,
1883 },
1884 },
1885
1886 // WASI Targets
1887
1888 .{
1889 .target = .{
1890 .cpu_arch = .wasm32,
1891 .os_tag = .wasi,
1892 .abi = .musl,
1893 },
1894 },
1895
1896 // Windows Targets
1897
1898 .{
1899 .target = .{
1900 .cpu_arch = .x86,
1901 .os_tag = .windows,
1902 .abi = .gnu,
1903 },
1904 },
1905 .{
1906 .target = .{
1907 .cpu_arch = .x86_64,
1908 .os_tag = .windows,
1909 .abi = .gnu,
1910 },
1911 },
1912 };
1731};1913};
17321914
1733pub fn addCompareOutputTests(1915pub fn addCompareOutputTests(