| ... | @@ -2718,7 +2718,9 @@ fn buildOutputType( | ... | @@ -2718,7 +2718,9 @@ fn buildOutputType( |
| 2718 | switch (c_out_mode orelse .link) { | 2718 | switch (c_out_mode orelse .link) { |
| 2719 | .link => { | 2719 | .link => { |
| 2720 | create_module.opts.output_mode = if (is_shared_lib) .Lib else .Exe; | 2720 | create_module.opts.output_mode = if (is_shared_lib) .Lib else .Exe; |
| 2721 | emit_bin = if (out_path) |p| .{ .yes = p } else EmitBin.yes_a_out; | 2721 | if (emit_bin != .no) { |
| | 2722 | emit_bin = if (out_path) |p| .{ .yes = p } else EmitBin.yes_a_out; |
| | 2723 | } |
| 2722 | if (emit_llvm) { | 2724 | if (emit_llvm) { |
| 2723 | fatal("-emit-llvm cannot be used when linking", .{}); | 2725 | fatal("-emit-llvm cannot be used when linking", .{}); |
| 2724 | } | 2726 | } |
| ... | @@ -2768,10 +2770,13 @@ fn buildOutputType( | ... | @@ -2768,10 +2770,13 @@ fn buildOutputType( |
| 2768 | emit_bin = if (out_path) |p| .{ .yes = p } else .yes_default_path; | 2770 | emit_bin = if (out_path) |p| .{ .yes = p } else .yes_default_path; |
| 2769 | clang_preprocessor_mode = .pch; | 2771 | clang_preprocessor_mode = .pch; |
| 2770 | } else { | 2772 | } else { |
| 2771 | if (out_path) |p| { | 2773 | // If the output path is "-" (stdout), then we need to emit the preprocessed output to stdout |
| 2772 | emit_bin = .{ .yes = p }; | 2774 | // like "clang -E main.c -o -" does. |
| | 2775 | if (out_path != null and !mem.eql(u8, out_path.?, "-")) { |
| | 2776 | emit_bin = .{ .yes = out_path.? }; |
| 2773 | clang_preprocessor_mode = .yes; | 2777 | clang_preprocessor_mode = .yes; |
| 2774 | } else { | 2778 | } else { |
| | 2779 | emit_bin = .no; |
| 2775 | clang_preprocessor_mode = .stdout; | 2780 | clang_preprocessor_mode = .stdout; |
| 2776 | } | 2781 | } |
| 2777 | } | 2782 | } |