authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-06 22:57:53-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:13-07:00
log8b871ae27584c2433683ca064dbd3e7127d2a184
tree02e0513c3dfa370f0a457069f488f3ede297d011
parent0b8736f5ed6e7ae08e8ef84beb03351a95daabdd

re-enable C ABI tests

These were mostly already using the correct build API. I cleaned up the code a bit and unconditionally disabled LTO for these tests since that actually tests the intended behavior better.

2 files changed, 30 insertions(+), 30 deletions(-)

build.zig+1-1
......@@ -460,7 +460,7 @@ pub fn build(b: *std.Build) !void {
460460 // b.enable_wine,
461461 // enable_symlinks_windows,
462462 //));
463 //test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
463 test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
464464 //test_step.dependOn(tests.addLinkTests(b, test_filter, optimization_modes, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows));
465465 test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes));
466466 test_step.dependOn(tests.addCliTests(b, test_filter, optimization_modes));
test/tests.zig+29-29
......@@ -985,37 +985,37 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
985985
986986 const optimize_modes: [2]OptimizeMode = .{ .Debug, .ReleaseFast };
987987
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.
10081008 test_step.want_lto = false;
1009 }
10101009
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 }));
10171016
1018 step.dependOn(&test_step.step);
1019 };
1017 step.dependOn(&test_step.step);
1018 }
1019 }
10201020 return step;
10211021}