mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
remove zig_is_stage2 from @import("builtin")
Instead use the standarized option for communicating the
zig compiler backend at comptime, which is `zig_backend`. This was
introduced in commit 1c24ef0d0b.
This commit is contained in:
parent
84c2c47fae
commit
4d05f2ae5f
17 changed files with 20 additions and 23 deletions
|
|
@ -753,7 +753,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn
|
||||||
@setCold(true);
|
@setCold(true);
|
||||||
// Until self-hosted catches up with stage1 language features, we have a simpler
|
// Until self-hosted catches up with stage1 language features, we have a simpler
|
||||||
// default panic function:
|
// default panic function:
|
||||||
if (builtin.zig_is_stage2) {
|
if (builtin.zig_backend != .stage1) {
|
||||||
while (true) {
|
while (true) {
|
||||||
@breakpoint();
|
@breakpoint();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.
|
/// 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
|
/// TODO remove this once self-hosted is capable enough to handle printing and
|
||||||
/// stack trace dumping.
|
/// 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{
|
pub const UnexpectedError = error{
|
||||||
/// The Operating System returned an undocumented error code.
|
/// The Operating System returned an undocumented error code.
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ comptime {
|
||||||
// When the self-hosted compiler is further along, all the logic from c_stage1.zig will
|
// 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
|
// 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.
|
// 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(memset, .{ .name = "memset", .linkage = .Strong });
|
||||||
@export(memcpy, .{ .name = "memcpy", .linkage = .Strong });
|
@export(memcpy, .{ .name = "memcpy", .linkage = .Strong });
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -25,7 +25,7 @@ comptime {
|
||||||
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
|
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
|
||||||
@setCold(true);
|
@setCold(true);
|
||||||
_ = error_return_trace;
|
_ = error_return_trace;
|
||||||
if (builtin.zig_is_stage2) {
|
if (builtin.zig_backend != .stage1) {
|
||||||
while (true) {
|
while (true) {
|
||||||
@breakpoint();
|
@breakpoint();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const long_double_is_f128 = builtin.target.longDoubleIsF128();
|
||||||
|
|
||||||
comptime {
|
comptime {
|
||||||
// These files do their own comptime exporting logic.
|
// 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/atomics.zig");
|
||||||
}
|
}
|
||||||
_ = @import("compiler_rt/clear_cache.zig").clear_cache;
|
_ = @import("compiler_rt/clear_cache.zig").clear_cache;
|
||||||
|
|
@ -186,7 +186,7 @@ comptime {
|
||||||
//@export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage });
|
//@export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!builtin.zig_is_stage2) {
|
if (builtin.zig_backend == .stage1) {
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
.i386,
|
.i386,
|
||||||
.x86_64,
|
.x86_64,
|
||||||
|
|
@ -301,7 +301,7 @@ comptime {
|
||||||
|
|
||||||
const __floatunsisf = @import("compiler_rt/floatunsisf.zig").__floatunsisf;
|
const __floatunsisf = @import("compiler_rt/floatunsisf.zig").__floatunsisf;
|
||||||
@export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage });
|
@export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage });
|
||||||
if (!builtin.zig_is_stage2) {
|
if (builtin.zig_backend == .stage1) {
|
||||||
const __floatundisf = @import("compiler_rt/floatundisf.zig").__floatundisf;
|
const __floatundisf = @import("compiler_rt/floatundisf.zig").__floatundisf;
|
||||||
@export(__floatundisf, .{ .name = "__floatundisf", .linkage = linkage });
|
@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 {
|
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
|
||||||
_ = error_return_trace;
|
_ = error_return_trace;
|
||||||
@setCold(true);
|
@setCold(true);
|
||||||
if (builtin.zig_is_stage2) {
|
if (builtin.zig_backend != .stage1) {
|
||||||
while (true) {
|
while (true) {
|
||||||
@breakpoint();
|
@breakpoint();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ fn processArgs() void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
if (builtin.zig_is_stage2) {
|
if (builtin.zig_backend != .stage1) {
|
||||||
return main2() catch @panic("test failure");
|
return main2() catch @panic("test failure");
|
||||||
}
|
}
|
||||||
processArgs();
|
processArgs();
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ comptime {
|
||||||
// The self-hosted compiler is not fully capable of handling all of this start.zig file.
|
// 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
|
// 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.
|
// 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.output_mode == .Exe) {
|
||||||
if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {
|
if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {
|
||||||
if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
|
if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
|
||||||
|
|
|
||||||
|
|
@ -4579,8 +4579,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
|
||||||
\\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
|
\\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
|
||||||
\\pub const zig_version = std.SemanticVersion.parse("{s}") catch unreachable;
|
\\pub const zig_version = std.SemanticVersion.parse("{s}") catch unreachable;
|
||||||
\\pub const zig_backend = std.builtin.CompilerBackend.{};
|
\\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.
|
\\/// Temporary until self-hosted supports the `cpu.arch` value.
|
||||||
\\pub const stage2_arch: std.Target.Cpu.Arch = .{};
|
\\pub const stage2_arch: std.Target.Cpu.Arch = .{};
|
||||||
\\/// Temporary until self-hosted can call `std.Target.x86.featureSetHas` at comptime.
|
\\/// 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,
|
build_options.version,
|
||||||
std.zig.fmtId(@tagName(zig_backend)),
|
std.zig.fmtId(@tagName(zig_backend)),
|
||||||
!use_stage1,
|
|
||||||
std.zig.fmtId(@tagName(target.cpu.arch)),
|
std.zig.fmtId(@tagName(target.cpu.arch)),
|
||||||
stage2_x86_cx16,
|
stage2_x86_cx16,
|
||||||
std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)),
|
std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)),
|
||||||
|
|
|
||||||
|
|
@ -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 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 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 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);
|
TargetSubsystem detected_subsystem = detect_subsystem(g);
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ test "array with sentinels" {
|
||||||
|
|
||||||
const S = struct {
|
const S = struct {
|
||||||
fn doTheTest(is_ct: bool) !void {
|
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{};
|
var zero_sized: [0:0xde]u8 = [_:0xde]u8{};
|
||||||
// Stage1 test coverage disabled at runtime because of
|
// Stage1 test coverage disabled at runtime because of
|
||||||
// https://github.com/ziglang/zig/issues/4372
|
// https://github.com/ziglang/zig/issues/4372
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ test "128-bit cmpxchg" {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_u128_cmpxchg() !void {
|
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.cpu.arch != .x86_64) return error.SkipZigTest;
|
||||||
if (!builtin.stage2_x86_cx16) return error.SkipZigTest;
|
if (!builtin.stage2_x86_cx16) return error.SkipZigTest;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ const OpaqueB = opaque {};
|
||||||
|
|
||||||
test "opaque types" {
|
test "opaque types" {
|
||||||
try expect(*OpaqueA != *OpaqueB);
|
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(OpaqueA), "OpaqueA"));
|
||||||
try expect(mem.eql(u8, @typeName(OpaqueB), "OpaqueB"));
|
try expect(mem.eql(u8, @typeName(OpaqueB), "OpaqueB"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ test "bug 2006" {
|
||||||
var a: S = undefined;
|
var a: S = undefined;
|
||||||
a = S{ .p = undefined };
|
a = S{ .p = undefined };
|
||||||
try expect(@sizeOf(S) != 0);
|
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
|
// It is an accepted proposal to make `@sizeOf` for pointers independent
|
||||||
// of whether the element type is zero bits.
|
// of whether the element type is zero bits.
|
||||||
// This language change has not been implemented in stage1.
|
// This language change has not been implemented in stage1.
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ test "lazy sizeof comparison with zero" {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hasNoBits(comptime T: type) bool {
|
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
|
// It is an accepted proposal to make `@sizeOf` for pointers independent
|
||||||
// of whether the element type is zero bits.
|
// of whether the element type is zero bits.
|
||||||
// This language change has not been implemented in stage1.
|
// This language change has not been implemented in stage1.
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ test "array coersion to undefined at runtime" {
|
||||||
@setRuntimeSafety(true);
|
@setRuntimeSafety(true);
|
||||||
|
|
||||||
// TODO implement @setRuntimeSafety in stage2
|
// 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;
|
return error.SkipZigTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ fn checkSize(comptime T: type) usize {
|
||||||
test "simple generic fn" {
|
test "simple generic fn" {
|
||||||
try expect(max(i32, 3, -1) == 3);
|
try expect(max(i32, 3, -1) == 3);
|
||||||
try expect(max(u8, 1, 100) == 100);
|
try expect(max(u8, 1, 100) == 100);
|
||||||
if (!builtin.zig_is_stage2) {
|
if (builtin.zig_backend == .stage1) {
|
||||||
// TODO: stage2 is incorrectly emitting the following:
|
// TODO: stage2 is incorrectly emitting the following:
|
||||||
// error: cast of value 1.23e-01 to type 'f32' loses information
|
// error: cast of value 1.23e-01 to type 'f32' loses information
|
||||||
try expect(max(f32, 0.123, 0.456) == 0.456);
|
try expect(max(f32, 0.123, 0.456) == 0.456);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ test "undefined 128 bit int" {
|
||||||
@setRuntimeSafety(true);
|
@setRuntimeSafety(true);
|
||||||
|
|
||||||
// TODO implement @setRuntimeSafety in stage2
|
// 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;
|
return error.SkipZigTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ test "packed struct field alignment" {
|
||||||
b: u32 align(1),
|
b: u32 align(1),
|
||||||
} = undefined;
|
} = 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);
|
try expect(@TypeOf(&S.baz.b) == *align(1) u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue