Commit 98cf81d51c
test/c_abi/cfuncs.c
@@ -37,6 +37,10 @@ static void assert_or_panic(bool ok) {
# define ZIG_NO_I128
#endif
+#ifdef __hexagon__
+# define ZIG_NO_I128
+#endif
+
#ifdef __mips__
# define ZIG_NO_I128
#endif
@@ -77,6 +81,14 @@ static void assert_or_panic(bool ok) {
#define ZIG_NO_RAW_F16
#endif
+#ifdef __hexagon__
+#define ZIG_NO_RAW_F16
+#endif
+
+#ifdef __loongarch__
+#define ZIG_NO_RAW_F16
+#endif
+
#ifdef __mips__
#define ZIG_NO_RAW_F16
#endif
@@ -85,6 +97,10 @@ static void assert_or_panic(bool ok) {
#define ZIG_NO_RAW_F16
#endif
+#ifdef __s390x__
+#define ZIG_NO_RAW_F16
+#endif
+
#ifdef __wasm__
#define ZIG_NO_RAW_F16
#endif
@@ -101,6 +117,14 @@ static void assert_or_panic(bool ok) {
#define ZIG_NO_F128
#endif
+#ifdef __hexagon__
+#define ZIG_NO_F128
+#endif
+
+#ifdef __loongarch__
+#define ZIG_NO_F128
+#endif
+
#ifdef __mips__
#define ZIG_NO_F128
#endif
@@ -113,6 +137,10 @@ static void assert_or_panic(bool ok) {
#define ZIG_NO_F128
#endif
+#ifdef __s390x__
+#define ZIG_NO_F128
+#endif
+
#ifdef __APPLE__
#define ZIG_NO_F128
#endif
@@ -2713,18 +2741,24 @@ void run_c_tests(void) {
}
#if !defined(ZIG_RISCV64)
+#if !defined(__mips64__)
{
struct Struct_f32 s = zig_ret_struct_f32();
assert_or_panic(s.a == 2.5f);
zig_struct_f32((struct Struct_f32){ 2.5f });
}
+#endif
+#if !(defined(__arm__) && defined(__SOFTFP__))
+#if !defined(ZIG_RISCV32)
{
struct Struct_f64 s = zig_ret_struct_f64();
assert_or_panic(s.a == 2.5);
zig_struct_f64((struct Struct_f64){ 2.5 });
}
+#endif
+#if !defined(__loongarch__) && !defined(__mips64__)
{
struct Struct_f32f32_f32 s = zig_ret_struct_f32f32_f32();
assert_or_panic(s.a.b == 1.0f);
@@ -2741,8 +2775,10 @@ void run_c_tests(void) {
zig_struct_f32_f32f32((struct Struct_f32_f32f32){ 1.0f, { 2.0f, 3.0f } });
}
#endif
+#endif
+#endif
-#if !defined(__powerpc__)
+#if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__)
{
struct Struct_u32_Union_u32_u32u32 s = zig_ret_struct_u32_union_u32_u32u32();
assert_or_panic(s.a == 1);
@@ -2750,20 +2786,24 @@ void run_c_tests(void) {
assert_or_panic(s.b.c.e == 3);
zig_struct_u32_union_u32_u32u32(s);
}
+
{
struct Struct_i32_i32 s = {1, 2};
zig_struct_i32_i32(s);
}
#endif
+#if !defined(__powerpc64__) && !defined(__loongarch__) && !defined(__mips64__)
{
struct BigStruct s = {1, 2, 3, 4, 5};
zig_big_struct(s);
}
#endif
+#endif
#if !defined __i386__ && !defined __arm__ && !defined __aarch64__ && \
- !defined __powerpc__ && !defined ZIG_RISCV64
+ !defined __powerpc__ && !defined ZIG_RISCV64 && !defined(__loongarch__) && \
+ !defined(__mips64__)
{
struct SmallStructInts s = {1, 2, 3, 4};
zig_small_struct_ints(s);
@@ -2771,7 +2811,8 @@ void run_c_tests(void) {
#endif
#if !defined __arm__ && !defined __aarch64__ && \
- !defined __powerpc__ && !defined ZIG_RISCV64
+ !defined __powerpc__ && !defined ZIG_RISCV64 && !defined(__loongarch__) && \
+ !defined(__mips64__)
{
struct MedStructInts s = {1, 2, 3};
zig_med_struct_ints(s);
@@ -2797,14 +2838,16 @@ void run_c_tests(void) {
}
#if !defined __i386__ && !defined __arm__ && \
- !defined ZIG_PPC32 && !defined _ARCH_PPC64
+ !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
+ !defined(__mips64__)
{
struct SplitStructInts s = {1234, 100, 1337};
zig_split_struct_ints(s);
}
#endif
-#if !defined __arm__ && !defined ZIG_PPC32 && !defined _ARCH_PPC64
+#if !defined __arm__ && !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
+ !defined(__mips64__)
{
struct MedStructMixed s = {1234, 100.0f, 1337.0f};
zig_med_struct_mixed(s);
@@ -2812,14 +2855,15 @@ void run_c_tests(void) {
#endif
#if !defined __i386__ && !defined __arm__ && \
- !defined ZIG_PPC32 && !defined _ARCH_PPC64
+ !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
+ !defined(__mips64__)
{
struct SplitStructMixed s = {1234, 100, 1337.0f};
zig_split_struct_mixed(s);
}
#endif
-#if !defined ZIG_PPC32
+#if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__)
{
struct BigStruct s = {30, 31, 32, 33, 34};
struct BigStruct res = zig_big_struct_both(s);
@@ -2831,7 +2875,7 @@ void run_c_tests(void) {
}
#endif
-#if !defined ZIG_PPC32 && !defined _ARCH_PPC64
+#if !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && !defined(__mips64__)
{
struct Rect r1 = {1, 21, 16, 4};
struct Rect r2 = {178, 189, 21, 15};
@@ -2839,7 +2883,7 @@ void run_c_tests(void) {
}
#endif
-#if !defined ZIG_PPC32
+#if !defined ZIG_PPC32 && !defined(__loongarch__) && !defined(__mips64__)
{
struct FloatRect r1 = {1, 21, 16, 4};
struct FloatRect r2 = {178, 189, 21, 15};
test/c_abi/main.zig
@@ -11,7 +11,7 @@ const print = std.debug.print;
const expect = std.testing.expect;
const expectEqual = std.testing.expectEqual;
const have_i128 = builtin.cpu.arch != .x86 and !builtin.cpu.arch.isArm() and
- !builtin.cpu.arch.isMIPS() and !builtin.cpu.arch.isPowerPC32();
+ !builtin.cpu.arch.isMIPS() and !builtin.cpu.arch.isPowerPC32() and builtin.cpu.arch != .riscv32;
const have_f128 = builtin.cpu.arch.isWasm() or (builtin.cpu.arch.isX86() and !builtin.os.tag.isDarwin());
const 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 {
}
test "C ABI integers" {
+ if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
+
c_u8(0xff);
c_u16(0xfffe);
c_u32(0xfffffffd);
@@ -383,6 +385,8 @@ extern fn c_struct_f64(Struct_f64) void;
test "C ABI struct f64" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
+ if (builtin.cpu.arch == .riscv32) return error.SkipZigTest;
const s = c_ret_struct_f64();
try expect(s.a == 2.5);
@@ -411,6 +415,8 @@ extern fn c_struct_f32f32_f32(Struct_f32f32_f32) void;
test "C ABI struct {f32,f32} f32" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s = c_ret_struct_f32f32_f32();
try expect(s.a.b == 1.0);
@@ -441,6 +447,8 @@ extern fn c_struct_f32_f32f32(Struct_f32_f32f32) void;
test "C ABI struct f32 {f32,f32}" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s = c_ret_struct_f32_f32f32();
try expect(s.a == 1.0);
@@ -476,6 +484,7 @@ extern fn c_struct_u32_union_u32_u32u32(Struct_u32_Union_u32_u32u32) void;
test "C ABI struct{u32,union{u32,struct{u32,u32}}}" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s = c_ret_struct_u32_union_u32_u32u32();
try expect(s.a == 1);
@@ -494,6 +503,8 @@ extern fn c_struct_i32_i32(Struct_i32_i32) void;
test "C ABI struct i32 i32" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch == .riscv32) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s: Struct_i32_i32 = .{
.a = 1,
@@ -523,7 +534,8 @@ extern fn c_big_struct(BigStruct) void;
test "C ABI big struct" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
- if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s = BigStruct{
.a = 1,
@@ -550,6 +562,7 @@ extern fn c_big_union(BigUnion) void;
test "C ABI big union" {
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const x = BigUnion{
.a = BigStruct{
@@ -583,6 +596,7 @@ extern fn c_ret_med_struct_mixed() MedStructMixed;
test "C ABI medium struct of ints and floats" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s = MedStructMixed{
.a = 1234,
@@ -615,6 +629,8 @@ test "C ABI small struct of ints" {
if (builtin.cpu.arch == .x86) return error.SkipZigTest;
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s = SmallStructInts{
.a = 1,
@@ -648,6 +664,7 @@ extern fn c_ret_med_struct_ints() MedStructInts;
test "C ABI medium struct of ints" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s = MedStructInts{
.x = 1,
@@ -726,6 +743,7 @@ test "C ABI split struct of ints" {
if (builtin.cpu.arch == .x86) return error.SkipZigTest;
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s = SplitStructInt{
.a = 1234,
@@ -753,6 +771,7 @@ test "C ABI split struct of ints and floats" {
if (builtin.cpu.arch == .x86) return error.SkipZigTest;
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s = SplitStructMixed{
.a = 1234,
@@ -779,7 +798,8 @@ extern fn c_multiple_struct_floats(FloatRect, FloatRect) void;
test "C ABI sret and byval together" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
- if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const s = BigStruct{
.a = 1,
@@ -832,6 +852,7 @@ extern fn c_big_struct_floats(Vector5) void;
test "C ABI structs of floats as parameter" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const v3 = Vector3{
.x = 3.0,
@@ -871,6 +892,8 @@ export fn zig_multiple_struct_ints(x: Rect, y: Rect) void {
test "C ABI structs of ints as multiple parameters" {
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
const r1 = Rect{
.left = 1,
@@ -908,6 +931,7 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {
test "C ABI structs of floats as multiple parameters" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const r1 = FloatRect{
.left = 1,
@@ -1021,6 +1045,7 @@ test "Struct with array as padding." {
if (builtin.cpu.arch == .x86) return error.SkipZigTest;
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 });
@@ -1046,6 +1071,7 @@ extern fn c_ret_float_array_struct() FloatArrayStruct;
test "Float array like struct" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
c_float_array_struct(.{
.origin = .{
@@ -1073,6 +1099,7 @@ extern fn c_ret_small_vec() SmallVec;
test "small simd vector" {
if (builtin.cpu.arch == .x86) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
c_small_vec(.{ 1, 2 });
@@ -1134,7 +1161,8 @@ extern fn c_ret_vector_2_float() Vector2Float;
extern fn c_ret_vector_4_float() Vector4Float;
test "float simd vectors" {
- if (builtin.cpu.arch == .powerpc or builtin.cpu.arch == .powerpc64le) return error.SkipZigTest;
+ if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
{
c_vector_2_float(.{ 1.0, 2.0 });
@@ -5419,6 +5447,7 @@ test "C ABI pointer sized float struct" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
c_ptr_size_float_struct(.{ .x = 1, .y = 2 });
@@ -5441,24 +5470,28 @@ test "DC: Zig passes to C" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));
}
test "DC: Zig returns to C" {
- if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest;
+ if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectOk(c_assert_ret_DC());
}
test "DC: C passes to Zig" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectOk(c_send_DC());
}
test "DC: C returns to Zig" {
- if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest;
+ if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectEqual(DC{ .v1 = -0.25, .v2 = 15 }, c_ret_DC());
}
@@ -5484,11 +5517,13 @@ test "CFF: Zig passes to C" {
if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));
}
test "CFF: Zig returns to C" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectOk(c_assert_ret_CFF());
}
test "CFF: C passes to Zig" {
@@ -5497,6 +5532,7 @@ test "CFF: C passes to Zig" {
if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectOk(c_send_CFF());
}
@@ -5505,6 +5541,7 @@ test "CFF: C returns to Zig" {
if (builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectEqual(CFF{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }, c_ret_CFF());
}
pub extern fn c_assert_CFF(lv: CFF) c_int;
@@ -5529,21 +5566,25 @@ const PD = extern struct { v1: ?*anyopaque, v2: f64 };
test "PD: Zig passes to C" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 }));
}
test "PD: Zig returns to C" {
- if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest;
+ if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectOk(c_assert_ret_PD());
}
test "PD: C passes to Zig" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectOk(c_send_PD());
}
test "PD: C returns to Zig" {
- if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest;
+ if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
try expectEqual(PD{ .v1 = null, .v2 = 0.5 }, c_ret_PD());
}
pub extern fn c_assert_PD(lv: PD) c_int;
@@ -5576,6 +5617,7 @@ extern fn c_modify_by_ref_param(ByRef) ByRef;
test "C function modifies by ref param" {
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const res = c_modify_by_ref_param(.{ .val = 1, .arr = undefined });
try expect(res.val == 42);
@@ -5596,8 +5638,9 @@ const ByVal = extern struct {
extern fn c_func_ptr_byval(*anyopaque, *anyopaque, ByVal, c_ulong, *anyopaque, c_ulong) void;
test "C function that takes byval struct called via function pointer" {
- if (builtin.cpu.arch.isMIPS64() and builtin.mode != .Debug) return error.SkipZigTest;
+ if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
var fn_ptr = &c_func_ptr_byval;
_ = &fn_ptr;
@@ -5736,6 +5779,8 @@ extern fn stdcall_coord2(Coord2, Coord2, Coord2) callconv(stdcall_callconv) Coor
test "Stdcall ABI structs" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
+ if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const res = stdcall_coord2(
.{ .x = 0x1111, .y = 0x2222 },
@@ -5749,6 +5794,7 @@ test "Stdcall ABI structs" {
extern fn stdcall_big_union(BigUnion) callconv(stdcall_callconv) void;
test "Stdcall ABI big union" {
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
const x = BigUnion{
.a = BigStruct{
@@ -5821,6 +5867,7 @@ const byval_tail_callsite_attr = struct {
test "byval tail callsite attribute" {
if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
+ if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
// Originally reported at https://github.com/ziglang/zig/issues/16290
// the bug was that the extern function had the byval attribute, but
test/tests.zig
@@ -1597,137 +1597,319 @@ const CAbiTarget = struct {
c_defines: []const []const u8 = &.{},
};
-const c_abi_targets = [_]CAbiTarget{
- // Native Targets
+const c_abi_targets = blk: {
+ @setEvalBranchQuota(20000);
+ break :blk [_]CAbiTarget{
+ // Native Targets
- .{},
+ .{},
- // Linux Targets
+ // Linux Targets
- .{
- .target = .{
- .cpu_arch = .aarch64,
- .os_tag = .linux,
- .abi = .musl,
+ .{
+ .target = .{
+ .cpu_arch = .aarch64,
+ .os_tag = .linux,
+ .abi = .musl,
+ },
},
- },
- .{
- .target = .{
- .cpu_arch = .arm,
- .os_tag = .linux,
- .abi = .musleabihf,
+ .{
+ .target = .{
+ .cpu_arch = .aarch64_be,
+ .os_tag = .linux,
+ .abi = .musl,
+ },
},
- },
- .{
- .target = .{
- .cpu_arch = .mips,
- .os_tag = .linux,
- .abi = .musleabihf,
+ .{
+ .target = .{
+ .cpu_arch = .arm,
+ .os_tag = .linux,
+ .abi = .musleabi,
+ },
+ },
+ .{
+ .target = .{
+ .cpu_arch = .arm,
+ .os_tag = .linux,
+ .abi = .musleabihf,
+ },
},
- },
- .{
- .target = .{
- .cpu_arch = .powerpc,
- .os_tag = .linux,
- .abi = .musleabihf,
+ .{
+ .target = .{
+ .cpu_arch = .armeb,
+ .os_tag = .linux,
+ .abi = .musleabi,
+ },
+ },
+ .{
+ .target = .{
+ .cpu_arch = .armeb,
+ .os_tag = .linux,
+ .abi = .musleabihf,
+ },
},
- },
- .{
- .target = .{
- .cpu_arch = .powerpc64le,
- .os_tag = .linux,
- .abi = .musl,
+ // Crashes in LLVM instruction selection.
+ // .{
+ // .target = .{
+ // .cpu_arch = .hexagon,
+ // .os_tag = .linux,
+ // .abi = .musl,
+ // },
+ // },
+
+ .{
+ .target = .{
+ .cpu_arch = .loongarch64,
+ .os_tag = .linux,
+ .abi = .musl,
+ },
},
- },
- .{
- .target = .{
- .cpu_arch = .riscv64,
- .os_tag = .linux,
- .abi = .musl,
+ .{
+ .target = .{
+ .cpu_arch = .mips,
+ .os_tag = .linux,
+ .abi = .musleabi,
+ },
+ },
+ .{
+ .target = .{
+ .cpu_arch = .mips,
+ .os_tag = .linux,
+ .abi = .musleabihf,
+ },
},
- },
- .{
- .target = .{
- .cpu_arch = .x86,
- .os_tag = .linux,
- .abi = .musl,
+ .{
+ .target = .{
+ .cpu_arch = .mipsel,
+ .os_tag = .linux,
+ .abi = .musleabi,
+ },
+ },
+ .{
+ .target = .{
+ .cpu_arch = .mipsel,
+ .os_tag = .linux,
+ .abi = .musleabihf,
+ },
},
- },
- .{
- .target = .{
- .cpu_arch = .x86_64,
- .os_tag = .linux,
- .abi = .musl,
- },
- .use_llvm = false,
- .use_lld = false,
- .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
- },
- .{
- .target = .{
- .cpu_arch = .x86_64,
- .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
- .os_tag = .linux,
- .abi = .musl,
- },
- .use_llvm = false,
- .use_lld = false,
- .strip = true,
- .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
- },
- .{
- .target = .{
- .cpu_arch = .x86_64,
- .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
- .os_tag = .linux,
- .abi = .musl,
+ .{
+ .target = .{
+ .cpu_arch = .mips64,
+ .os_tag = .linux,
+ .abi = .muslabi64,
+ },
},
- .use_llvm = false,
- .use_lld = false,
- .pic = true,
- .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
- },
- .{
- .target = .{
- .cpu_arch = .x86_64,
- .os_tag = .linux,
- .abi = .musl,
+ .{
+ .target = .{
+ .cpu_arch = .mips64,
+ .os_tag = .linux,
+ .abi = .muslabin32,
+ },
+ },
+
+ .{
+ .target = .{
+ .cpu_arch = .mips64el,
+ .os_tag = .linux,
+ .abi = .muslabi64,
+ },
+ },
+ .{
+ .target = .{
+ .cpu_arch = .mips64el,
+ .os_tag = .linux,
+ .abi = .muslabin32,
+ },
+ },
+
+ .{
+ .target = .{
+ .cpu_arch = .powerpc,
+ .os_tag = .linux,
+ .abi = .musleabi,
+ },
+ },
+ .{
+ .target = .{
+ .cpu_arch = .powerpc,
+ .os_tag = .linux,
+ .abi = .musleabihf,
+ },
+ },
+
+ .{
+ .target = .{
+ .cpu_arch = .powerpc64,
+ .os_tag = .linux,
+ .abi = .musl,
+ },
+ },
+ .{
+ .target = .{
+ .cpu_arch = .powerpc64le,
+ .os_tag = .linux,
+ .abi = .musl,
+ },
},
- },
- // WASI Targets
+ .{
+ .target = std.Target.Query.parse(.{
+ .arch_os_abi = "riscv32-linux-musl",
+ .cpu_features = "baseline-d-f",
+ }) catch unreachable,
+ },
+ .{
+ .target = .{
+ .cpu_arch = .riscv32,
+ .os_tag = .linux,
+ .abi = .musl,
+ },
+ },
- .{
- .target = .{
- .cpu_arch = .wasm32,
- .os_tag = .wasi,
- .abi = .musl,
+ .{
+ .target = std.Target.Query.parse(.{
+ .arch_os_abi = "riscv64-linux-musl",
+ .cpu_features = "baseline-d-f",
+ }) catch unreachable,
+ },
+ .{
+ .target = .{
+ .cpu_arch = .riscv64,
+ .os_tag = .linux,
+ .abi = .musl,
+ },
},
- },
- // Windows Targets
+ // Clang explodes when parsing `cfuncs.c`.
+ // .{
+ // .target = .{
+ // .cpu_arch = .s390x,
+ // .os_tag = .linux,
+ // .abi = .musl,
+ // },
+ // },
+
+ .{
+ .target = std.Target.Query.parse(.{
+ .arch_os_abi = "thumb-linux-musleabi",
+ .cpu_features = "baseline+long_calls",
+ }) catch unreachable,
+ .pic = false, // Long calls don't work with PIC.
+ },
+ .{
+ .target = std.Target.Query.parse(.{
+ .arch_os_abi = "thumb-linux-musleabihf",
+ .cpu_features = "baseline+long_calls",
+ }) catch unreachable,
+ .pic = false, // Long calls don't work with PIC.
+ },
- .{
- .target = .{
- .cpu_arch = .x86,
- .os_tag = .windows,
- .abi = .gnu,
+ .{
+ .target = std.Target.Query.parse(.{
+ .arch_os_abi = "thumbeb-linux-musleabi",
+ .cpu_features = "baseline+long_calls",
+ }) catch unreachable,
+ .pic = false, // Long calls don't work with PIC.
},
- },
- .{
- .target = .{
- .cpu_arch = .x86_64,
- .os_tag = .windows,
- .abi = .gnu,
+ .{
+ .target = std.Target.Query.parse(.{
+ .arch_os_abi = "thumbeb-linux-musleabihf",
+ .cpu_features = "baseline+long_calls",
+ }) catch unreachable,
+ .pic = false, // Long calls don't work with PIC.
+ },
+
+ .{
+ .target = .{
+ .cpu_arch = .x86,
+ .os_tag = .linux,
+ .abi = .musl,
+ },
},
- },
+
+ .{
+ .target = .{
+ .cpu_arch = .x86_64,
+ .os_tag = .linux,
+ .abi = .musl,
+ },
+ .use_llvm = false,
+ .use_lld = false,
+ .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
+ },
+ .{
+ .target = .{
+ .cpu_arch = .x86_64,
+ .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
+ .os_tag = .linux,
+ .abi = .musl,
+ },
+ .use_llvm = false,
+ .use_lld = false,
+ .strip = true,
+ .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
+ },
+ .{
+ .target = .{
+ .cpu_arch = .x86_64,
+ .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
+ .os_tag = .linux,
+ .abi = .musl,
+ },
+ .use_llvm = false,
+ .use_lld = false,
+ .pic = true,
+ .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
+ },
+ .{
+ .target = .{
+ .cpu_arch = .x86_64,
+ .os_tag = .linux,
+ .abi = .musl,
+ },
+ },
+ .{
+ .target = .{
+ .cpu_arch = .x86_64,
+ .os_tag = .linux,
+ .abi = .muslx32,
+ },
+ },
+
+ // WASI Targets
+
+ .{
+ .target = .{
+ .cpu_arch = .wasm32,
+ .os_tag = .wasi,
+ .abi = .musl,
+ },
+ },
+
+ // Windows Targets
+
+ .{
+ .target = .{
+ .cpu_arch = .x86,
+ .os_tag = .windows,
+ .abi = .gnu,
+ },
+ },
+ .{
+ .target = .{
+ .cpu_arch = .x86_64,
+ .os_tag = .windows,
+ .abi = .gnu,
+ },
+ },
+ };
};
pub fn addCompareOutputTests(