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.
This commit is contained in:
Andrew Kelley 2022-02-28 12:36:45 -07:00
parent 331cc810de
commit e1375942e5

View File

@ -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