authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-04 20:49:14+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-30 06:36:41+02:00
logf1491129516af8eb780127c292ab9a1975a7d189
tree4f27e48385dd0298e0760970cbe46c6f497a26d4
parentf6879c35af446c3ca3ef61f4b5b7d03d0e064769
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

test: expand C ABI test coverage to hexagon-linux-musl


3 files changed, 52 insertions(+), 19 deletions(-)

test/c_abi/cfuncs.c+14-9
......@@ -65,6 +65,10 @@ static void assert_or_panic(bool ok) {
6565# define ZIG_NO_COMPLEX
6666#endif
6767
68#ifdef __hexagon__
69# define ZIG_NO_COMPLEX
70#endif
71
6872#ifdef __powerpc__
6973# define ZIG_NO_COMPLEX
7074#endif
......@@ -2724,7 +2728,7 @@ void run_c_tests(void) {
27242728 }
27252729#endif
27262730
2727#if !defined(ZIG_PPC32)
2731#if !defined(ZIG_PPC32) && !defined(__hexagon__)
27282732 {
27292733 struct Struct_u64_u64 s = zig_ret_struct_u64_u64();
27302734 assert_or_panic(s.a == 1);
......@@ -2803,7 +2807,7 @@ void run_c_tests(void) {
28032807
28042808#if !defined __i386__ && !defined __arm__ && !defined __aarch64__ && \
28052809 !defined __powerpc__ && !defined ZIG_RISCV64 && !defined(__loongarch__) && \
2806 !defined(__mips64__)
2810 !defined(__mips64__) && !defined(__hexagon__)
28072811 {
28082812 struct SmallStructInts s = {1, 2, 3, 4};
28092813 zig_small_struct_ints(s);
......@@ -2812,7 +2816,7 @@ void run_c_tests(void) {
28122816
28132817#if !defined __arm__ && !defined __aarch64__ && \
28142818 !defined __powerpc__ && !defined ZIG_RISCV64 && !defined(__loongarch__) && \
2815 !defined(__mips64__)
2819 !defined(__mips64__) && !defined(__hexagon__)
28162820 {
28172821 struct MedStructInts s = {1, 2, 3};
28182822 zig_med_struct_ints(s);
......@@ -2839,7 +2843,7 @@ void run_c_tests(void) {
28392843
28402844#if !defined __i386__ && !defined __arm__ && \
28412845 !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
2842 !defined(__mips64__)
2846 !defined(__mips64__) && !defined(__hexagon__)
28432847 {
28442848 struct SplitStructInts s = {1234, 100, 1337};
28452849 zig_split_struct_ints(s);
......@@ -2847,7 +2851,7 @@ void run_c_tests(void) {
28472851#endif
28482852
28492853#if !defined __arm__ && !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
2850 !defined(__mips64__)
2854 !defined(__mips64__) && !defined(__hexagon__)
28512855 {
28522856 struct MedStructMixed s = {1234, 100.0f, 1337.0f};
28532857 zig_med_struct_mixed(s);
......@@ -2856,14 +2860,14 @@ void run_c_tests(void) {
28562860
28572861#if !defined __i386__ && !defined __arm__ && \
28582862 !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
2859 !defined(__mips64__)
2863 !defined(__mips64__) && !defined(__hexagon__)
28602864 {
28612865 struct SplitStructMixed s = {1234, 100, 1337.0f};
28622866 zig_split_struct_mixed(s);
28632867 }
28642868#endif
28652869
2866#if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__)
2870#if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__) && !defined(__hexagon__)
28672871 {
28682872 struct BigStruct s = {30, 31, 32, 33, 34};
28692873 struct BigStruct res = zig_big_struct_both(s);
......@@ -2875,7 +2879,8 @@ void run_c_tests(void) {
28752879 }
28762880#endif
28772881
2878#if !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && !defined(__mips64__)
2882#if !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && !defined(__mips64__) && \
2883 !defined(__hexagon__)
28792884 {
28802885 struct Rect r1 = {1, 21, 16, 4};
28812886 struct Rect r2 = {178, 189, 21, 15};
......@@ -2883,7 +2888,7 @@ void run_c_tests(void) {
28832888 }
28842889#endif
28852890
2886#if !defined ZIG_PPC32 && !defined(__loongarch__) && !defined(__mips64__)
2891#if !defined ZIG_PPC32 && !defined(__loongarch__) && !defined(__mips64__) && !defined(__hexagon__)
28872892 {
28882893 struct FloatRect r1 = {1, 21, 16, 4};
28892894 struct FloatRect r2 = {178, 189, 21, 15};
test/c_abi/main.zig+31-2
......@@ -11,7 +11,8 @@ const print = std.debug.print;
1111const expect = std.testing.expect;
1212const expectEqual = std.testing.expectEqual;
1313const have_i128 = builtin.cpu.arch != .x86 and !builtin.cpu.arch.isArm() and
14 !builtin.cpu.arch.isMIPS() and !builtin.cpu.arch.isPowerPC32() and builtin.cpu.arch != .riscv32;
14 !builtin.cpu.arch.isMIPS() and !builtin.cpu.arch.isPowerPC32() and builtin.cpu.arch != .riscv32 and
15 builtin.cpu.arch != .hexagon;
1516
1617const have_f128 = builtin.cpu.arch.isWasm() or (builtin.cpu.arch.isX86() and !builtin.os.tag.isDarwin());
1718const have_f80 = builtin.cpu.arch.isX86();
......@@ -183,7 +184,8 @@ extern fn c_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat;
183184extern fn c_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble;
184185
185186const complex_abi_compatible = builtin.cpu.arch != .x86 and !builtin.cpu.arch.isMIPS() and
186 !builtin.cpu.arch.isArm() and !builtin.cpu.arch.isPowerPC32() and !builtin.cpu.arch.isRISCV();
187 !builtin.cpu.arch.isArm() and !builtin.cpu.arch.isPowerPC32() and !builtin.cpu.arch.isRISCV() and
188 builtin.cpu.arch != .hexagon;
187189
188190test "C ABI complex float" {
189191 if (!complex_abi_compatible) return error.SkipZigTest;
......@@ -326,6 +328,7 @@ extern fn c_struct_u64_u64_8(usize, usize, usize, usize, usize, usize, usize, us
326328test "C ABI struct u64 u64" {
327329 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
328330 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
331 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
329332
330333 const s = c_ret_struct_u64_u64();
331334 try expect(s.a == 21);
......@@ -417,6 +420,7 @@ test "C ABI struct {f32,f32} f32" {
417420 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
418421 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
419422 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
423 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
420424
421425 const s = c_ret_struct_f32f32_f32();
422426 try expect(s.a.b == 1.0);
......@@ -449,6 +453,7 @@ test "C ABI struct f32 {f32,f32}" {
449453 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
450454 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
451455 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
456 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
452457
453458 const s = c_ret_struct_f32_f32f32();
454459 try expect(s.a == 1.0);
......@@ -485,6 +490,7 @@ test "C ABI struct{u32,union{u32,struct{u32,u32}}}" {
485490 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
486491 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
487492 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
493 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
488494
489495 const s = c_ret_struct_u32_union_u32_u32u32();
490496 try expect(s.a == 1);
......@@ -536,6 +542,7 @@ test "C ABI big struct" {
536542 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
537543 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
538544 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
545 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
539546
540547 const s = BigStruct{
541548 .a = 1,
......@@ -563,6 +570,7 @@ extern fn c_big_union(BigUnion) void;
563570test "C ABI big union" {
564571 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
565572 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
573 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
566574
567575 const x = BigUnion{
568576 .a = BigStruct{
......@@ -597,6 +605,7 @@ test "C ABI medium struct of ints and floats" {
597605 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
598606 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
599607 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
608 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
600609
601610 const s = MedStructMixed{
602611 .a = 1234,
......@@ -631,6 +640,7 @@ test "C ABI small struct of ints" {
631640 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
632641 if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest;
633642 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
643 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
634644
635645 const s = SmallStructInts{
636646 .a = 1,
......@@ -665,6 +675,7 @@ test "C ABI medium struct of ints" {
665675 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
666676 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
667677 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
678 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
668679
669680 const s = MedStructInts{
670681 .x = 1,
......@@ -744,6 +755,7 @@ test "C ABI split struct of ints" {
744755 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
745756 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
746757 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
758 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
747759
748760 const s = SplitStructInt{
749761 .a = 1234,
......@@ -772,6 +784,7 @@ test "C ABI split struct of ints and floats" {
772784 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
773785 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
774786 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
787 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
775788
776789 const s = SplitStructMixed{
777790 .a = 1234,
......@@ -800,6 +813,7 @@ test "C ABI sret and byval together" {
800813 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
801814 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
802815 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
816 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
803817
804818 const s = BigStruct{
805819 .a = 1,
......@@ -853,6 +867,7 @@ test "C ABI structs of floats as parameter" {
853867 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
854868 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
855869 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
870 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
856871
857872 const v3 = Vector3{
858873 .x = 3.0,
......@@ -894,6 +909,7 @@ test "C ABI structs of ints as multiple parameters" {
894909 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
895910 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
896911 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
912 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
897913
898914 const r1 = Rect{
899915 .left = 1,
......@@ -932,6 +948,7 @@ test "C ABI structs of floats as multiple parameters" {
932948 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
933949 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
934950 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
951 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
935952
936953 const r1 = FloatRect{
937954 .left = 1,
......@@ -1046,6 +1063,7 @@ test "Struct with array as padding." {
10461063 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
10471064 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
10481065 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
1066 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
10491067
10501068 c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 });
10511069
......@@ -1072,6 +1090,7 @@ test "Float array like struct" {
10721090 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
10731091 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
10741092 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
1093 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
10751094
10761095 c_float_array_struct(.{
10771096 .origin = .{
......@@ -5471,6 +5490,7 @@ test "DC: Zig passes to C" {
54715490 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
54725491 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
54735492 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5493 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
54745494 try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));
54755495}
54765496test "DC: Zig returns to C" {
......@@ -5485,6 +5505,7 @@ test "DC: C passes to Zig" {
54855505 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
54865506 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
54875507 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5508 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
54885509 try expectOk(c_send_DC());
54895510}
54905511test "DC: C returns to Zig" {
......@@ -5518,6 +5539,7 @@ test "CFF: Zig passes to C" {
55185539 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
55195540 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55205541 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5542 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
55215543 try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));
55225544}
55235545test "CFF: Zig returns to C" {
......@@ -5533,6 +5555,7 @@ test "CFF: C passes to Zig" {
55335555 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
55345556 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55355557 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5558 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
55365559
55375560 try expectOk(c_send_CFF());
55385561}
......@@ -5567,6 +5590,7 @@ test "PD: Zig passes to C" {
55675590 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
55685591 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55695592 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5593 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
55705594 try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 }));
55715595}
55725596test "PD: Zig returns to C" {
......@@ -5579,6 +5603,7 @@ test "PD: C passes to Zig" {
55795603 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
55805604 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55815605 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5606 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
55825607 try expectOk(c_send_PD());
55835608}
55845609test "PD: C returns to Zig" {
......@@ -5641,6 +5666,7 @@ test "C function that takes byval struct called via function pointer" {
56415666 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
56425667 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
56435668 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5669 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
56445670
56455671 var fn_ptr = &c_func_ptr_byval;
56465672 _ = &fn_ptr;
......@@ -5781,6 +5807,7 @@ test "Stdcall ABI structs" {
57815807 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
57825808 if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest;
57835809 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5810 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
57845811
57855812 const res = stdcall_coord2(
57865813 .{ .x = 0x1111, .y = 0x2222 },
......@@ -5795,6 +5822,7 @@ extern fn stdcall_big_union(BigUnion) callconv(stdcall_callconv) void;
57955822test "Stdcall ABI big union" {
57965823 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
57975824 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5825 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
57985826
57995827 const x = BigUnion{
58005828 .a = BigStruct{
......@@ -5868,6 +5896,7 @@ test "byval tail callsite attribute" {
58685896 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
58695897 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
58705898 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5899 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
58715900
58725901 // Originally reported at https://github.com/ziglang/zig/issues/16290
58735902 // the bug was that the extern function had the byval attribute, but
test/tests.zig+7-8
......@@ -1607,14 +1607,13 @@ const c_abi_targets = blk: {
16071607 },
16081608 },
16091609
1610 // Crashes in LLVM instruction selection.
1611 // .{
1612 // .target = .{
1613 // .cpu_arch = .hexagon,
1614 // .os_tag = .linux,
1615 // .abi = .musl,
1616 // },
1617 // },
1610 .{
1611 .target = .{
1612 .cpu_arch = .hexagon,
1613 .os_tag = .linux,
1614 .abi = .musl,
1615 },
1616 },
16181617
16191618 .{
16201619 .target = .{