diff options
| author | Brendan Burns <bburns@microsoft.com> | 2023-01-06 08:40:16 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-06 18:40:16 +0200 |
| commit | 24b4e643f486ce803f758a6eab0c587c44b9cfa4 (patch) | |
| tree | a462fbd4199453da809cb7239ed52bb81e26c8cc /src | |
| parent | 7a2d7ff6280c4e75618b5d4de24c3ff4aedd8a18 (diff) | |
| download | zig-24b4e643f486ce803f758a6eab0c587c44b9cfa4.tar.gz zig-24b4e643f486ce803f758a6eab0c587c44b9cfa4.zip | |
Implement some more environment functions for WASI.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.zig | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.zig b/src/main.zig index ba82efc294..007adb78ac 100644 --- a/src/main.zig +++ b/src/main.zig @@ -637,6 +637,10 @@ const Emit = union(enum) { }; fn optionalStringEnvVar(arena: Allocator, name: []const u8) !?[]const u8 { + // Env vars aren't used in the bootstrap stage. + if (build_options.only_c) { + return null; + } if (std.process.getEnvVarOwned(arena, name)) |value| { return value; } else |err| switch (err) { @@ -676,8 +680,8 @@ fn buildOutputType( var no_builtin = false; var watch = false; var debug_compile_errors = false; - var verbose_link = std.process.hasEnvVarConstant("ZIG_VERBOSE_LINK"); - var verbose_cc = std.process.hasEnvVarConstant("ZIG_VERBOSE_CC"); + var verbose_link = (builtin.os.tag != .wasi or builtin.link_libc) and std.process.hasEnvVarConstant("ZIG_VERBOSE_LINK"); + var verbose_cc = (builtin.os.tag != .wasi or builtin.link_libc) and std.process.hasEnvVarConstant("ZIG_VERBOSE_CC"); var verbose_air = false; var verbose_llvm_ir = false; var verbose_cimport = false; @@ -859,7 +863,8 @@ fn buildOutputType( // before arg parsing, check for the NO_COLOR environment variable // if it exists, default the color setting to .off // explicit --color arguments will still override this setting. - color = if (std.process.hasEnvVarConstant("NO_COLOR")) .off else .auto; + // Disable color on WASI per https://github.com/WebAssembly/WASI/issues/162 + color = if (builtin.os.tag == .wasi or std.process.hasEnvVarConstant("NO_COLOR")) .off else .auto; switch (arg_mode) { .build, .translate_c, .zig_test, .run => { |
