diff --git a/src/main.zig b/src/main.zig index ff78d16803..cdda56e8ad 100644 --- 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