authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-28 12:36:45-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-28 12:36:45-07:00
loge1375942e584d4fffd3ecd06277ced7cf35d7e6c
tree024365c5e9a858182e253bdfcd81e220b15a93fe
parent331cc810ded2058f2e2767b0485eb18d888a45e5

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 files changed, 10 insertions(+), 1 deletions(-)

src/main.zig+10-1
...@@ -1317,7 +1317,16 @@ fn buildOutputType(...@@ -1317,7 +1317,16 @@ fn buildOutputType(
1317 };1317 };
1318 switch (it.zig_equivalent) {1318 switch (it.zig_equivalent) {
1319 .target => target_arch_os_abi = it.only_arg, // example: -target riscv64-linux-unknown1319 .target => target_arch_os_abi = it.only_arg, // example: -target riscv64-linux-unknown
1320 .o => out_path = it.only_arg, // -o1320 .o => {
1321 // We handle -o /dev/null equivalent to -fno-emit-bin because
1322 // otherwise our atomic rename into place will fail. This also
1323 // makes Zig do less work, avoiding pointless file system operations.
1324 if (mem.eql(u8, it.only_arg, "/dev/null")) {
1325 emit_bin = .no;
1326 } else {
1327 out_path = it.only_arg;
1328 }
1329 },
1321 .c => c_out_mode = .object, // -c1330 .c => c_out_mode = .object, // -c
1322 .asm_only => c_out_mode = .assembly, // -S1331 .asm_only => c_out_mode = .assembly, // -S
1323 .preprocess_only => c_out_mode = .preprocessor, // -E1332 .preprocess_only => c_out_mode = .preprocessor, // -E