diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index c94651a92d7763664eacd24648eb4c0222829f74..ba5801e93649ba3e854cfb9550c6cd5cbdd1335b 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 7be8825fcc3ccd31e4f1a9981f1d97db904e49f6..03469cd47f65d6ae183547458850e475c19c48e2 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 a7821643da8890bc5d68ec29dcba3a78b4a7f681..bc6d03bffdcc26f54d0ea8e70581e488309505fd 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 d9dc4b288495d338b46439274a61ebfef12cb0a2..0cd7ca2418b9549b35274c8b42a1aa591295c5bd 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 76b309b7957e86b53f603be21c85cd04579da242..22edaf7bedb9d5fee4ae745ced17b0f28aa8f9cf 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 1d3cad93d28431f1b07c94c6173314066b87c382..1d06e1eaf608e1fb3d322275f5e9811d103ba25c 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 833e3b39ca064d42b44125425dc7d92c33f0cece..c21bf7132691413797548c814a65d8d7072ffc0d 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 cfd455e81505cba321ecc7b0a608cf971ec3b9ed..f9f37c2eb4cd7c8abf49efbef958a239c6f24a67 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 017d15a64ba00a605e83833a5d465cae3846d289..d512e506877797eb49d2c29fd838756d2e695845 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 0643b62fe3d3ee41bb94bfa835f539060a6524bf..efb4e32960f9fa70688bdb6ee280c2d824b84e35 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 cca2d63cd7cc4f6c4638206812cbe5a06de3a38e..90643398778e7c50b3324f4489ae074ff417d2a0 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 4f41553b8e6dab5208cd1089f68c5c930bb5a157..bf9849abb286d310b77fe3a7d773ac44ff47ddf3 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 ad4292cc092770c0d837b3f62612b433ec484217..7bab4d347af13377302f5152c13e72aa88743fde 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 c2eb49f85473efc4c5dd8a7002b54b9c311c7466..1e7a5a468762abfaf184d005549e854eedf19867 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 6cb1a82e3ecce99181eb5a5fac0ba74b838da559..f1107cef07d611eebb6a011ec27121994ae8c823 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 6bf0eca11ea4cdbae6aba4f92f80a463d3c9b20b..feb261799421d67799c133e7cb7e45d864ba9d30 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 b5841c58fb395e534678cff8cb440a5b42c29b23..40310f8add41a0816775627ab27c517be00c0555 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); }