authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-02-27 11:48:42+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-02-27 11:57:12+02:00
log950d840be66deb9239c0effa90ee41a7c0884f95
tree50c2f0f8c60bab3586e889a9ff4d457480ec4482
parent593d23c0d746deae1036b5209c683c1984dd0203

stage2: use stage1 test runner for stage2


5 files changed, 50 insertions(+), 32 deletions(-)

lib/std/Progress.zig+8-2
......@@ -269,7 +269,12 @@ fn refreshWithHeldLock(self: *Progress) void {
269269 }
270270 if (eti > 0) {
271271 if (need_ellipse) self.bufWrite(&end, " ", .{});
272 self.bufWrite(&end, "[{d}/{d}] ", .{ current_item, eti });
272 if (builtin.zig_backend == .stage2_llvm) {
273 self.bufWrite(&end, "[{d}/ ", .{current_item});
274 self.bufWrite(&end, "{d}] ", .{eti});
275 } else {
276 self.bufWrite(&end, "[{d}/{d}] ", .{ current_item, eti });
277 }
273278 need_ellipse = false;
274279 } else if (completed_items != 0) {
275280 if (need_ellipse) self.bufWrite(&end, " ", .{});
......@@ -284,9 +289,10 @@ fn refreshWithHeldLock(self: *Progress) void {
284289 }
285290 }
286291
287 _ = file.write(self.output_buffer[0..end]) catch {
292 _ = file.write(self.output_buffer[0..end]) catch blk: {
288293 // Stop trying to write to this file once it errors.
289294 self.terminal = null;
295 break :blk 0; // TODO stage2 requires this
290296 };
291297 if (self.timer) |*timer| {
292298 self.prev_refresh_timestamp = timer.read();
lib/std/os/linux.zig+1-1
......@@ -871,7 +871,7 @@ var vdso_clock_gettime = @ptrCast(?*const anyopaque, init_vdso_clock_gettime);
871871const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize;
872872
873873pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
874 if (@hasDecl(VDSO, "CGT_SYM")) {
874 if (@hasDecl(VDSO, "CGT_SYM") and builtin.zig_backend == .stage1) {
875875 const ptr = @atomicLoad(?*const anyopaque, &vdso_clock_gettime, .Unordered);
876876 if (ptr) |fn_ptr| {
877877 const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);
lib/std/special/test_runner.zig+26-23
......@@ -23,10 +23,12 @@ fn processArgs() void {
2323}
2424
2525pub fn main() void {
26 if (builtin.zig_backend != .stage1) {
26 if (builtin.zig_backend != .stage1 and
27 builtin.zig_backend != .stage2_llvm)
28 {
2729 return main2() catch @panic("test failure");
2830 }
29 processArgs();
31 if (builtin.zig_backend == .stage1) processArgs();
3032 const test_fn_list = builtin.test_functions;
3133 var ok_count: usize = 0;
3234 var skip_count: usize = 0;
......@@ -44,9 +46,9 @@ pub fn main() void {
4446
4547 var leaks: usize = 0;
4648 for (test_fn_list) |test_fn, i| {
47 std.testing.allocator_instance = .{};
49 if (builtin.zig_backend != .stage2_llvm) std.testing.allocator_instance = .{};
4850 defer {
49 if (std.testing.allocator_instance.deinit()) {
51 if (builtin.zig_backend != .stage2_llvm and std.testing.allocator_instance.deinit()) {
5052 leaks += 1;
5153 }
5254 }
......@@ -56,9 +58,17 @@ pub fn main() void {
5658 test_node.activate();
5759 progress.refresh();
5860 if (!have_tty) {
59 std.debug.print("{d}/{d} {s}... ", .{ i + 1, test_fn_list.len, test_fn.name });
61 if (builtin.zig_backend == .stage2_llvm) {
62 std.debug.print("{d}/", .{i + 1});
63 std.debug.print("{d} ", .{test_fn_list.len});
64 std.debug.print("{s}... ", .{test_fn.name});
65 } else {
66 std.debug.print("{d}/{d} {s}... ", .{ i + 1, test_fn_list.len, test_fn.name });
67 }
6068 }
61 const result = if (test_fn.async_frame_size) |size| switch (io_mode) {
69 const result = if (builtin.zig_backend == .stage2_llvm)
70 test_fn.func()
71 else if (test_fn.async_frame_size) |size| switch (io_mode) {
6272 .evented => blk: {
6373 if (async_frame_buffer.len < size) {
6474 std.heap.page_allocator.free(async_frame_buffer);
......@@ -90,9 +100,9 @@ pub fn main() void {
90100 fail_count += 1;
91101 progress.log("FAIL ({s})\n", .{@errorName(err)});
92102 if (!have_tty) std.debug.print("FAIL ({s})\n", .{@errorName(err)});
93 if (@errorReturnTrace()) |trace| {
103 if (builtin.zig_backend != .stage2_llvm) if (@errorReturnTrace()) |trace| {
94104 std.debug.dumpStackTrace(trace.*);
95 }
105 };
96106 test_node.end();
97107 },
98108 }
......@@ -101,7 +111,13 @@ pub fn main() void {
101111 if (ok_count == test_fn_list.len) {
102112 std.debug.print("All {d} tests passed.\n", .{ok_count});
103113 } else {
104 std.debug.print("{d} passed; {d} skipped; {d} failed.\n", .{ ok_count, skip_count, fail_count });
114 if (builtin.zig_backend == .stage2_llvm) {
115 std.debug.print("{d} passed; ", .{ok_count});
116 std.debug.print("{d} skipped; ", .{skip_count});
117 std.debug.print("{d} failed.\n", .{fail_count});
118 } else {
119 std.debug.print("{d} passed; {d} skipped; {d} failed.\n", .{ ok_count, skip_count, fail_count });
120 }
105121 }
106122 if (log_err_count != 0) {
107123 std.debug.print("{d} errors were logged.\n", .{log_err_count});
......@@ -141,20 +157,7 @@ pub fn main2() anyerror!void {
141157 }
142158 };
143159 }
144 if (builtin.zig_backend == .stage2_llvm) {
145 const stderr = std.io.getStdErr().writer();
146 const ok_count = builtin.test_functions.len - skipped - failed;
147 if (ok_count == builtin.test_functions.len) {
148 try stderr.print("All {d} tests passed.\n", .{ok_count});
149 } else {
150 try stderr.print("{d} passed; ", .{ok_count});
151 try stderr.print("{d} skipped; ", .{skipped});
152 try stderr.print("{d} failed.\n", .{failed});
153 }
154 if (failed != 0) {
155 std.process.exit(1);
156 }
157 } else if (builtin.zig_backend == .stage2_wasm or
160 if (builtin.zig_backend == .stage2_wasm or
158161 builtin.zig_backend == .stage2_x86_64)
159162 {
160163 const passed = builtin.test_functions.len - skipped - failed;
src/Module.zig+1-1
......@@ -3762,7 +3762,7 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool {
37623762 // Note this resolves the type of the Decl, not the value; if this Decl
37633763 // is a struct, for example, this resolves `type` (which needs no resolution),
37643764 // not the struct itself.
3765 try sema.resolveTypeLayout(&block_scope, src, decl_tv.ty);
3765 try sema.resolveTypeFully(&block_scope, src, decl_tv.ty);
37663766
37673767 const decl_arena_state = try decl_arena_allocator.create(std.heap.ArenaAllocator.State);
37683768
src/Sema.zig+14-5
......@@ -11947,19 +11947,27 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
1194711947 var buffer: Value.ToTypeBuffer = undefined;
1194811948 const child_ty = child_val.toType(&buffer);
1194911949
11950 const ptr_size = size_val.toEnum(std.builtin.TypeInfo.Pointer.Size);
11951
11952 var actual_sentinel: ?Value = null;
1195011953 if (!sentinel_val.isNull()) {
11951 return sema.fail(block, src, "TODO: implement zirReify for pointer with non-null sentinel", .{});
11954 if (ptr_size == .One or ptr_size == .C) {
11955 return sema.fail(block, src, "sentinels are only allowed on slices and unknown-length pointers", .{});
11956 }
11957 const sentinel_ptr_val = sentinel_val.castTag(.opt_payload).?.data;
11958 const ptr_ty = try Type.ptr(sema.arena, .{ .@"addrspace" = .generic, .pointee_type = child_ty });
11959 actual_sentinel = (try sema.pointerDeref(block, src, sentinel_ptr_val, ptr_ty)).?;
1195211960 }
1195311961
1195411962 const ty = try Type.ptr(sema.arena, .{
11955 .size = size_val.toEnum(std.builtin.TypeInfo.Pointer.Size),
11963 .size = ptr_size,
1195611964 .mutable = !is_const_val.toBool(),
1195711965 .@"volatile" = is_volatile_val.toBool(),
1195811966 .@"align" = @intCast(u8, alignment_val.toUnsignedInt()), // TODO: Validate this value.
1195911967 .@"addrspace" = address_space_val.toEnum(std.builtin.AddressSpace),
1196011968 .pointee_type = try child_ty.copy(sema.arena),
1196111969 .@"allowzero" = is_allowzero_val.toBool(),
11962 .sentinel = null,
11970 .sentinel = actual_sentinel,
1196311971 });
1196411972 return sema.addType(ty);
1196511973 },
......@@ -12069,6 +12077,7 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1206912077 const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1207012078 const type_res = try sema.resolveType(block, src, extra.lhs);
1207112079 try sema.checkPtrType(block, type_src, type_res);
12080 _ = try sema.resolveTypeLayout(block, src, type_res.childType());
1207212081 const ptr_align = type_res.ptrAlignment(sema.mod.getTarget());
1207312082
1207412083 if (try sema.resolveDefinedValue(block, operand_src, operand_coerced)) |val| {
......@@ -17586,7 +17595,7 @@ fn resolvePeerTypes(
1758617595 return chosen_ty;
1758717596}
1758817597
17589pub fn resolveTypeLayout(
17598fn resolveTypeLayout(
1759017599 sema: *Sema,
1759117600 block: *Block,
1759217601 src: LazySrcLoc,
......@@ -17659,7 +17668,7 @@ fn resolveUnionLayout(
1765917668 union_obj.status = .have_layout;
1766017669}
1766117670
17662fn resolveTypeFully(
17671pub fn resolveTypeFully(
1766317672 sema: *Sema,
1766417673 block: *Block,
1766517674 src: LazySrcLoc,