From 4219825042057ce901df1261e089ef477c381fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 1 Jun 2026 14:44:13 +0200 Subject: [PATCH 1/8] test: use -ffunction-sections -fdata-sections for C backend module tests if needed We need this for certain targets for the same reason we do it when bootstrapping the compiler from zig1.wasm. --- test/tests.zig | 99 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 39 deletions(-) diff --git a/test/tests.zig b/test/tests.zig index c6de8b13bef27040372aaeca3177b5a066c4f0f6..c37ce962353448b615c21fedf6d681276a47bef2 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -2811,45 +2811,66 @@ fn addOneModuleTest( compile_c.addCSourceFile(.{ .file = these_tests.getEmittedBin(), - .flags = &.{ - // Tracking issue for making the C backend generate C89 compatible code: - // https://github.com/ziglang/zig/issues/19468 - "-std=c99", - "-Werror", - - "-Wall", - "-Wembedded-directive", - "-Wempty-translation-unit", - "-Wextra", - "-Wgnu", - "-Winvalid-utf8", - "-Wkeyword-macro", - "-Woverlength-strings", - - // Tracking issue for making the C backend generate code - // that does not trigger warnings: - // https://github.com/ziglang/zig/issues/19467 - - // spotted everywhere - "-Wno-builtin-requires-header", - - // spotted on linux - "-Wno-braced-scalar-init", - "-Wno-excess-initializers", - "-Wno-incompatible-pointer-types-discards-qualifiers", - "-Wno-unused", - "-Wno-unused-parameter", - - // spotted on darwin - "-Wno-incompatible-pointer-types", - - // https://github.com/llvm/llvm-project/issues/153314 - "-Wno-unterminated-string-initialization", - - // In both Zig and C it is legal to return a pointer to a - // local. The C backend lowers such thing directly, so the - // corresponding warning in C must be disabled. - "-Wno-return-stack-address", + .flags = blk: { + const invariant_cflags: []const []const u8 = &.{ + // Tracking issue for making the C backend generate C89 compatible code: + // https://github.com/ziglang/zig/issues/19468 + "-std=c99", + "-Werror", + + "-Wall", + "-Wembedded-directive", + "-Wempty-translation-unit", + "-Wextra", + "-Wgnu", + "-Winvalid-utf8", + "-Wkeyword-macro", + "-Woverlength-strings", + + // Tracking issue for making the C backend generate code + // that does not trigger warnings: + // https://github.com/ziglang/zig/issues/19467 + + // spotted everywhere + "-Wno-builtin-requires-header", + + // spotted on linux + "-Wno-braced-scalar-init", + "-Wno-excess-initializers", + "-Wno-incompatible-pointer-types-discards-qualifiers", + "-Wno-unused", + "-Wno-unused-parameter", + + // spotted on darwin + "-Wno-incompatible-pointer-types", + + // https://github.com/llvm/llvm-project/issues/153314 + "-Wno-unterminated-string-initialization", + + // In both Zig and C it is legal to return a pointer to a + // local. The C backend lowers such thing directly, so the + // corresponding warning in C must be disabled. + "-Wno-return-stack-address", + }; + + const function_data_sections = switch (target.cpu.arch) { + .arm, + .armeb, + .thumb, + .thumbeb, + .hexagon, + .powerpc, + .powerpcle, + .powerpc64, + .powerpc64le, + => true, + else => false, + }; + + break :blk if (function_data_sections) invariant_cflags ++ &[_][]const u8{ + "-ffunction-sections", + "-fdata-sections", + } else invariant_cflags; }, }); compile_c.addIncludePath(b.path("lib")); // for zig.h -- 2.54.0 From 6384ac6601b4d0654022786edba0cb775255ebd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 1 Jun 2026 10:15:20 +0200 Subject: [PATCH 2/8] behavior: disable tail call tests on powerpc and mips with the C backend Since LLVM doesn't support tail calls on these targets, these tests shouldn't run with the C backend either. closes https://codeberg.org/ziglang/zig/issues/35522 --- test/behavior/call.zig | 8 ++++---- test/tests.zig | 5 ----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/test/behavior/call.zig b/test/behavior/call.zig index 9ff3e56d3ebbc8e5a61663c8a814a106ab3fe0c5..e1152ad910695f425c8de60894d7ecc92fe9d0f9 100644 --- a/test/behavior/call.zig +++ b/test/behavior/call.zig @@ -277,7 +277,7 @@ test "forced tail call" { if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm) { + if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) { if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) { return error.SkipZigTest; } @@ -312,7 +312,7 @@ test "inline call preserves tail call" { if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm) { + if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) { if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) { return error.SkipZigTest; } @@ -708,7 +708,7 @@ test "tail call function pointer" { if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm) { + if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) { if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) { return error.SkipZigTest; } @@ -736,7 +736,7 @@ test "tail call with potentially extended types" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO - if (builtin.zig_backend == .stage2_llvm) { + if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) { if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) { return error.SkipZigTest; } diff --git a/test/tests.zig b/test/tests.zig index c37ce962353448b615c21fedf6d681276a47bef2..bfb7a4eaee02773ba7d54261cd2b72dd445859f0 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -2650,11 +2650,6 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { const target = &resolved_target.result; - if (target.cpu.arch == .powerpc64le and target.ofmt == .c) { - // https://codeberg.org/ziglang/zig/issues/35522 - continue; - } - if (target.cpu.arch == .s390x and target.ofmt == .c) { // https://codeberg.org/ziglang/zig/issues/35523 continue; -- 2.54.0 From ee3c7a9f39b397aa8a1153f5699d9ff39bd9b359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 1 Jun 2026 10:27:10 +0200 Subject: [PATCH 3/8] std.c: fix some symbol names under the msvc ABI --- lib/std/c.zig | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/std/c.zig b/lib/std/c.zig index d4efb2c07e0fc412e495a993dbb451e09964e0b6..5c61cbb676d9e73309af48f0d898cb2e9ddab48d 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -11134,14 +11134,23 @@ pub const ioctl = switch (native_os) { pub extern "c" fn bzero(s: *anyopaque, n: usize) void; -pub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; +pub const swab = switch (builtin.abi) { + .msvc => private._swab, + else => private.swab, +}; pub extern "c" fn strncmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int; pub extern "c" fn strcasecmp(a: [*:0]const c_char, b: [*:0]const c_char) c_int; pub extern "c" fn strncasecmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int; -pub extern "c" fn strdup(s: [*:0]const c_char) ?[*:0]c_char; +pub const strdup = switch (builtin.abi) { + .msvc => private._strdup, + else => private.strdup, +}; pub extern "c" fn strndup(s: [*:0]const c_char, n: usize) ?[*:0]c_char; -pub extern "c" fn wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t; +pub const wcsdup = switch (builtin.abi) { + .msvc => private._wcsdup, + else => private.wcsdup, +}; pub extern "c" fn ffs(i: c_int) c_int; pub extern "c" fn ffsl(i: c_long) c_long; @@ -11555,6 +11564,14 @@ pub const setkeymap = serenity.setkeymap; /// External definitions shared by two or more operating systems. const private = struct { + pub extern "c" fn strdup(s: [*:0]const c_char) ?[*:0]c_char; + pub extern "c" fn _strdup(s: [*:0]const c_char) ?[*:0]c_char; + pub extern "c" fn wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t; + pub extern "c" fn _wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t; + + pub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; + pub extern "c" fn _swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; + extern "c" fn close(fd: fd_t) c_int; extern "c" fn clock_getres(clk_id: clockid_t, tp: *timespec) c_int; extern "c" fn clock_gettime(clk_id: clockid_t, tp: *timespec) c_int; -- 2.54.0 From 1188871ed4a3034a0b9ccd00ee58965d83a75e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 1 Jun 2026 12:06:26 +0200 Subject: [PATCH 4/8] test/c: disable failing *div tests on x86-windows --- test/c/stdlib.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/c/stdlib.zig b/test/c/stdlib.zig index 589a8ef59ab2ae5356fe50640493c479e44e9997..b93bf7226eb3598ff582cc8078900742e46f0b5c 100644 --- a/test/c/stdlib.zig +++ b/test/c/stdlib.zig @@ -33,6 +33,7 @@ test "div" { if (builtin.target.cpu.arch.isMIPS64()) return error.SkipZigTest; // TODO if (builtin.target.cpu.arch.isPowerPC()) return error.SkipZigTest; // TODO if (builtin.target.cpu.arch == .s390x) return error.SkipZigTest; // TODO + if (builtin.target.cpu.arch == .x86 and builtin.target.os.tag == .windows) return error.SkipZigTest; // TODO const expected: c.div_t = .{ .quot = 5, .rem = 5 }; try testing.expectEqual(expected, c.div(55, 10)); @@ -42,6 +43,7 @@ test "ldiv" { if (builtin.target.cpu.arch.isMIPS64() and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO if (builtin.target.cpu.arch.isPowerPC32()) return error.SkipZigTest; // TODO if (builtin.target.cpu.arch == .s390x) return error.SkipZigTest; // TODO + if (builtin.target.cpu.arch == .x86 and builtin.target.os.tag == .windows) return error.SkipZigTest; // TODO const expected: c.ldiv_t = .{ .quot = -6, .rem = 2 }; try testing.expectEqual(expected, c.ldiv(38, -6)); -- 2.54.0 From 3c72bea595381effb5950b41e0f222b671e7b7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 1 Jun 2026 12:08:41 +0200 Subject: [PATCH 5/8] test/c: disable failing strto* tests on x86(_64)-windows-msvc --- test/c/stdlib.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/c/stdlib.zig b/test/c/stdlib.zig index b93bf7226eb3598ff582cc8078900742e46f0b5c..931b5dc6656434a6df392d8065ef93dcd9a3ec7d 100644 --- a/test/c/stdlib.zig +++ b/test/c/stdlib.zig @@ -131,6 +131,8 @@ fn testStrToLLikeFunctionAnyErrno( } test "strtol" { + if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO + c._errno().* = @intFromEnum(c.E.SUCCESS); try testStrToLLikeFunctionAnyErrno(c.strtol, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); try testStrToLLikeFunction(c.strtol, @ptrCast("42true"), 0, 42, 2, .SUCCESS); @@ -169,6 +171,8 @@ test "strtol" { } test "strtoll" { + if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO + c._errno().* = @intFromEnum(c.E.SUCCESS); try testStrToLLikeFunctionAnyErrno(c.strtoll, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); try testStrToLLikeFunction(c.strtoll, @ptrCast("42true"), 0, 42, 2, .SUCCESS); @@ -207,6 +211,8 @@ test "strtoll" { } test "strtoul" { + if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO + c._errno().* = @intFromEnum(c.E.SUCCESS); try testStrToLLikeFunctionAnyErrno(c.strtoul, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); try testStrToLLikeFunction(c.strtoul, @ptrCast("42true"), 0, 42, 2, .SUCCESS); @@ -243,6 +249,8 @@ test "strtoul" { } test "strtoull" { + if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO + c._errno().* = @intFromEnum(c.E.SUCCESS); try testStrToLLikeFunctionAnyErrno(c.strtoull, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); try testStrToLLikeFunction(c.strtoull, @ptrCast("42true"), 0, 42, 2, .SUCCESS); @@ -279,6 +287,8 @@ test "strtoull" { } test "strtoimax" { + if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO + c._errno().* = @intFromEnum(c.E.SUCCESS); try testStrToLLikeFunctionAnyErrno(c.strtoimax, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); try testStrToLLikeFunction(c.strtoimax, @ptrCast("42true"), 0, 42, 2, .SUCCESS); @@ -317,6 +327,8 @@ test "strtoimax" { } test "strtoumax" { + if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO + c._errno().* = @intFromEnum(c.E.SUCCESS); try testStrToLLikeFunctionAnyErrno(c.strtoumax, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); try testStrToLLikeFunction(c.strtoumax, @ptrCast("42true"), 0, 42, 2, .SUCCESS); -- 2.54.0 From 6fe487bca2b69c16be2db78ef075470ef60fb1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 1 Jun 2026 12:09:36 +0200 Subject: [PATCH 6/8] test/c: disable failing swab test on x86(_64)-windows-msvc --- test/c/unistd.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/test/c/unistd.zig b/test/c/unistd.zig index c9a52ec5e77c5b72fd466fdc3c9b3378c944f56c..944ba8de92a4c96537f88080714fb40ba8f0bdcc 100644 --- a/test/c/unistd.zig +++ b/test/c/unistd.zig @@ -8,6 +8,7 @@ test "swab" { if (builtin.target.cpu.arch.isMIPS64() and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO if (builtin.target.cpu.arch == .x86_64 and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO if (builtin.target.os.tag == .netbsd) return error.SkipZigTest; // TODO + if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO var a: [4]u8 = undefined; @memset(a[0..], '\x00'); -- 2.54.0 From 9bd82fd51ee77a4033d726f3ade94c7964f5beed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 1 Jun 2026 10:35:16 +0200 Subject: [PATCH 7/8] test/c: disable some tests on *-windows-msvc when the symbols don't exist closes https://codeberg.org/ziglang/zig/issues/35517 --- test/c/math.zig | 3 +++ test/c/pthread.zig | 1 + test/c/strings.zig | 4 ++++ test/tests.zig | 6 ------ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/c/math.zig b/test/c/math.zig index b365bc9ac43e94177f332c4e8374b485e1a79987..38127769777051722c317be97d7c27fcff689fc4 100644 --- a/test/c/math.zig +++ b/test/c/math.zig @@ -61,10 +61,13 @@ test "modf" { } test "modff" { + if (builtin.cpu.arch == .x86 and builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only + try testModf(f32); } test "modfl" { + if (builtin.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only if (builtin.target.cpu.arch.isPowerPC()) return error.SkipZigTest; // TODO: see https://codeberg.org/ziglang/zig/issues/30976 try testModf(c_longdouble); diff --git a/test/c/pthread.zig b/test/c/pthread.zig index 7dd050ad81574a923cfb026cb4cce30ca9dd6072..abac50414324036b38f78b66627c839dd8868bc9 100644 --- a/test/c/pthread.zig +++ b/test/c/pthread.zig @@ -7,6 +7,7 @@ const testing = std.testing; test "pthread_spinlock_t" { if (builtin.target.os.tag.isDarwin()) return; // Darwin doesn't have `pthread_spin_*` + if (builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // winpthreads-only var spin: c.pthread_spinlock_t = undefined; _ = c.pthread_spin_init(&spin, c.PTHREAD_PROCESS_PRIVATE); diff --git a/test/c/strings.zig b/test/c/strings.zig index 3675b0396d17e3978d1a539d578c23a37dd81a0f..baea1a8fe1f658dbd4c6a9491b4c14d57d22b842 100644 --- a/test/c/strings.zig +++ b/test/c/strings.zig @@ -48,6 +48,8 @@ test "ffs" { } test "strcasecmp" { + if (builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only + try testing.expect(c.strcasecmp(@ptrCast("a"), @ptrCast("b")) < 0); try testing.expect(c.strcasecmp(@ptrCast("b"), @ptrCast("a")) > 0); try testing.expect(c.strcasecmp(@ptrCast("A"), @ptrCast("b")) < 0); @@ -58,6 +60,8 @@ test "strcasecmp" { } test "strncasecmp" { + if (builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only + try testing.expect(c.strncasecmp(@ptrCast("a"), @ptrCast("b"), 1) < 0); try testing.expect(c.strncasecmp(@ptrCast("b"), @ptrCast("a"), 1) > 0); try testing.expect(c.strncasecmp(@ptrCast("A"), @ptrCast("b"), 1) < 0); diff --git a/test/tests.zig b/test/tests.zig index bfb7a4eaee02773ba7d54261cd2b72dd445859f0..b70e384e72fb38179853c34872ca2c8d0b8cfa0f 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -1611,8 +1611,6 @@ const module_test_targets = blk: { .abi = .msvc, }, .link_libc = true, - // https://codeberg.org/ziglang/zig/issues/35517 - .skip_modules = &.{"libc"}, }, .{ .target = .{ @@ -1628,8 +1626,6 @@ const module_test_targets = blk: { .abi = .gnu, }, .link_libc = true, - // https://codeberg.org/ziglang/zig/issues/35517 - .skip_modules = &.{"libc"}, }, .{ @@ -1657,8 +1653,6 @@ const module_test_targets = blk: { .abi = .msvc, }, .link_libc = true, - // https://codeberg.org/ziglang/zig/issues/35517 - .skip_modules = &.{"libc"}, }, .{ .target = .{ -- 2.54.0 From f1dbf830e225c47189f71d2952512a81e18b8651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 1 Jun 2026 10:45:00 +0200 Subject: [PATCH 8/8] test: disable failing C ABI tests for x86-windows ref https://codeberg.org/ziglang/zig/issues/35521 --- test/c_abi/cfuncs.c | 14 ++++++++++++++ test/c_abi/main.zig | 12 ++++++++++++ test/tests.zig | 15 +++++++-------- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/test/c_abi/cfuncs.c b/test/c_abi/cfuncs.c index 4ef3468f51cc12af666c62af28f15826a582ff6a..5e9d192c6ffc83fd4352281742730a6a58712995 100644 --- a/test/c_abi/cfuncs.c +++ b/test/c_abi/cfuncs.c @@ -2846,6 +2846,7 @@ void run_c_tests(void) { #if !defined(__mips64) #if !defined(ZIG_PPC32) #if !defined(__s390x__) +#if !(defined(_WIN32) && defined(__i386__)) { struct Struct_u8 s = zig_ret_struct_u8(); assert_or_panic(s.a == 1); @@ -2854,10 +2855,12 @@ void run_c_tests(void) { #endif #endif #endif +#endif #if !defined(__mips64) #if !defined(ZIG_PPC32) #if !defined(__s390x__) +#if !(defined(_WIN32) && defined(__i386__)) { struct Struct_u16 s = zig_ret_struct_u16(); assert_or_panic(s.a == 7); @@ -2866,10 +2869,12 @@ void run_c_tests(void) { #endif #endif #endif +#endif #if !defined(__mips64) #if !defined(ZIG_PPC32) #if !defined(__s390x__) +#if !(defined(_WIN32) && defined(__i386__)) { struct Struct_u32 s = zig_ret_struct_u32(); assert_or_panic(s.a == 13); @@ -2878,10 +2883,12 @@ void run_c_tests(void) { #endif #endif #endif +#endif #if !defined(ZIG_PPC32) #if !defined(ZIG_RISCV32) #if !defined(__s390x__) +#if !(defined(_WIN32) && defined(__i386__)) { struct Struct_u64 s = zig_ret_struct_u64(); assert_or_panic(s.a == 19); @@ -2890,6 +2897,7 @@ void run_c_tests(void) { #endif #endif #endif +#endif #if !defined(ZIG_PPC32) && !defined(__hexagon__) && !defined(__s390x__) { @@ -2908,15 +2916,18 @@ void run_c_tests(void) { } #if !defined(__mips64__) +#if !(defined(_WIN32) && defined(__i386__)) { struct Struct_f32 s = zig_ret_struct_f32(); assert_or_panic(s.a == 2.5f); zig_struct_f32((struct Struct_f32){ .a = 2.5f }); } #endif +#endif #if !(defined(__arm__) && defined(__SOFTFP__)) #if !defined(ZIG_RISCV32) +#if !(defined(_WIN32) && defined(__i386__)) { struct Struct_f64 s = zig_ret_struct_f64(); assert_or_panic(s.a == 2.5); @@ -2924,6 +2935,7 @@ void run_c_tests(void) { } #endif #endif +#endif #if !defined(__arm__) #if !defined(__loongarch__) @@ -2987,6 +2999,7 @@ void run_c_tests(void) { #endif #if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__) +#if !(defined(_WIN32) && defined(__i386__)) { struct Struct_u32_Union_u32_u32u32 s = zig_ret_struct_u32_union_u32_u32u32(); assert_or_panic(s.a == 1); @@ -3000,6 +3013,7 @@ void run_c_tests(void) { zig_struct_i32_i32(s); } #endif +#endif #if !defined(__powerpc64__) && !defined(__loongarch__) && !defined(__mips64__) { diff --git a/test/c_abi/main.zig b/test/c_abi/main.zig index b722e4089210a2520c6e67391d32bbb1097050e1..ff6ecbea9a4bd4a318fa8cbbd6cdcca73528b1ce 100644 --- a/test/c_abi/main.zig +++ b/test/c_abi/main.zig @@ -291,6 +291,7 @@ test "C ABI struct u8" { if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; const s = c_ret_struct_u8(); try expect(s.a == 4); @@ -318,6 +319,7 @@ test "C ABI struct u16" { if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; const s = c_ret_struct_u16(); try expect(s.a == 10); @@ -345,6 +347,7 @@ test "C ABI struct u32" { if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; const s = c_ret_struct_u32(); try expect(s.a == 16); @@ -372,6 +375,7 @@ test "C ABI struct u64" { if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; if (builtin.cpu.arch == .riscv32) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; const s = c_ret_struct_u64(); try expect(s.a == 22); @@ -485,6 +489,7 @@ test "C ABI struct f32" { if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; const s = c_ret_struct_f32(); try expect(s.a == 2.5); @@ -513,6 +518,7 @@ test "C ABI struct f64" { if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest; if (builtin.cpu.arch == .riscv32) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; const s = c_ret_struct_f64(); try expect(s.a == 2.5); @@ -705,6 +711,7 @@ test "C ABI struct i32 i32" { if (builtin.cpu.arch == .riscv32) return error.SkipZigTest; if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; const s: Struct_i32_i32 = .{ .a = 1, @@ -5681,6 +5688,7 @@ test "C ABI pointer sized float struct" { if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest; if (builtin.cpu.arch.isLoongArch() and builtin.abi.float() == .soft) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; c_ptr_size_float_struct(.{ .x = 1, .y = 2 }); @@ -5812,6 +5820,7 @@ test "PD: Zig passes to C" { if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 })); } test "PD: Zig returns to C" { @@ -5827,6 +5836,7 @@ test "PD: C passes to Zig" { if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; try expectOk(c_send_PD()); } test "PD: C returns to Zig" { @@ -5936,6 +5946,7 @@ test "f16 struct" { if (builtin.target.cpu.arch.isPowerPC32()) return error.SkipZigTest; if (builtin.cpu.arch.isArm() and builtin.mode != .Debug) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; const a = c_f16_struct(.{ .a = 12 }); try expect(a.a == 34); @@ -6045,6 +6056,7 @@ test "Stdcall ABI structs" { if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; const res = stdcall_coord2( .{ .x = 0x1111, .y = 0x2222 }, diff --git a/test/tests.zig b/test/tests.zig index b70e384e72fb38179853c34872ca2c8d0b8cfa0f..2610a54ccd884aa35976335aa5bf0ca974d6f052 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -1995,14 +1995,13 @@ const c_abi_targets = blk: { // Windows Targets - // https://codeberg.org/ziglang/zig/issues/35521 - //.{ - // .target = .{ - // .cpu_arch = .x86, - // .os_tag = .windows, - // .abi = .gnu, - // }, - //}, + .{ + .target = .{ + .cpu_arch = .x86, + .os_tag = .windows, + .abi = .gnu, + }, + }, .{ .target = .{ .cpu_arch = .x86_64, -- 2.54.0