cross compile the stage2 tests for the target that they work for
This commit is contained in:
parent
69a5f0d797
commit
cd5f69794d
@ -29,6 +29,7 @@ pub const TestContext = struct {
|
||||
name: []const u8,
|
||||
src: [:0]const u8,
|
||||
expected_zir: []const u8,
|
||||
cross_target: std.zig.CrossTarget,
|
||||
};
|
||||
|
||||
pub fn addZIRCompareOutput(
|
||||
@ -47,6 +48,7 @@ pub const TestContext = struct {
|
||||
pub fn addZIRTransform(
|
||||
ctx: *TestContext,
|
||||
name: []const u8,
|
||||
cross_target: std.zig.CrossTarget,
|
||||
src: [:0]const u8,
|
||||
expected_zir: []const u8,
|
||||
) void {
|
||||
@ -54,6 +56,7 @@ pub const TestContext = struct {
|
||||
.name = name,
|
||||
.src = src,
|
||||
.expected_zir = expected_zir,
|
||||
.cross_target = cross_target,
|
||||
}) catch unreachable;
|
||||
}
|
||||
|
||||
@ -85,7 +88,8 @@ pub const TestContext = struct {
|
||||
}
|
||||
for (self.zir_transform_cases.items) |case| {
|
||||
std.testing.base_allocator_instance.reset();
|
||||
try self.runOneZIRTransformCase(std.testing.allocator, root_node, case, native_info.target);
|
||||
const info = try std.zig.system.NativeTargetInfo.detect(std.testing.allocator, case.cross_target);
|
||||
try self.runOneZIRTransformCase(std.testing.allocator, root_node, case, info.target);
|
||||
try std.testing.allocator_instance.validate();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,15 @@
|
||||
const std = @import("std");
|
||||
const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
|
||||
// self-hosted does not yet support PE executable files / COFF object files
|
||||
// or mach-o files. So we do the ZIR transform test cases cross compiling for
|
||||
// x86_64-linux.
|
||||
const linux_x64 = std.zig.CrossTarget{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .linux,
|
||||
};
|
||||
|
||||
pub fn addCases(ctx: *TestContext) void {
|
||||
ctx.addZIRTransform("elemptr, add, cmp, condbr, return, breakpoint",
|
||||
ctx.addZIRTransform("elemptr, add, cmp, condbr, return, breakpoint", linux_x64,
|
||||
\\@void = primitive(void)
|
||||
\\@usize = primitive(usize)
|
||||
\\@fnty = fntype([], @void, cc=C)
|
||||
@ -49,8 +57,8 @@ pub fn addCases(ctx: *TestContext) void {
|
||||
\\
|
||||
);
|
||||
|
||||
if (@import("std").Target.current.os.tag != .linux or
|
||||
@import("std").Target.current.cpu.arch != .x86_64)
|
||||
if (std.Target.current.os.tag != .linux or
|
||||
std.Target.current.cpu.arch != .x86_64)
|
||||
{
|
||||
// TODO implement self-hosted PE (.exe file) linking
|
||||
// TODO implement more ZIR so we don't depend on x86_64-linux
|
||||
|
Loading…
x
Reference in New Issue
Block a user