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();...@@ -3256,11 +3256,16 @@ const ThisModule = @This();
3256pub const Step = struct {3256pub const Step = struct {
3257 id: Id,3257 id: Id,
3258 name: []const u8,3258 name: []const u8,
3259 makeFn: fn (self: *Step) anyerror!void,3259 makeFn: MakeFn,
3260 dependencies: ArrayList(*Step),3260 dependencies: ArrayList(*Step),
3261 loop_flag: bool,3261 loop_flag: bool,
3262 done_flag: bool,3262 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
3264 pub const Id = enum {3269 pub const Id = enum {
3265 top_level,3270 top_level,
3266 lib_exe_obj,3271 lib_exe_obj,
...@@ -3279,7 +3284,7 @@ pub const Step = struct {...@@ -3279,7 +3284,7 @@ pub const Step = struct {
3279 custom,3284 custom,
3280 };3285 };
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 {
3283 return Step{3288 return Step{
3284 .id = id,3289 .id = id,
3285 .name = allocator.dupe(u8, name) catch unreachable,3290 .name = allocator.dupe(u8, name) catch unreachable,
lib/std/start.zig+4-5
...@@ -408,11 +408,6 @@ fn posixCallMainAndExit() noreturn {...@@ -408,11 +408,6 @@ fn posixCallMainAndExit() noreturn {
408 // Initialize the TLS area.408 // Initialize the TLS area.
409 std.os.linux.tls.initStaticTLS(phdrs);409 std.os.linux.tls.initStaticTLS(phdrs);
410410
411 if (builtin.zig_backend == .stage2_llvm) {
412 root.main();
413 exit2(0);
414 }
415
416 // The way Linux executables represent stack size is via the PT_GNU_STACK411 // The way Linux executables represent stack size is via the PT_GNU_STACK
417 // program header. However the kernel does not recognize it; it always gives 8 MiB.412 // program header. However the kernel does not recognize it; it always gives 8 MiB.
418 // Here we look for the stack size in our program headers and use setrlimit413 // 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 {...@@ -454,6 +449,10 @@ fn callMainWithArgs(argc: usize, argv: [*][*:0]u8, envp: [][*:0]u8) u8 {
454 std.os.argv = argv[0..argc];449 std.os.argv = argv[0..argc];
455 std.os.environ = envp;450 std.os.environ = envp;
456451
452 if (builtin.zig_backend == .stage2_llvm) {
453 return @call(.{ .modifier = .always_inline }, callMain, .{});
454 }
455
457 std.debug.maybeEnableSegfaultHandler();456 std.debug.maybeEnableSegfaultHandler();
458457
459 return initEventLoopAndCallMain();458 return initEventLoopAndCallMain();
src/Sema.zig+5-1
...@@ -12439,7 +12439,11 @@ fn zirErrorReturnTrace(...@@ -12439,7 +12439,11 @@ fn zirErrorReturnTrace(
12439 extended: Zir.Inst.Extended.InstData,12439 extended: Zir.Inst.Extended.InstData,
12440) CompileError!Air.Inst.Ref {12440) CompileError!Air.Inst.Ref {
12441 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };12441 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");
12443}12447}
1244412448
12445fn zirFrame(12449fn zirFrame(