authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-13 11:51:58-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-15 19:06:39-07:00
log798ad631f3f9836de663bc6c728b415e0a13528f
tree345fe3987200eedf7e00c905dc9e5e98f29ebaa9
parent6dba9bc6fc6741e51af86f71e3057cffed7406a6

stage2 start.zig: slight simplification

fewer required language features to allow this to work

2 files changed, 7 insertions(+), 3 deletions(-)

lib/std/start.zig+3-3
...@@ -11,8 +11,8 @@ const builtin = @import("builtin");...@@ -11,8 +11,8 @@ const builtin = @import("builtin");
11const assert = std.debug.assert;11const assert = std.debug.assert;
12const uefi = std.os.uefi;12const uefi = std.os.uefi;
13const tlcsprng = @import("crypto/tlcsprng.zig");13const tlcsprng = @import("crypto/tlcsprng.zig");
14const native_arch = std.Target.current.cpu.arch;14const native_arch = builtin.cpu.arch;
15const native_os = std.Target.current.os.tag;15const native_os = builtin.os.tag;
1616
17var argc_argv_ptr: [*]usize = undefined;17var argc_argv_ptr: [*]usize = undefined;
1818
...@@ -80,7 +80,7 @@ fn _start2() callconv(.Naked) noreturn {...@@ -80,7 +80,7 @@ fn _start2() callconv(.Naked) noreturn {
80}80}
8181
82fn exit2(code: u8) noreturn {82fn exit2(code: u8) noreturn {
83 switch (native_arch) {83 switch (builtin.stage2_arch) {
84 .x86_64 => {84 .x86_64 => {
85 asm volatile ("syscall"85 asm volatile ("syscall"
86 :86 :
src/Compilation.zig+4
...@@ -3078,7 +3078,10 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) Alloc...@@ -3078,7 +3078,10 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) Alloc
3078 \\/// Zig version. When writing code that supports multiple versions of Zig, prefer3078 \\/// Zig version. When writing code that supports multiple versions of Zig, prefer
3079 \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.3079 \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
3080 \\pub const zig_version = try std.SemanticVersion.parse("{s}");3080 \\pub const zig_version = try std.SemanticVersion.parse("{s}");
3081 \\/// Temporary until self-hosted is feature complete.
3081 \\pub const zig_is_stage2 = {};3082 \\pub const zig_is_stage2 = {};
3083 \\/// Temporary until self-hosted supports the `cpu.arch` value.
3084 \\pub const stage2_arch: std.Target.Cpu.Arch = .{};
3082 \\3085 \\
3083 \\pub const output_mode = std.builtin.OutputMode.{};3086 \\pub const output_mode = std.builtin.OutputMode.{};
3084 \\pub const link_mode = std.builtin.LinkMode.{};3087 \\pub const link_mode = std.builtin.LinkMode.{};
...@@ -3093,6 +3096,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) Alloc...@@ -3093,6 +3096,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) Alloc
3093 , .{3096 , .{
3094 build_options.version,3097 build_options.version,
3095 !use_stage1,3098 !use_stage1,
3099 std.zig.fmtId(@tagName(target.cpu.arch)),
3096 std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)),3100 std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)),
3097 std.zig.fmtId(@tagName(comp.bin_file.options.link_mode)),3101 std.zig.fmtId(@tagName(comp.bin_file.options.link_mode)),
3098 comp.bin_file.options.is_test,3102 comp.bin_file.options.is_test,