| ... | ... | @@ -985,37 +985,37 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S |
| 985 | 985 | |
| 986 | 986 | const optimize_modes: [2]OptimizeMode = .{ .Debug, .ReleaseFast }; |
| 987 | 987 | |
| 988 | | for (optimize_modes[0 .. @as(u8, 1) + @boolToInt(!skip_release)]) |optimize_mode| for (c_abi_targets) |c_abi_target| { |
| 989 | | if (skip_non_native and !c_abi_target.isNative()) |
| 990 | | continue; |
| 991 | | |
| 992 | | const test_step = b.addTest(.{ |
| 993 | | .root_source_file = .{ .path = "test/c_abi/main.zig" }, |
| 994 | | .optimize = optimize_mode, |
| 995 | | .target = c_abi_target, |
| 996 | | }); |
| 997 | | if (c_abi_target.abi != null and c_abi_target.abi.?.isMusl()) { |
| 998 | | // TODO NativeTargetInfo insists on dynamically linking musl |
| 999 | | // for some reason? |
| 1000 | | test_step.target_info.dynamic_linker.max_byte = null; |
| 1001 | | } |
| 1002 | | test_step.linkLibC(); |
| 1003 | | test_step.addCSourceFile("test/c_abi/cfuncs.c", &.{"-std=c99"}); |
| 1004 | | |
| 1005 | | if (c_abi_target.isWindows() and (c_abi_target.getCpuArch() == .x86 or builtin.target.os.tag == .linux)) { |
| 1006 | | // LTO currently incorrectly strips stdcall name-mangled functions |
| 1007 | | // LLD crashes in LTO here when cross compiling for windows on linux |
| 988 | for (optimize_modes) |optimize_mode| { |
| 989 | if (optimize_mode != .Debug and skip_release) continue; |
| 990 | |
| 991 | for (c_abi_targets) |c_abi_target| { |
| 992 | if (skip_non_native and !c_abi_target.isNative()) continue; |
| 993 | |
| 994 | const test_step = b.addTest(.{ |
| 995 | .root_source_file = .{ .path = "test/c_abi/main.zig" }, |
| 996 | .optimize = optimize_mode, |
| 997 | .target = c_abi_target, |
| 998 | }); |
| 999 | if (c_abi_target.abi != null and c_abi_target.abi.?.isMusl()) { |
| 1000 | // TODO NativeTargetInfo insists on dynamically linking musl |
| 1001 | // for some reason? |
| 1002 | test_step.target_info.dynamic_linker.max_byte = null; |
| 1003 | } |
| 1004 | test_step.linkLibC(); |
| 1005 | test_step.addCSourceFile("test/c_abi/cfuncs.c", &.{"-std=c99"}); |
| 1006 | // This test is intentionally trying to check if the external ABI is |
| 1007 | // done properly. LTO would be a hindrance to this. |
| 1008 | 1008 | test_step.want_lto = false; |
| 1009 | | } |
| 1010 | 1009 | |
| 1011 | | const triple_prefix = c_abi_target.zigTriple(b.allocator) catch @panic("OOM"); |
| 1012 | | test_step.setNamePrefix(b.fmt("{s}-{s}-{s} ", .{ |
| 1013 | | "test-c-abi", |
| 1014 | | triple_prefix, |
| 1015 | | @tagName(optimize_mode), |
| 1016 | | })); |
| 1010 | const triple_prefix = c_abi_target.zigTriple(b.allocator) catch @panic("OOM"); |
| 1011 | test_step.setNamePrefix(b.fmt("{s}-{s}-{s} ", .{ |
| 1012 | "test-c-abi", |
| 1013 | triple_prefix, |
| 1014 | @tagName(optimize_mode), |
| 1015 | })); |
| 1017 | 1016 | |
| 1018 | | step.dependOn(&test_step.step); |
| 1019 | | }; |
| 1017 | step.dependOn(&test_step.step); |
| 1018 | } |
| 1019 | } |
| 1020 | 1020 | return step; |
| 1021 | 1021 | } |