authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-16 12:19:31-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-16 12:19:31-04:00
logcd5f69794d63ece18cd8f8aa0e2ce8bc16a31ab7
tree8874dcf7f2ddade357cff053eaad230dcde834a5
parent69a5f0d7973f2a3fefb69bc30c7dc1f0b430bba2

cross compile the stage2 tests for the target that they work for


2 files changed, 16 insertions(+), 4 deletions(-)

src-self-hosted/test.zig+5-1
......@@ -29,6 +29,7 @@ pub const TestContext = struct {
2929 name: []const u8,
3030 src: [:0]const u8,
3131 expected_zir: []const u8,
32 cross_target: std.zig.CrossTarget,
3233 };
3334
3435 pub fn addZIRCompareOutput(
......@@ -47,6 +48,7 @@ pub const TestContext = struct {
4748 pub fn addZIRTransform(
4849 ctx: *TestContext,
4950 name: []const u8,
51 cross_target: std.zig.CrossTarget,
5052 src: [:0]const u8,
5153 expected_zir: []const u8,
5254 ) void {
......@@ -54,6 +56,7 @@ pub const TestContext = struct {
5456 .name = name,
5557 .src = src,
5658 .expected_zir = expected_zir,
59 .cross_target = cross_target,
5760 }) catch unreachable;
5861 }
5962
......@@ -85,7 +88,8 @@ pub const TestContext = struct {
8588 }
8689 for (self.zir_transform_cases.items) |case| {
8790 std.testing.base_allocator_instance.reset();
88 try self.runOneZIRTransformCase(std.testing.allocator, root_node, case, native_info.target);
91 const info = try std.zig.system.NativeTargetInfo.detect(std.testing.allocator, case.cross_target);
92 try self.runOneZIRTransformCase(std.testing.allocator, root_node, case, info.target);
8993 try std.testing.allocator_instance.validate();
9094 }
9195 }
test/stage2/zir.zig+11-3
......@@ -1,7 +1,15 @@
1const std = @import("std");
12const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
3// self-hosted does not yet support PE executable files / COFF object files
4// or mach-o files. So we do the ZIR transform test cases cross compiling for
5// x86_64-linux.
6const linux_x64 = std.zig.CrossTarget{
7 .cpu_arch = .x86_64,
8 .os_tag = .linux,
9};
210
311pub fn addCases(ctx: *TestContext) void {
4 ctx.addZIRTransform("elemptr, add, cmp, condbr, return, breakpoint",
12 ctx.addZIRTransform("elemptr, add, cmp, condbr, return, breakpoint", linux_x64,
513 \\@void = primitive(void)
614 \\@usize = primitive(usize)
715 \\@fnty = fntype([], @void, cc=C)
......@@ -49,8 +57,8 @@ pub fn addCases(ctx: *TestContext) void {
4957 \\
5058 );
5159
52 if (@import("std").Target.current.os.tag != .linux or
53 @import("std").Target.current.cpu.arch != .x86_64)
60 if (std.Target.current.os.tag != .linux or
61 std.Target.current.cpu.arch != .x86_64)
5462 {
5563 // TODO implement self-hosted PE (.exe file) linking
5664 // TODO implement more ZIR so we don't depend on x86_64-linux