| author | |
| committer | |
| log | 4d05f2ae5f7b79f8abb4aa07d846a46470ffdb1a |
| tree | 930c4dc2aa77d420fd66917136cb1c0e2514f2e6 |
| parent | 84c2c47fae82e913286a2306d8947252ae3a42f7 |
Instead use the standarized option for communicating the
zig compiler backend at comptime, which is `zig_backend`. This was
introduced in commit 1c24ef0d0b09a12a1fe98056f2fc04de78a82df3.17 files changed, 20 insertions(+), 23 deletions(-)
lib/std/builtin.zig+1-1| ... | @@ -753,7 +753,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn | ... | @@ -753,7 +753,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn |
| 753 | @setCold(true); | 753 | @setCold(true); |
| 754 | // Until self-hosted catches up with stage1 language features, we have a simpler | 754 | // Until self-hosted catches up with stage1 language features, we have a simpler |
| 755 | // default panic function: | 755 | // default panic function: |
| 756 | if (builtin.zig_is_stage2) { | 756 | if (builtin.zig_backend != .stage1) { |
| 757 | while (true) { | 757 | while (true) { |
| 758 | @breakpoint(); | 758 | @breakpoint(); |
| 759 | } | 759 | } |
lib/std/os.zig+1-1| ... | @@ -4973,7 +4973,7 @@ pub fn toPosixPath(file_path: []const u8) ![MAX_PATH_BYTES - 1:0]u8 { | ... | @@ -4973,7 +4973,7 @@ pub fn toPosixPath(file_path: []const u8) ![MAX_PATH_BYTES - 1:0]u8 { |
| 4973 | /// Until then, unexpected error tracing is disabled for the self-hosted compiler. | 4973 | /// Until then, unexpected error tracing is disabled for the self-hosted compiler. |
| 4974 | /// TODO remove this once self-hosted is capable enough to handle printing and | 4974 | /// TODO remove this once self-hosted is capable enough to handle printing and |
| 4975 | /// stack trace dumping. | 4975 | /// stack trace dumping. |
| 4976 | pub const unexpected_error_tracing = !builtin.zig_is_stage2 and builtin.mode == .Debug; | 4976 | pub const unexpected_error_tracing = builtin.zig_backend == .stage1 and builtin.mode == .Debug; |
| 4977 | 4977 | ||
| 4978 | pub const UnexpectedError = error{ | 4978 | pub const UnexpectedError = error{ |
| 4979 | /// The Operating System returned an undocumented error code. | 4979 | /// The Operating System returned an undocumented error code. |
lib/std/special/c.zig+2-2| ... | @@ -12,7 +12,7 @@ comptime { | ... | @@ -12,7 +12,7 @@ comptime { |
| 12 | // When the self-hosted compiler is further along, all the logic from c_stage1.zig will | 12 | // When the self-hosted compiler is further along, all the logic from c_stage1.zig will |
| 13 | // be migrated to this file and then c_stage1.zig will be deleted. Until then we have a | 13 | // be migrated to this file and then c_stage1.zig will be deleted. Until then we have a |
| 14 | // simpler implementation of c.zig that only uses features already implemented in self-hosted. | 14 | // simpler implementation of c.zig that only uses features already implemented in self-hosted. |
| 15 | if (builtin.zig_is_stage2) { | 15 | if (builtin.zig_backend != .stage1) { |
| 16 | @export(memset, .{ .name = "memset", .linkage = .Strong }); | 16 | @export(memset, .{ .name = "memset", .linkage = .Strong }); |
| 17 | @export(memcpy, .{ .name = "memcpy", .linkage = .Strong }); | 17 | @export(memcpy, .{ .name = "memcpy", .linkage = .Strong }); |
| 18 | } else { | 18 | } else { |
| ... | @@ -25,7 +25,7 @@ comptime { | ... | @@ -25,7 +25,7 @@ comptime { |
| 25 | pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { | 25 | pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { |
| 26 | @setCold(true); | 26 | @setCold(true); |
| 27 | _ = error_return_trace; | 27 | _ = error_return_trace; |
| 28 | if (builtin.zig_is_stage2) { | 28 | if (builtin.zig_backend != .stage1) { |
| 29 | while (true) { | 29 | while (true) { |
| 30 | @breakpoint(); | 30 | @breakpoint(); |
| 31 | } | 31 | } |
lib/std/special/compiler_rt.zig+4-4| ... | @@ -23,7 +23,7 @@ const long_double_is_f128 = builtin.target.longDoubleIsF128(); | ... | @@ -23,7 +23,7 @@ const long_double_is_f128 = builtin.target.longDoubleIsF128(); |
| 23 | 23 | ||
| 24 | comptime { | 24 | comptime { |
| 25 | // These files do their own comptime exporting logic. | 25 | // These files do their own comptime exporting logic. |
| 26 | if (!builtin.zig_is_stage2) { | 26 | if (builtin.zig_backend == .stage1) { |
| 27 | _ = @import("compiler_rt/atomics.zig"); | 27 | _ = @import("compiler_rt/atomics.zig"); |
| 28 | } | 28 | } |
| 29 | _ = @import("compiler_rt/clear_cache.zig").clear_cache; | 29 | _ = @import("compiler_rt/clear_cache.zig").clear_cache; |
| ... | @@ -186,7 +186,7 @@ comptime { | ... | @@ -186,7 +186,7 @@ comptime { |
| 186 | //@export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage }); | 186 | //@export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage }); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | if (!builtin.zig_is_stage2) { | 189 | if (builtin.zig_backend == .stage1) { |
| 190 | switch (arch) { | 190 | switch (arch) { |
| 191 | .i386, | 191 | .i386, |
| 192 | .x86_64, | 192 | .x86_64, |
| ... | @@ -301,7 +301,7 @@ comptime { | ... | @@ -301,7 +301,7 @@ comptime { |
| 301 | 301 | ||
| 302 | const __floatunsisf = @import("compiler_rt/floatunsisf.zig").__floatunsisf; | 302 | const __floatunsisf = @import("compiler_rt/floatunsisf.zig").__floatunsisf; |
| 303 | @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage }); | 303 | @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage }); |
| 304 | if (!builtin.zig_is_stage2) { | 304 | if (builtin.zig_backend == .stage1) { |
| 305 | const __floatundisf = @import("compiler_rt/floatundisf.zig").__floatundisf; | 305 | const __floatundisf = @import("compiler_rt/floatundisf.zig").__floatundisf; |
| 306 | @export(__floatundisf, .{ .name = "__floatundisf", .linkage = linkage }); | 306 | @export(__floatundisf, .{ .name = "__floatundisf", .linkage = linkage }); |
| 307 | } | 307 | } |
| ... | @@ -752,7 +752,7 @@ fn floorl(x: c_longdouble) callconv(.C) c_longdouble { | ... | @@ -752,7 +752,7 @@ fn floorl(x: c_longdouble) callconv(.C) c_longdouble { |
| 752 | pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { | 752 | pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { |
| 753 | _ = error_return_trace; | 753 | _ = error_return_trace; |
| 754 | @setCold(true); | 754 | @setCold(true); |
| 755 | if (builtin.zig_is_stage2) { | 755 | if (builtin.zig_backend != .stage1) { |
| 756 | while (true) { | 756 | while (true) { |
| 757 | @breakpoint(); | 757 | @breakpoint(); |
| 758 | } | 758 | } |
lib/std/special/test_runner.zig+1-1| ... | @@ -23,7 +23,7 @@ fn processArgs() void { | ... | @@ -23,7 +23,7 @@ fn processArgs() void { |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | pub fn main() void { | 25 | pub fn main() void { |
| 26 | if (builtin.zig_is_stage2) { | 26 | if (builtin.zig_backend != .stage1) { |
| 27 | return main2() catch @panic("test failure"); | 27 | return main2() catch @panic("test failure"); |
| 28 | } | 28 | } |
| 29 | processArgs(); | 29 | processArgs(); |
lib/std/start.zig+1-1| ... | @@ -22,7 +22,7 @@ comptime { | ... | @@ -22,7 +22,7 @@ comptime { |
| 22 | // The self-hosted compiler is not fully capable of handling all of this start.zig file. | 22 | // The self-hosted compiler is not fully capable of handling all of this start.zig file. |
| 23 | // Until then, we have simplified logic here for self-hosted. TODO remove this once | 23 | // Until then, we have simplified logic here for self-hosted. TODO remove this once |
| 24 | // self-hosted is capable enough to handle all of the real start.zig logic. | 24 | // self-hosted is capable enough to handle all of the real start.zig logic. |
| 25 | if (builtin.zig_is_stage2) { | 25 | if (builtin.zig_backend != .stage1) { |
| 26 | if (builtin.output_mode == .Exe) { | 26 | if (builtin.output_mode == .Exe) { |
| 27 | if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) { | 27 | if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) { |
| 28 | if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { | 28 | if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { |
src/Compilation.zig-3| ... | @@ -4579,8 +4579,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca | ... | @@ -4579,8 +4579,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca |
| 4579 | \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks. | 4579 | \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks. |
| 4580 | \\pub const zig_version = std.SemanticVersion.parse("{s}") catch unreachable; | 4580 | \\pub const zig_version = std.SemanticVersion.parse("{s}") catch unreachable; |
| 4581 | \\pub const zig_backend = std.builtin.CompilerBackend.{}; | 4581 | \\pub const zig_backend = std.builtin.CompilerBackend.{}; |
| 4582 | \\/// Temporary until self-hosted is feature complete. | ||
| 4583 | \\pub const zig_is_stage2 = {}; | ||
| 4584 | \\/// Temporary until self-hosted supports the `cpu.arch` value. | 4582 | \\/// Temporary until self-hosted supports the `cpu.arch` value. |
| 4585 | \\pub const stage2_arch: std.Target.Cpu.Arch = .{}; | 4583 | \\pub const stage2_arch: std.Target.Cpu.Arch = .{}; |
| 4586 | \\/// Temporary until self-hosted can call `std.Target.x86.featureSetHas` at comptime. | 4584 | \\/// Temporary until self-hosted can call `std.Target.x86.featureSetHas` at comptime. |
| ... | @@ -4599,7 +4597,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca | ... | @@ -4599,7 +4597,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca |
| 4599 | , .{ | 4597 | , .{ |
| 4600 | build_options.version, | 4598 | build_options.version, |
| 4601 | std.zig.fmtId(@tagName(zig_backend)), | 4599 | std.zig.fmtId(@tagName(zig_backend)), |
| 4602 | !use_stage1, | ||
| 4603 | std.zig.fmtId(@tagName(target.cpu.arch)), | 4600 | std.zig.fmtId(@tagName(target.cpu.arch)), |
| 4604 | stage2_x86_cx16, | 4601 | stage2_x86_cx16, |
| 4605 | std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)), | 4602 | std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)), |
src/stage1/codegen.cpp+1-1| ... | @@ -9392,7 +9392,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { | ... | @@ -9392,7 +9392,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { |
| 9392 | buf_appendf(contents, "pub const position_independent_executable = %s;\n", bool_to_str(g->have_pie)); | 9392 | buf_appendf(contents, "pub const position_independent_executable = %s;\n", bool_to_str(g->have_pie)); |
| 9393 | buf_appendf(contents, "pub const strip_debug_info = %s;\n", bool_to_str(g->strip_debug_symbols)); | 9393 | buf_appendf(contents, "pub const strip_debug_info = %s;\n", bool_to_str(g->strip_debug_symbols)); |
| 9394 | buf_appendf(contents, "pub const code_model = std.builtin.CodeModel.default;\n"); | 9394 | buf_appendf(contents, "pub const code_model = std.builtin.CodeModel.default;\n"); |
| 9395 | buf_appendf(contents, "pub const zig_is_stage2 = false;\n"); | 9395 | buf_appendf(contents, "pub const zig_backend = std.builtin.CompilerBackend.stage1;\n"); |
| 9396 | 9396 | ||
| 9397 | { | 9397 | { |
| 9398 | TargetSubsystem detected_subsystem = detect_subsystem(g); | 9398 | TargetSubsystem detected_subsystem = detect_subsystem(g); |
test/behavior/array.zig+1-1| ... | @@ -111,7 +111,7 @@ test "array with sentinels" { | ... | @@ -111,7 +111,7 @@ test "array with sentinels" { |
| 111 | 111 | ||
| 112 | const S = struct { | 112 | const S = struct { |
| 113 | fn doTheTest(is_ct: bool) !void { | 113 | fn doTheTest(is_ct: bool) !void { |
| 114 | if (is_ct or builtin.zig_is_stage2) { | 114 | if (is_ct or builtin.zig_backend != .stage1) { |
| 115 | var zero_sized: [0:0xde]u8 = [_:0xde]u8{}; | 115 | var zero_sized: [0:0xde]u8 = [_:0xde]u8{}; |
| 116 | // Stage1 test coverage disabled at runtime because of | 116 | // Stage1 test coverage disabled at runtime because of |
| 117 | // https://github.com/ziglang/zig/issues/4372 | 117 | // https://github.com/ziglang/zig/issues/4372 |
test/behavior/atomics.zig+1-1| ... | @@ -88,7 +88,7 @@ test "128-bit cmpxchg" { | ... | @@ -88,7 +88,7 @@ test "128-bit cmpxchg" { |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | fn test_u128_cmpxchg() !void { | 90 | fn test_u128_cmpxchg() !void { |
| 91 | if (builtin.zig_is_stage2) { | 91 | if (builtin.zig_backend != .stage1) { |
| 92 | if (builtin.cpu.arch != .x86_64) return error.SkipZigTest; | 92 | if (builtin.cpu.arch != .x86_64) return error.SkipZigTest; |
| 93 | if (!builtin.stage2_x86_cx16) return error.SkipZigTest; | 93 | if (!builtin.stage2_x86_cx16) return error.SkipZigTest; |
| 94 | } else { | 94 | } else { |
test/behavior/basic.zig+1-1| ... | @@ -180,7 +180,7 @@ const OpaqueB = opaque {}; | ... | @@ -180,7 +180,7 @@ const OpaqueB = opaque {}; |
| 180 | 180 | ||
| 181 | test "opaque types" { | 181 | test "opaque types" { |
| 182 | try expect(*OpaqueA != *OpaqueB); | 182 | try expect(*OpaqueA != *OpaqueB); |
| 183 | if (!builtin.zig_is_stage2) { | 183 | if (builtin.zig_backend == .stage1) { // TODO make this pass for stage2 |
| 184 | try expect(mem.eql(u8, @typeName(OpaqueA), "OpaqueA")); | 184 | try expect(mem.eql(u8, @typeName(OpaqueA), "OpaqueA")); |
| 185 | try expect(mem.eql(u8, @typeName(OpaqueB), "OpaqueB")); | 185 | try expect(mem.eql(u8, @typeName(OpaqueB), "OpaqueB")); |
| 186 | } | 186 | } |
test/behavior/bugs/2006.zig+1-1| ... | @@ -8,7 +8,7 @@ test "bug 2006" { | ... | @@ -8,7 +8,7 @@ test "bug 2006" { |
| 8 | var a: S = undefined; | 8 | var a: S = undefined; |
| 9 | a = S{ .p = undefined }; | 9 | a = S{ .p = undefined }; |
| 10 | try expect(@sizeOf(S) != 0); | 10 | try expect(@sizeOf(S) != 0); |
| 11 | if (@import("builtin").zig_is_stage2) { | 11 | if (@import("builtin").zig_backend != .stage1) { |
| 12 | // It is an accepted proposal to make `@sizeOf` for pointers independent | 12 | // It is an accepted proposal to make `@sizeOf` for pointers independent |
| 13 | // of whether the element type is zero bits. | 13 | // of whether the element type is zero bits. |
| 14 | // This language change has not been implemented in stage1. | 14 | // This language change has not been implemented in stage1. |
test/behavior/bugs/6850.zig+1-1| ... | @@ -8,7 +8,7 @@ test "lazy sizeof comparison with zero" { | ... | @@ -8,7 +8,7 @@ test "lazy sizeof comparison with zero" { |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | fn hasNoBits(comptime T: type) bool { | 10 | fn hasNoBits(comptime T: type) bool { |
| 11 | if (@import("builtin").zig_is_stage2) { | 11 | if (@import("builtin").zig_backend != .stage1) { |
| 12 | // It is an accepted proposal to make `@sizeOf` for pointers independent | 12 | // It is an accepted proposal to make `@sizeOf` for pointers independent |
| 13 | // of whether the element type is zero bits. | 13 | // of whether the element type is zero bits. |
| 14 | // This language change has not been implemented in stage1. | 14 | // This language change has not been implemented in stage1. |
test/behavior/cast.zig+1-1| ... | @@ -246,7 +246,7 @@ test "array coersion to undefined at runtime" { | ... | @@ -246,7 +246,7 @@ test "array coersion to undefined at runtime" { |
| 246 | @setRuntimeSafety(true); | 246 | @setRuntimeSafety(true); |
| 247 | 247 | ||
| 248 | // TODO implement @setRuntimeSafety in stage2 | 248 | // TODO implement @setRuntimeSafety in stage2 |
| 249 | if (builtin.zig_is_stage2 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { | 249 | if (builtin.zig_backend != .stage1 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { |
| 250 | return error.SkipZigTest; | 250 | return error.SkipZigTest; |
| 251 | } | 251 | } |
| 252 | 252 |
test/behavior/generics.zig+1-1| ... | @@ -19,7 +19,7 @@ fn checkSize(comptime T: type) usize { | ... | @@ -19,7 +19,7 @@ fn checkSize(comptime T: type) usize { |
| 19 | test "simple generic fn" { | 19 | test "simple generic fn" { |
| 20 | try expect(max(i32, 3, -1) == 3); | 20 | try expect(max(i32, 3, -1) == 3); |
| 21 | try expect(max(u8, 1, 100) == 100); | 21 | try expect(max(u8, 1, 100) == 100); |
| 22 | if (!builtin.zig_is_stage2) { | 22 | if (builtin.zig_backend == .stage1) { |
| 23 | // TODO: stage2 is incorrectly emitting the following: | 23 | // TODO: stage2 is incorrectly emitting the following: |
| 24 | // error: cast of value 1.23e-01 to type 'f32' loses information | 24 | // error: cast of value 1.23e-01 to type 'f32' loses information |
| 25 | try expect(max(f32, 0.123, 0.456) == 0.456); | 25 | try expect(max(f32, 0.123, 0.456) == 0.456); |
test/behavior/int128.zig+1-1| ... | @@ -22,7 +22,7 @@ test "undefined 128 bit int" { | ... | @@ -22,7 +22,7 @@ test "undefined 128 bit int" { |
| 22 | @setRuntimeSafety(true); | 22 | @setRuntimeSafety(true); |
| 23 | 23 | ||
| 24 | // TODO implement @setRuntimeSafety in stage2 | 24 | // TODO implement @setRuntimeSafety in stage2 |
| 25 | if (builtin.zig_is_stage2 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { | 25 | if (builtin.zig_backend != .stage1 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { |
| 26 | return error.SkipZigTest; | 26 | return error.SkipZigTest; |
| 27 | } | 27 | } |
| 28 | 28 |
test/behavior/struct.zig+1-1| ... | @@ -213,7 +213,7 @@ test "packed struct field alignment" { | ... | @@ -213,7 +213,7 @@ test "packed struct field alignment" { |
| 213 | b: u32 align(1), | 213 | b: u32 align(1), |
| 214 | } = undefined; | 214 | } = undefined; |
| 215 | }; | 215 | }; |
| 216 | const S = if (builtin.zig_is_stage2) Stage2 else Stage1; | 216 | const S = if (builtin.zig_backend != .stage1) Stage2 else Stage1; |
| 217 | try expect(@TypeOf(&S.baz.b) == *align(1) u32); | 217 | try expect(@TypeOf(&S.baz.b) == *align(1) u32); |
| 218 | } | 218 | } |
| 219 | 219 |