@@ -12,6 +12,7 @@ const Color = std.zig.Color;
12
12
const warn = std .log .warn ;
13
13
const ThreadPool = std .Thread .Pool ;
14
14
const cleanExit = std .process .cleanExit ;
15
+ const native_os = builtin .os .tag ;
15
16
16
17
const tracy = @import ("tracy.zig" );
17
18
const Compilation = @import ("Compilation.zig" );
@@ -158,9 +159,9 @@ var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{
158
159
pub fn main () anyerror ! void {
159
160
crash_report .initialize ();
160
161
161
- const use_gpa = (build_options .force_gpa or ! builtin .link_libc ) and builtin . os . tag != .wasi ;
162
+ const use_gpa = (build_options .force_gpa or ! builtin .link_libc ) and native_os != .wasi ;
162
163
const gpa = gpa : {
163
- if (builtin . os . tag == .wasi ) {
164
+ if (native_os == .wasi ) {
164
165
break :gpa std .heap .wasm_allocator ;
165
166
}
166
167
if (use_gpa ) {
@@ -187,7 +188,7 @@ pub fn main() anyerror!void {
187
188
return mainArgs (gpa_tracy .allocator (), arena , args );
188
189
}
189
190
190
- if (builtin . os . tag == .wasi ) {
191
+ if (native_os == .wasi ) {
191
192
wasi_preopens = try fs .wasi .preopensAlloc (arena );
192
193
}
193
194
@@ -813,9 +814,9 @@ fn buildOutputType(
813
814
var no_builtin = false ;
814
815
var listen : Listen = .none ;
815
816
var debug_compile_errors = false ;
816
- var verbose_link = (builtin . os . tag != .wasi or builtin .link_libc ) and
817
+ var verbose_link = (native_os != .wasi or builtin .link_libc ) and
817
818
EnvVar .ZIG_VERBOSE_LINK .isSet ();
818
- var verbose_cc = (builtin . os . tag != .wasi or builtin .link_libc ) and
819
+ var verbose_cc = (native_os != .wasi or builtin .link_libc ) and
819
820
EnvVar .ZIG_VERBOSE_CC .isSet ();
820
821
var verbose_air = false ;
821
822
var verbose_intern_pool = false ;
@@ -991,7 +992,7 @@ fn buildOutputType(
991
992
// if it exists, default the color setting to .off
992
993
// explicit --color arguments will still override this setting.
993
994
// Disable color on WASI per https://github.com/WebAssembly/WASI/issues/162
994
- var color : Color = if (builtin . os . tag == .wasi or EnvVar .NO_COLOR .isSet ()) .off else .auto ;
995
+ var color : Color = if (native_os == .wasi or EnvVar .NO_COLOR .isSet ()) .off else .auto ;
995
996
996
997
switch (arg_mode ) {
997
998
.build , .translate_c , .zig_test , .run = > {
@@ -2684,7 +2685,7 @@ fn buildOutputType(
2684
2685
fatal ("unable to open zig lib directory '{s}': {s}" , .{ lib_dir , @errorName (err ) });
2685
2686
},
2686
2687
};
2687
- } else if (builtin . os . tag == .wasi ) {
2688
+ } else if (native_os == .wasi ) {
2688
2689
break :d getWasiPreopen ("/lib" );
2689
2690
} else if (self_exe_path ) | p | {
2690
2691
break :d introspect .findZigLibDirFromSelfExe (arena , p ) catch | err | {
@@ -2703,7 +2704,7 @@ fn buildOutputType(
2703
2704
.path = p ,
2704
2705
};
2705
2706
}
2706
- if (builtin . os . tag == .wasi ) {
2707
+ if (native_os == .wasi ) {
2707
2708
break :l getWasiPreopen ("/cache" );
2708
2709
}
2709
2710
const p = try introspect .resolveGlobalCacheDir (arena );
@@ -4368,7 +4369,7 @@ fn runOrTest(
4368
4369
}
4369
4370
} else {
4370
4371
const cmd = try std .mem .join (arena , " " , argv .items );
4371
- fatal ("the following command cannot be executed ({s} does not support spawning a child process):\n {s}" , .{ @tagName (builtin . os . tag ), cmd });
4372
+ fatal ("the following command cannot be executed ({s} does not support spawning a child process):\n {s}" , .{ @tagName (native_os ), cmd });
4372
4373
}
4373
4374
}
4374
4375
@@ -4747,9 +4748,9 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
4747
4748
var child_argv = std .ArrayList ([]const u8 ).init (arena );
4748
4749
var reference_trace : ? u32 = null ;
4749
4750
var debug_compile_errors = false ;
4750
- var verbose_link = (builtin . os . tag != .wasi or builtin .link_libc ) and
4751
+ var verbose_link = (native_os != .wasi or builtin .link_libc ) and
4751
4752
EnvVar .ZIG_VERBOSE_LINK .isSet ();
4752
- var verbose_cc = (builtin . os . tag != .wasi or builtin .link_libc ) and
4753
+ var verbose_cc = (native_os != .wasi or builtin .link_libc ) and
4753
4754
EnvVar .ZIG_VERBOSE_CC .isSet ();
4754
4755
var verbose_air = false ;
4755
4756
var verbose_intern_pool = false ;
@@ -4894,7 +4895,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
4894
4895
}
4895
4896
}
4896
4897
4897
- const work_around_btrfs_bug = builtin . os . tag == .linux and
4898
+ const work_around_btrfs_bug = native_os == .linux and
4898
4899
EnvVar .ZIG_BTRFS_WORKAROUND .isSet ();
4899
4900
const color : Color = .auto ;
4900
4901
@@ -5311,7 +5312,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
5311
5312
}
5312
5313
} else {
5313
5314
const cmd = try std .mem .join (arena , " " , child_argv .items );
5314
- fatal ("the following command cannot be executed ({s} does not support spawning a child process):\n {s}" , .{ @tagName (builtin . os . tag ), cmd });
5315
+ fatal ("the following command cannot be executed ({s} does not support spawning a child process):\n {s}" , .{ @tagName (native_os ), cmd });
5315
5316
}
5316
5317
}
5317
5318
}
@@ -5543,7 +5544,7 @@ fn jitCmd(
5543
5544
if (! process .can_spawn ) {
5544
5545
const cmd = try std .mem .join (arena , " " , child_argv .items );
5545
5546
fatal ("the following command cannot be executed ({s} does not support spawning a child process):\n {s}" , .{
5546
- @tagName (builtin . os . tag ), cmd ,
5547
+ @tagName (native_os ), cmd ,
5547
5548
});
5548
5549
}
5549
5550
@@ -5655,7 +5656,7 @@ pub fn lldMain(
5655
5656
var count : usize = 0 ;
5656
5657
};
5657
5658
if (CallCounter .count == 1 ) { // Issue the warning on the first repeat call
5658
- warn ("invoking LLD for the second time within the same process because the host OS ({s}) does not support spawning child processes. This sometimes activates LLD bugs" , .{@tagName (builtin . os . tag )});
5659
+ warn ("invoking LLD for the second time within the same process because the host OS ({s}) does not support spawning child processes. This sometimes activates LLD bugs" , .{@tagName (native_os )});
5659
5660
}
5660
5661
CallCounter .count += 1 ;
5661
5662
@@ -5985,21 +5986,21 @@ fn parseCodeModel(arg: []const u8) std.builtin.CodeModel {
5985
5986
/// garbage collector to run concurrently to zig processes, and to allow multiple
5986
5987
/// zig processes to run concurrently with each other, without clobbering each other.
5987
5988
fn gimmeMoreOfThoseSweetSweetFileDescriptors () void {
5988
- const have_rlimit = switch (builtin . os . tag ) {
5989
+ const have_rlimit = switch (native_os ) {
5989
5990
.windows , .wasi = > false ,
5990
5991
else = > true ,
5991
5992
};
5992
5993
if (! have_rlimit ) return ;
5993
5994
const posix = std .posix ;
5994
5995
5995
5996
var lim = posix .getrlimit (.NOFILE ) catch return ; // Oh well; we tried.
5996
- if (comptime builtin . target .isDarwin ()) {
5997
+ if (native_os .isDarwin ()) {
5997
5998
// On Darwin, `NOFILE` is bounded by a hardcoded value `OPEN_MAX`.
5998
5999
// According to the man pages for setrlimit():
5999
6000
// setrlimit() now returns with errno set to EINVAL in places that historically succeeded.
6000
6001
// It no longer accepts "rlim_cur = RLIM.INFINITY" for RLIM.NOFILE.
6001
6002
// Use "rlim_cur = min(OPEN_MAX, rlim_max)".
6002
- lim .max = @min (std .os . darwin .OPEN_MAX , lim .max );
6003
+ lim .max = @min (std .c .OPEN_MAX , lim .max );
6003
6004
}
6004
6005
if (lim .cur == lim .max ) return ;
6005
6006
@@ -6770,7 +6771,7 @@ fn cmdFetch(
6770
6771
args : []const []const u8 ,
6771
6772
) ! void {
6772
6773
const color : Color = .auto ;
6773
- const work_around_btrfs_bug = builtin . os . tag == .linux and
6774
+ const work_around_btrfs_bug = native_os == .linux and
6774
6775
EnvVar .ZIG_BTRFS_WORKAROUND .isSet ();
6775
6776
var opt_path_or_url : ? []const u8 = null ;
6776
6777
var override_global_cache_dir : ? []const u8 = try EnvVar .ZIG_GLOBAL_CACHE_DIR .get (arena );
0 commit comments