zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit e1375942e584d4fffd3ecd06277ced7cf35d7e6c (tree)
parent 331cc810ded2058f2e2767b0485eb18d888a45e5
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Mon, 28 Feb 2022 12:36:45 -0700

zig cc: special handling of /dev/null

Now we handle -o /dev/null equivalent to -fno-emit-bin because
otherwise our atomic rename into place will fail. This also
makes Zig do less work, avoiding pointless file system operations.

Diffstat:
Msrc/main.zig | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/main.zig b/src/main.zig @@ -1317,7 +1317,16 @@ fn buildOutputType( }; switch (it.zig_equivalent) { .target => target_arch_os_abi = it.only_arg, // example: -target riscv64-linux-unknown - .o => out_path = it.only_arg, // -o + .o => { + // We handle -o /dev/null equivalent to -fno-emit-bin because + // otherwise our atomic rename into place will fail. This also + // makes Zig do less work, avoiding pointless file system operations. + if (mem.eql(u8, it.only_arg, "/dev/null")) { + emit_bin = .no; + } else { + out_path = it.only_arg; + } + }, .c => c_out_mode = .object, // -c .asm_only => c_out_mode = .assembly, // -S .preprocess_only => c_out_mode = .preprocessor, // -E