authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-06-01 19:20:03+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-06-01 19:20:03+02:00
log0c41edf4978cc45b59909fce69885e310360cbfa
treee143076d2f253578e9a5a6fdd4f13e201b98e3c0
parent45c4f781a5a831dd08cbab745a55834d514e45f5
parentf1dbf830e225c47189f71d2952512a81e18b8651

Merge pull request 'Some follow-up work for #35502' (#35565) from alexrp/zig:35502-followup into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35565

10 files changed, 140 insertions(+), 65 deletions(-)

lib/std/c.zig+20-3
......@@ -11134,14 +11134,23 @@ pub const ioctl = switch (native_os) {
1113411134
1113511135pub extern "c" fn bzero(s: *anyopaque, n: usize) void;
1113611136
11137pub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void;
11137pub const swab = switch (builtin.abi) {
11138 .msvc => private._swab,
11139 else => private.swab,
11140};
1113811141
1113911142pub extern "c" fn strncmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int;
1114011143pub extern "c" fn strcasecmp(a: [*:0]const c_char, b: [*:0]const c_char) c_int;
1114111144pub extern "c" fn strncasecmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int;
11142pub extern "c" fn strdup(s: [*:0]const c_char) ?[*:0]c_char;
11145pub const strdup = switch (builtin.abi) {
11146 .msvc => private._strdup,
11147 else => private.strdup,
11148};
1114311149pub extern "c" fn strndup(s: [*:0]const c_char, n: usize) ?[*:0]c_char;
11144pub extern "c" fn wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t;
11150pub const wcsdup = switch (builtin.abi) {
11151 .msvc => private._wcsdup,
11152 else => private.wcsdup,
11153};
1114511154
1114611155pub extern "c" fn ffs(i: c_int) c_int;
1114711156pub extern "c" fn ffsl(i: c_long) c_long;
......@@ -11555,6 +11564,14 @@ pub const setkeymap = serenity.setkeymap;
1155511564
1155611565/// External definitions shared by two or more operating systems.
1155711566const private = struct {
11567 pub extern "c" fn strdup(s: [*:0]const c_char) ?[*:0]c_char;
11568 pub extern "c" fn _strdup(s: [*:0]const c_char) ?[*:0]c_char;
11569 pub extern "c" fn wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t;
11570 pub extern "c" fn _wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t;
11571
11572 pub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void;
11573 pub extern "c" fn _swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void;
11574
1155811575 extern "c" fn close(fd: fd_t) c_int;
1155911576 extern "c" fn clock_getres(clk_id: clockid_t, tp: *timespec) c_int;
1156011577 extern "c" fn clock_gettime(clk_id: clockid_t, tp: *timespec) c_int;
test/behavior/call.zig+4-4
......@@ -277,7 +277,7 @@ test "forced tail call" {
277277 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
278278 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
279279
280 if (builtin.zig_backend == .stage2_llvm) {
280 if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) {
281281 if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) {
282282 return error.SkipZigTest;
283283 }
......@@ -312,7 +312,7 @@ test "inline call preserves tail call" {
312312 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
313313 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
314314
315 if (builtin.zig_backend == .stage2_llvm) {
315 if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) {
316316 if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) {
317317 return error.SkipZigTest;
318318 }
......@@ -708,7 +708,7 @@ test "tail call function pointer" {
708708 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
709709 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
710710
711 if (builtin.zig_backend == .stage2_llvm) {
711 if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) {
712712 if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) {
713713 return error.SkipZigTest;
714714 }
......@@ -736,7 +736,7 @@ test "tail call with potentially extended types" {
736736 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
737737 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
738738
739 if (builtin.zig_backend == .stage2_llvm) {
739 if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) {
740740 if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) {
741741 return error.SkipZigTest;
742742 }
test/c/math.zig+3
......@@ -61,10 +61,13 @@ test "modf" {
6161}
6262
6363test "modff" {
64 if (builtin.cpu.arch == .x86 and builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only
65
6466 try testModf(f32);
6567}
6668
6769test "modfl" {
70 if (builtin.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only
6871 if (builtin.target.cpu.arch.isPowerPC()) return error.SkipZigTest; // TODO: see https://codeberg.org/ziglang/zig/issues/30976
6972
7073 try testModf(c_longdouble);
test/c/pthread.zig+1
......@@ -7,6 +7,7 @@ const testing = std.testing;
77
88test "pthread_spinlock_t" {
99 if (builtin.target.os.tag.isDarwin()) return; // Darwin doesn't have `pthread_spin_*`
10 if (builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // winpthreads-only
1011
1112 var spin: c.pthread_spinlock_t = undefined;
1213 _ = c.pthread_spin_init(&spin, c.PTHREAD_PROCESS_PRIVATE);
test/c/stdlib.zig+14
......@@ -33,6 +33,7 @@ test "div" {
3333 if (builtin.target.cpu.arch.isMIPS64()) return error.SkipZigTest; // TODO
3434 if (builtin.target.cpu.arch.isPowerPC()) return error.SkipZigTest; // TODO
3535 if (builtin.target.cpu.arch == .s390x) return error.SkipZigTest; // TODO
36 if (builtin.target.cpu.arch == .x86 and builtin.target.os.tag == .windows) return error.SkipZigTest; // TODO
3637
3738 const expected: c.div_t = .{ .quot = 5, .rem = 5 };
3839 try testing.expectEqual(expected, c.div(55, 10));
......@@ -42,6 +43,7 @@ test "ldiv" {
4243 if (builtin.target.cpu.arch.isMIPS64() and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO
4344 if (builtin.target.cpu.arch.isPowerPC32()) return error.SkipZigTest; // TODO
4445 if (builtin.target.cpu.arch == .s390x) return error.SkipZigTest; // TODO
46 if (builtin.target.cpu.arch == .x86 and builtin.target.os.tag == .windows) return error.SkipZigTest; // TODO
4547
4648 const expected: c.ldiv_t = .{ .quot = -6, .rem = 2 };
4749 try testing.expectEqual(expected, c.ldiv(38, -6));
......@@ -129,6 +131,8 @@ fn testStrToLLikeFunctionAnyErrno(
129131}
130132
131133test "strtol" {
134 if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO
135
132136 c._errno().* = @intFromEnum(c.E.SUCCESS);
133137 try testStrToLLikeFunctionAnyErrno(c.strtol, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL });
134138 try testStrToLLikeFunction(c.strtol, @ptrCast("42true"), 0, 42, 2, .SUCCESS);
......@@ -167,6 +171,8 @@ test "strtol" {
167171}
168172
169173test "strtoll" {
174 if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO
175
170176 c._errno().* = @intFromEnum(c.E.SUCCESS);
171177 try testStrToLLikeFunctionAnyErrno(c.strtoll, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL });
172178 try testStrToLLikeFunction(c.strtoll, @ptrCast("42true"), 0, 42, 2, .SUCCESS);
......@@ -205,6 +211,8 @@ test "strtoll" {
205211}
206212
207213test "strtoul" {
214 if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO
215
208216 c._errno().* = @intFromEnum(c.E.SUCCESS);
209217 try testStrToLLikeFunctionAnyErrno(c.strtoul, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL });
210218 try testStrToLLikeFunction(c.strtoul, @ptrCast("42true"), 0, 42, 2, .SUCCESS);
......@@ -241,6 +249,8 @@ test "strtoul" {
241249}
242250
243251test "strtoull" {
252 if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO
253
244254 c._errno().* = @intFromEnum(c.E.SUCCESS);
245255 try testStrToLLikeFunctionAnyErrno(c.strtoull, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL });
246256 try testStrToLLikeFunction(c.strtoull, @ptrCast("42true"), 0, 42, 2, .SUCCESS);
......@@ -277,6 +287,8 @@ test "strtoull" {
277287}
278288
279289test "strtoimax" {
290 if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO
291
280292 c._errno().* = @intFromEnum(c.E.SUCCESS);
281293 try testStrToLLikeFunctionAnyErrno(c.strtoimax, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL });
282294 try testStrToLLikeFunction(c.strtoimax, @ptrCast("42true"), 0, 42, 2, .SUCCESS);
......@@ -315,6 +327,8 @@ test "strtoimax" {
315327}
316328
317329test "strtoumax" {
330 if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO
331
318332 c._errno().* = @intFromEnum(c.E.SUCCESS);
319333 try testStrToLLikeFunctionAnyErrno(c.strtoumax, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL });
320334 try testStrToLLikeFunction(c.strtoumax, @ptrCast("42true"), 0, 42, 2, .SUCCESS);
test/c/strings.zig+4
......@@ -48,6 +48,8 @@ test "ffs" {
4848}
4949
5050test "strcasecmp" {
51 if (builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only
52
5153 try testing.expect(c.strcasecmp(@ptrCast("a"), @ptrCast("b")) < 0);
5254 try testing.expect(c.strcasecmp(@ptrCast("b"), @ptrCast("a")) > 0);
5355 try testing.expect(c.strcasecmp(@ptrCast("A"), @ptrCast("b")) < 0);
......@@ -58,6 +60,8 @@ test "strcasecmp" {
5860}
5961
6062test "strncasecmp" {
63 if (builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only
64
6165 try testing.expect(c.strncasecmp(@ptrCast("a"), @ptrCast("b"), 1) < 0);
6266 try testing.expect(c.strncasecmp(@ptrCast("b"), @ptrCast("a"), 1) > 0);
6367 try testing.expect(c.strncasecmp(@ptrCast("A"), @ptrCast("b"), 1) < 0);
test/c/unistd.zig+1
......@@ -8,6 +8,7 @@ test "swab" {
88 if (builtin.target.cpu.arch.isMIPS64() and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO
99 if (builtin.target.cpu.arch == .x86_64 and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO
1010 if (builtin.target.os.tag == .netbsd) return error.SkipZigTest; // TODO
11 if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO
1112
1213 var a: [4]u8 = undefined;
1314 @memset(a[0..], '\x00');
test/c_abi/cfuncs.c+14
......@@ -2846,6 +2846,7 @@ void run_c_tests(void) {
28462846#if !defined(__mips64)
28472847#if !defined(ZIG_PPC32)
28482848#if !defined(__s390x__)
2849#if !(defined(_WIN32) && defined(__i386__))
28492850 {
28502851 struct Struct_u8 s = zig_ret_struct_u8();
28512852 assert_or_panic(s.a == 1);
......@@ -2854,10 +2855,12 @@ void run_c_tests(void) {
28542855#endif
28552856#endif
28562857#endif
2858#endif
28572859
28582860#if !defined(__mips64)
28592861#if !defined(ZIG_PPC32)
28602862#if !defined(__s390x__)
2863#if !(defined(_WIN32) && defined(__i386__))
28612864 {
28622865 struct Struct_u16 s = zig_ret_struct_u16();
28632866 assert_or_panic(s.a == 7);
......@@ -2866,10 +2869,12 @@ void run_c_tests(void) {
28662869#endif
28672870#endif
28682871#endif
2872#endif
28692873
28702874#if !defined(__mips64)
28712875#if !defined(ZIG_PPC32)
28722876#if !defined(__s390x__)
2877#if !(defined(_WIN32) && defined(__i386__))
28732878 {
28742879 struct Struct_u32 s = zig_ret_struct_u32();
28752880 assert_or_panic(s.a == 13);
......@@ -2878,10 +2883,12 @@ void run_c_tests(void) {
28782883#endif
28792884#endif
28802885#endif
2886#endif
28812887
28822888#if !defined(ZIG_PPC32)
28832889#if !defined(ZIG_RISCV32)
28842890#if !defined(__s390x__)
2891#if !(defined(_WIN32) && defined(__i386__))
28852892 {
28862893 struct Struct_u64 s = zig_ret_struct_u64();
28872894 assert_or_panic(s.a == 19);
......@@ -2890,6 +2897,7 @@ void run_c_tests(void) {
28902897#endif
28912898#endif
28922899#endif
2900#endif
28932901
28942902#if !defined(ZIG_PPC32) && !defined(__hexagon__) && !defined(__s390x__)
28952903 {
......@@ -2908,15 +2916,18 @@ void run_c_tests(void) {
29082916 }
29092917
29102918#if !defined(__mips64__)
2919#if !(defined(_WIN32) && defined(__i386__))
29112920 {
29122921 struct Struct_f32 s = zig_ret_struct_f32();
29132922 assert_or_panic(s.a == 2.5f);
29142923 zig_struct_f32((struct Struct_f32){ .a = 2.5f });
29152924 }
29162925#endif
2926#endif
29172927
29182928#if !(defined(__arm__) && defined(__SOFTFP__))
29192929#if !defined(ZIG_RISCV32)
2930#if !(defined(_WIN32) && defined(__i386__))
29202931 {
29212932 struct Struct_f64 s = zig_ret_struct_f64();
29222933 assert_or_panic(s.a == 2.5);
......@@ -2924,6 +2935,7 @@ void run_c_tests(void) {
29242935 }
29252936#endif
29262937#endif
2938#endif
29272939
29282940#if !defined(__arm__)
29292941#if !defined(__loongarch__)
......@@ -2987,6 +2999,7 @@ void run_c_tests(void) {
29872999#endif
29883000
29893001#if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__)
3002#if !(defined(_WIN32) && defined(__i386__))
29903003 {
29913004 struct Struct_u32_Union_u32_u32u32 s = zig_ret_struct_u32_union_u32_u32u32();
29923005 assert_or_panic(s.a == 1);
......@@ -3000,6 +3013,7 @@ void run_c_tests(void) {
30003013 zig_struct_i32_i32(s);
30013014 }
30023015#endif
3016#endif
30033017
30043018#if !defined(__powerpc64__) && !defined(__loongarch__) && !defined(__mips64__)
30053019 {
test/c_abi/main.zig+12
......@@ -291,6 +291,7 @@ test "C ABI struct u8" {
291291 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
292292 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
293293 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
294 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
294295
295296 const s = c_ret_struct_u8();
296297 try expect(s.a == 4);
......@@ -318,6 +319,7 @@ test "C ABI struct u16" {
318319 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
319320 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
320321 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
322 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
321323
322324 const s = c_ret_struct_u16();
323325 try expect(s.a == 10);
......@@ -345,6 +347,7 @@ test "C ABI struct u32" {
345347 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
346348 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
347349 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
350 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
348351
349352 const s = c_ret_struct_u32();
350353 try expect(s.a == 16);
......@@ -372,6 +375,7 @@ test "C ABI struct u64" {
372375 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
373376 if (builtin.cpu.arch == .riscv32) return error.SkipZigTest;
374377 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
378 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
375379
376380 const s = c_ret_struct_u64();
377381 try expect(s.a == 22);
......@@ -485,6 +489,7 @@ test "C ABI struct f32" {
485489 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
486490 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
487491 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
492 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
488493
489494 const s = c_ret_struct_f32();
490495 try expect(s.a == 2.5);
......@@ -513,6 +518,7 @@ test "C ABI struct f64" {
513518 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
514519 if (builtin.cpu.arch == .riscv32) return error.SkipZigTest;
515520 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
521 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
516522
517523 const s = c_ret_struct_f64();
518524 try expect(s.a == 2.5);
......@@ -705,6 +711,7 @@ test "C ABI struct i32 i32" {
705711 if (builtin.cpu.arch == .riscv32) return error.SkipZigTest;
706712 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
707713 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
714 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
708715
709716 const s: Struct_i32_i32 = .{
710717 .a = 1,
......@@ -5681,6 +5688,7 @@ test "C ABI pointer sized float struct" {
56815688 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
56825689 if (builtin.cpu.arch.isLoongArch() and builtin.abi.float() == .soft) return error.SkipZigTest;
56835690 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
5691 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
56845692
56855693 c_ptr_size_float_struct(.{ .x = 1, .y = 2 });
56865694
......@@ -5812,6 +5820,7 @@ test "PD: Zig passes to C" {
58125820 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
58135821 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
58145822 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
5823 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
58155824 try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 }));
58165825}
58175826test "PD: Zig returns to C" {
......@@ -5827,6 +5836,7 @@ test "PD: C passes to Zig" {
58275836 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
58285837 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
58295838 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
5839 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
58305840 try expectOk(c_send_PD());
58315841}
58325842test "PD: C returns to Zig" {
......@@ -5936,6 +5946,7 @@ test "f16 struct" {
59365946 if (builtin.target.cpu.arch.isPowerPC32()) return error.SkipZigTest;
59375947 if (builtin.cpu.arch.isArm() and builtin.mode != .Debug) return error.SkipZigTest;
59385948 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
5949 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
59395950
59405951 const a = c_f16_struct(.{ .a = 12 });
59415952 try expect(a.a == 34);
......@@ -6045,6 +6056,7 @@ test "Stdcall ABI structs" {
60456056 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
60466057 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
60476058 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
6059 if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest;
60486060
60496061 const res = stdcall_coord2(
60506062 .{ .x = 0x1111, .y = 0x2222 },
test/tests.zig+67-58
......@@ -1611,8 +1611,6 @@ const module_test_targets = blk: {
16111611 .abi = .msvc,
16121612 },
16131613 .link_libc = true,
1614 // https://codeberg.org/ziglang/zig/issues/35517
1615 .skip_modules = &.{"libc"},
16161614 },
16171615 .{
16181616 .target = .{
......@@ -1628,8 +1626,6 @@ const module_test_targets = blk: {
16281626 .abi = .gnu,
16291627 },
16301628 .link_libc = true,
1631 // https://codeberg.org/ziglang/zig/issues/35517
1632 .skip_modules = &.{"libc"},
16331629 },
16341630
16351631 .{
......@@ -1657,8 +1653,6 @@ const module_test_targets = blk: {
16571653 .abi = .msvc,
16581654 },
16591655 .link_libc = true,
1660 // https://codeberg.org/ziglang/zig/issues/35517
1661 .skip_modules = &.{"libc"},
16621656 },
16631657 .{
16641658 .target = .{
......@@ -2001,14 +1995,13 @@ const c_abi_targets = blk: {
20011995
20021996 // Windows Targets
20031997
2004 // https://codeberg.org/ziglang/zig/issues/35521
2005 //.{
2006 // .target = .{
2007 // .cpu_arch = .x86,
2008 // .os_tag = .windows,
2009 // .abi = .gnu,
2010 // },
2011 //},
1998 .{
1999 .target = .{
2000 .cpu_arch = .x86,
2001 .os_tag = .windows,
2002 .abi = .gnu,
2003 },
2004 },
20122005 .{
20132006 .target = .{
20142007 .cpu_arch = .x86_64,
......@@ -2650,11 +2643,6 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
26502643
26512644 const target = &resolved_target.result;
26522645
2653 if (target.cpu.arch == .powerpc64le and target.ofmt == .c) {
2654 // https://codeberg.org/ziglang/zig/issues/35522
2655 continue;
2656 }
2657
26582646 if (target.cpu.arch == .s390x and target.ofmt == .c) {
26592647 // https://codeberg.org/ziglang/zig/issues/35523
26602648 continue;
......@@ -2811,45 +2799,66 @@ fn addOneModuleTest(
28112799
28122800 compile_c.addCSourceFile(.{
28132801 .file = these_tests.getEmittedBin(),
2814 .flags = &.{
2815 // Tracking issue for making the C backend generate C89 compatible code:
2816 // https://github.com/ziglang/zig/issues/19468
2817 "-std=c99",
2818 "-Werror",
2819
2820 "-Wall",
2821 "-Wembedded-directive",
2822 "-Wempty-translation-unit",
2823 "-Wextra",
2824 "-Wgnu",
2825 "-Winvalid-utf8",
2826 "-Wkeyword-macro",
2827 "-Woverlength-strings",
2828
2829 // Tracking issue for making the C backend generate code
2830 // that does not trigger warnings:
2831 // https://github.com/ziglang/zig/issues/19467
2832
2833 // spotted everywhere
2834 "-Wno-builtin-requires-header",
2835
2836 // spotted on linux
2837 "-Wno-braced-scalar-init",
2838 "-Wno-excess-initializers",
2839 "-Wno-incompatible-pointer-types-discards-qualifiers",
2840 "-Wno-unused",
2841 "-Wno-unused-parameter",
2842
2843 // spotted on darwin
2844 "-Wno-incompatible-pointer-types",
2845
2846 // https://github.com/llvm/llvm-project/issues/153314
2847 "-Wno-unterminated-string-initialization",
2848
2849 // In both Zig and C it is legal to return a pointer to a
2850 // local. The C backend lowers such thing directly, so the
2851 // corresponding warning in C must be disabled.
2852 "-Wno-return-stack-address",
2802 .flags = blk: {
2803 const invariant_cflags: []const []const u8 = &.{
2804 // Tracking issue for making the C backend generate C89 compatible code:
2805 // https://github.com/ziglang/zig/issues/19468
2806 "-std=c99",
2807 "-Werror",
2808
2809 "-Wall",
2810 "-Wembedded-directive",
2811 "-Wempty-translation-unit",
2812 "-Wextra",
2813 "-Wgnu",
2814 "-Winvalid-utf8",
2815 "-Wkeyword-macro",
2816 "-Woverlength-strings",
2817
2818 // Tracking issue for making the C backend generate code
2819 // that does not trigger warnings:
2820 // https://github.com/ziglang/zig/issues/19467
2821
2822 // spotted everywhere
2823 "-Wno-builtin-requires-header",
2824
2825 // spotted on linux
2826 "-Wno-braced-scalar-init",
2827 "-Wno-excess-initializers",
2828 "-Wno-incompatible-pointer-types-discards-qualifiers",
2829 "-Wno-unused",
2830 "-Wno-unused-parameter",
2831
2832 // spotted on darwin
2833 "-Wno-incompatible-pointer-types",
2834
2835 // https://github.com/llvm/llvm-project/issues/153314
2836 "-Wno-unterminated-string-initialization",
2837
2838 // In both Zig and C it is legal to return a pointer to a
2839 // local. The C backend lowers such thing directly, so the
2840 // corresponding warning in C must be disabled.
2841 "-Wno-return-stack-address",
2842 };
2843
2844 const function_data_sections = switch (target.cpu.arch) {
2845 .arm,
2846 .armeb,
2847 .thumb,
2848 .thumbeb,
2849 .hexagon,
2850 .powerpc,
2851 .powerpcle,
2852 .powerpc64,
2853 .powerpc64le,
2854 => true,
2855 else => false,
2856 };
2857
2858 break :blk if (function_data_sections) invariant_cflags ++ &[_][]const u8{
2859 "-ffunction-sections",
2860 "-fdata-sections",
2861 } else invariant_cflags;
28532862 },
28542863 });
28552864 compile_c.addIncludePath(b.path("lib")); // for zig.h