diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index c94651a92d..ba5801e936 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -753,7 +753,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn @setCold(true); // Until self-hosted catches up with stage1 language features, we have a simpler // default panic function: - if (builtin.zig_is_stage2) { + if (builtin.zig_backend != .stage1) { while (true) { @breakpoint(); } diff --git a/lib/std/os.zig b/lib/std/os.zig index 7be8825fcc..03469cd47f 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -4973,7 +4973,7 @@ pub fn toPosixPath(file_path: []const u8) ![MAX_PATH_BYTES - 1:0]u8 { /// Until then, unexpected error tracing is disabled for the self-hosted compiler. /// TODO remove this once self-hosted is capable enough to handle printing and /// stack trace dumping. -pub const unexpected_error_tracing = !builtin.zig_is_stage2 and builtin.mode == .Debug; +pub const unexpected_error_tracing = builtin.zig_backend == .stage1 and builtin.mode == .Debug; pub const UnexpectedError = error{ /// The Operating System returned an undocumented error code. diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig index a7821643da..bc6d03bffd 100644 --- a/lib/std/special/c.zig +++ b/lib/std/special/c.zig @@ -12,7 +12,7 @@ comptime { // When the self-hosted compiler is further along, all the logic from c_stage1.zig will // be migrated to this file and then c_stage1.zig will be deleted. Until then we have a // simpler implementation of c.zig that only uses features already implemented in self-hosted. - if (builtin.zig_is_stage2) { + if (builtin.zig_backend != .stage1) { @export(memset, .{ .name = "memset", .linkage = .Strong }); @export(memcpy, .{ .name = "memcpy", .linkage = .Strong }); } else { @@ -25,7 +25,7 @@ comptime { pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { @setCold(true); _ = error_return_trace; - if (builtin.zig_is_stage2) { + if (builtin.zig_backend != .stage1) { while (true) { @breakpoint(); } diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index d9dc4b2884..0cd7ca2418 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -23,7 +23,7 @@ const long_double_is_f128 = builtin.target.longDoubleIsF128(); comptime { // These files do their own comptime exporting logic. - if (!builtin.zig_is_stage2) { + if (builtin.zig_backend == .stage1) { _ = @import("compiler_rt/atomics.zig"); } _ = @import("compiler_rt/clear_cache.zig").clear_cache; @@ -186,7 +186,7 @@ comptime { //@export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage }); } - if (!builtin.zig_is_stage2) { + if (builtin.zig_backend == .stage1) { switch (arch) { .i386, .x86_64, @@ -301,7 +301,7 @@ comptime { const __floatunsisf = @import("compiler_rt/floatunsisf.zig").__floatunsisf; @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage }); - if (!builtin.zig_is_stage2) { + if (builtin.zig_backend == .stage1) { const __floatundisf = @import("compiler_rt/floatundisf.zig").__floatundisf; @export(__floatundisf, .{ .name = "__floatundisf", .linkage = linkage }); } @@ -752,7 +752,7 @@ fn floorl(x: c_longdouble) callconv(.C) c_longdouble { pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { _ = error_return_trace; @setCold(true); - if (builtin.zig_is_stage2) { + if (builtin.zig_backend != .stage1) { while (true) { @breakpoint(); } diff --git a/lib/std/special/test_runner.zig b/lib/std/special/test_runner.zig index 76b309b795..22edaf7bed 100644 --- a/lib/std/special/test_runner.zig +++ b/lib/std/special/test_runner.zig @@ -23,7 +23,7 @@ fn processArgs() void { } pub fn main() void { - if (builtin.zig_is_stage2) { + if (builtin.zig_backend != .stage1) { return main2() catch @panic("test failure"); } processArgs(); diff --git a/lib/std/start.zig b/lib/std/start.zig index 1d3cad93d2..1d06e1eaf6 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -22,7 +22,7 @@ comptime { // The self-hosted compiler is not fully capable of handling all of this start.zig file. // Until then, we have simplified logic here for self-hosted. TODO remove this once // self-hosted is capable enough to handle all of the real start.zig logic. - if (builtin.zig_is_stage2) { + if (builtin.zig_backend != .stage1) { if (builtin.output_mode == .Exe) { if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) { if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { diff --git a/src/Compilation.zig b/src/Compilation.zig index 833e3b39ca..c21bf71326 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -4579,8 +4579,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks. \\pub const zig_version = std.SemanticVersion.parse("{s}") catch unreachable; \\pub const zig_backend = std.builtin.CompilerBackend.{}; - \\/// Temporary until self-hosted is feature complete. - \\pub const zig_is_stage2 = {}; \\/// Temporary until self-hosted supports the `cpu.arch` value. \\pub const stage2_arch: std.Target.Cpu.Arch = .{}; \\/// Temporary until self-hosted can call `std.Target.x86.featureSetHas` at comptime. @@ -4599,7 +4597,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca , .{ build_options.version, std.zig.fmtId(@tagName(zig_backend)), - !use_stage1, std.zig.fmtId(@tagName(target.cpu.arch)), stage2_x86_cx16, std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)), diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp index cfd455e815..f9f37c2eb4 100644 --- a/src/stage1/codegen.cpp +++ b/src/stage1/codegen.cpp @@ -9392,7 +9392,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { buf_appendf(contents, "pub const position_independent_executable = %s;\n", bool_to_str(g->have_pie)); buf_appendf(contents, "pub const strip_debug_info = %s;\n", bool_to_str(g->strip_debug_symbols)); buf_appendf(contents, "pub const code_model = std.builtin.CodeModel.default;\n"); - buf_appendf(contents, "pub const zig_is_stage2 = false;\n"); + buf_appendf(contents, "pub const zig_backend = std.builtin.CompilerBackend.stage1;\n"); { TargetSubsystem detected_subsystem = detect_subsystem(g); diff --git a/test/behavior/array.zig b/test/behavior/array.zig index 017d15a64b..d512e50687 100644 --- a/test/behavior/array.zig +++ b/test/behavior/array.zig @@ -111,7 +111,7 @@ test "array with sentinels" { const S = struct { fn doTheTest(is_ct: bool) !void { - if (is_ct or builtin.zig_is_stage2) { + if (is_ct or builtin.zig_backend != .stage1) { var zero_sized: [0:0xde]u8 = [_:0xde]u8{}; // Stage1 test coverage disabled at runtime because of // https://github.com/ziglang/zig/issues/4372 diff --git a/test/behavior/atomics.zig b/test/behavior/atomics.zig index 0643b62fe3..efb4e32960 100644 --- a/test/behavior/atomics.zig +++ b/test/behavior/atomics.zig @@ -88,7 +88,7 @@ test "128-bit cmpxchg" { } fn test_u128_cmpxchg() !void { - if (builtin.zig_is_stage2) { + if (builtin.zig_backend != .stage1) { if (builtin.cpu.arch != .x86_64) return error.SkipZigTest; if (!builtin.stage2_x86_cx16) return error.SkipZigTest; } else { diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index cca2d63cd7..9064339877 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -180,7 +180,7 @@ const OpaqueB = opaque {}; test "opaque types" { try expect(*OpaqueA != *OpaqueB); - if (!builtin.zig_is_stage2) { + if (builtin.zig_backend == .stage1) { // TODO make this pass for stage2 try expect(mem.eql(u8, @typeName(OpaqueA), "OpaqueA")); try expect(mem.eql(u8, @typeName(OpaqueB), "OpaqueB")); } diff --git a/test/behavior/bugs/2006.zig b/test/behavior/bugs/2006.zig index 4f41553b8e..bf9849abb2 100644 --- a/test/behavior/bugs/2006.zig +++ b/test/behavior/bugs/2006.zig @@ -8,7 +8,7 @@ test "bug 2006" { var a: S = undefined; a = S{ .p = undefined }; try expect(@sizeOf(S) != 0); - if (@import("builtin").zig_is_stage2) { + if (@import("builtin").zig_backend != .stage1) { // It is an accepted proposal to make `@sizeOf` for pointers independent // of whether the element type is zero bits. // This language change has not been implemented in stage1. diff --git a/test/behavior/bugs/6850.zig b/test/behavior/bugs/6850.zig index ad4292cc09..7bab4d347a 100644 --- a/test/behavior/bugs/6850.zig +++ b/test/behavior/bugs/6850.zig @@ -8,7 +8,7 @@ test "lazy sizeof comparison with zero" { } fn hasNoBits(comptime T: type) bool { - if (@import("builtin").zig_is_stage2) { + if (@import("builtin").zig_backend != .stage1) { // It is an accepted proposal to make `@sizeOf` for pointers independent // of whether the element type is zero bits. // This language change has not been implemented in stage1. diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index c2eb49f854..1e7a5a4687 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -246,7 +246,7 @@ test "array coersion to undefined at runtime" { @setRuntimeSafety(true); // TODO implement @setRuntimeSafety in stage2 - if (builtin.zig_is_stage2 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { + if (builtin.zig_backend != .stage1 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { return error.SkipZigTest; } diff --git a/test/behavior/generics.zig b/test/behavior/generics.zig index 6cb1a82e3e..f1107cef07 100644 --- a/test/behavior/generics.zig +++ b/test/behavior/generics.zig @@ -19,7 +19,7 @@ fn checkSize(comptime T: type) usize { test "simple generic fn" { try expect(max(i32, 3, -1) == 3); try expect(max(u8, 1, 100) == 100); - if (!builtin.zig_is_stage2) { + if (builtin.zig_backend == .stage1) { // TODO: stage2 is incorrectly emitting the following: // error: cast of value 1.23e-01 to type 'f32' loses information try expect(max(f32, 0.123, 0.456) == 0.456); diff --git a/test/behavior/int128.zig b/test/behavior/int128.zig index 6bf0eca11e..feb2617994 100644 --- a/test/behavior/int128.zig +++ b/test/behavior/int128.zig @@ -22,7 +22,7 @@ test "undefined 128 bit int" { @setRuntimeSafety(true); // TODO implement @setRuntimeSafety in stage2 - if (builtin.zig_is_stage2 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { + if (builtin.zig_backend != .stage1 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { return error.SkipZigTest; } diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index b5841c58fb..40310f8add 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -213,7 +213,7 @@ test "packed struct field alignment" { b: u32 align(1), } = undefined; }; - const S = if (builtin.zig_is_stage2) Stage2 else Stage1; + const S = if (builtin.zig_backend != .stage1) Stage2 else Stage1; try expect(@TypeOf(&S.baz.b) == *align(1) u32); }