Commit e1375942e5

Andrew Kelley <andrew@ziglang.org>
2022-02-28 20:36:45
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.
1 parent 331cc81
Changed files (1)
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