authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-21 19:07:20-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-21 19:08:30-07:00
log0fb005d1d05acb680389ce8be51bab6020309922
treebb6bd3fe4ec2cabc09768f3c44205cbcdd8c9725
parentbe579d479753153e78e55b17cb8fd2d55004145b

Sema: dummy implementation of `@errorReturnTrace`

Also update std/build.zig to use stage2 function pointer semantics. This gets us a little bit closer to `zig build` working, although it is now hitting a new crash in the compiler.

3 files changed, 16 insertions(+), 8 deletions(-)

lib/std/build.zig+7-2
......@@ -3256,11 +3256,16 @@ const ThisModule = @This();
32563256pub const Step = struct {
32573257 id: Id,
32583258 name: []const u8,
3259 makeFn: fn (self: *Step) anyerror!void,
3259 makeFn: MakeFn,
32603260 dependencies: ArrayList(*Step),
32613261 loop_flag: bool,
32623262 done_flag: bool,
32633263
3264 const MakeFn = switch (builtin.zig_backend) {
3265 .stage1 => fn (self: *Step) anyerror!void,
3266 else => *const fn (self: *Step) anyerror!void,
3267 };
3268
32643269 pub const Id = enum {
32653270 top_level,
32663271 lib_exe_obj,
......@@ -3279,7 +3284,7 @@ pub const Step = struct {
32793284 custom,
32803285 };
32813286
3282 pub fn init(id: Id, name: []const u8, allocator: Allocator, makeFn: fn (*Step) anyerror!void) Step {
3287 pub fn init(id: Id, name: []const u8, allocator: Allocator, makeFn: MakeFn) Step {
32833288 return Step{
32843289 .id = id,
32853290 .name = allocator.dupe(u8, name) catch unreachable,
lib/std/start.zig+4-5
......@@ -408,11 +408,6 @@ fn posixCallMainAndExit() noreturn {
408408 // Initialize the TLS area.
409409 std.os.linux.tls.initStaticTLS(phdrs);
410410
411 if (builtin.zig_backend == .stage2_llvm) {
412 root.main();
413 exit2(0);
414 }
415
416411 // The way Linux executables represent stack size is via the PT_GNU_STACK
417412 // program header. However the kernel does not recognize it; it always gives 8 MiB.
418413 // Here we look for the stack size in our program headers and use setrlimit
......@@ -454,6 +449,10 @@ fn callMainWithArgs(argc: usize, argv: [*][*:0]u8, envp: [][*:0]u8) u8 {
454449 std.os.argv = argv[0..argc];
455450 std.os.environ = envp;
456451
452 if (builtin.zig_backend == .stage2_llvm) {
453 return @call(.{ .modifier = .always_inline }, callMain, .{});
454 }
455
457456 std.debug.maybeEnableSegfaultHandler();
458457
459458 return initEventLoopAndCallMain();
src/Sema.zig+5-1
......@@ -12439,7 +12439,11 @@ fn zirErrorReturnTrace(
1243912439 extended: Zir.Inst.Extended.InstData,
1244012440) CompileError!Air.Inst.Ref {
1244112441 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
12442 return sema.fail(block, src, "TODO: Sema.zirErrorReturnTrace", .{});
12442 const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace");
12443 const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty);
12444 const opt_stack_trace_ty = try Type.optional(sema.arena, stack_trace_ty);
12445 // https://github.com/ziglang/zig/issues/11259
12446 return sema.addConstant(opt_stack_trace_ty, Value.@"null");
1244312447}
1244412448
1244512449fn zirFrame(