| ... | @@ -780,7 +780,7 @@ pub const Object = struct { | ... | @@ -780,7 +780,7 @@ pub const Object = struct { |
| 780 | null; | 780 | null; |
| 781 | | 781 | |
| 782 | const emit_asm_path = try locPath(arena, comp.emit_asm, cache_dir); | 782 | const emit_asm_path = try locPath(arena, comp.emit_asm, cache_dir); |
| 783 | const emit_llvm_ir_path = try locPath(arena, comp.emit_llvm_ir, cache_dir); | 783 | var emit_llvm_ir_path = try locPath(arena, comp.emit_llvm_ir, cache_dir); |
| 784 | const emit_llvm_bc_path = try locPath(arena, comp.emit_llvm_bc, cache_dir); | 784 | const emit_llvm_bc_path = try locPath(arena, comp.emit_llvm_bc, cache_dir); |
| 785 | | 785 | |
| 786 | const emit_asm_msg = emit_asm_path orelse "(none)"; | 786 | const emit_asm_msg = emit_asm_path orelse "(none)"; |
| ... | @@ -791,7 +791,34 @@ pub const Object = struct { | ... | @@ -791,7 +791,34 @@ pub const Object = struct { |
| 791 | emit_asm_msg, emit_bin_msg, emit_llvm_ir_msg, emit_llvm_bc_msg, | 791 | emit_asm_msg, emit_bin_msg, emit_llvm_ir_msg, emit_llvm_bc_msg, |
| 792 | }); | 792 | }); |
| 793 | | 793 | |
| | 794 | // Unfortunately, LLVM shits the bed when we ask for both binary and assembly. |
| | 795 | // So we call the entire pipeline multiple times if this is requested. |
| 794 | var error_message: [*:0]const u8 = undefined; | 796 | var error_message: [*:0]const u8 = undefined; |
| | 797 | if (emit_asm_path != null and emit_bin_path != null) { |
| | 798 | if (self.target_machine.emitToFile( |
| | 799 | self.llvm_module, |
| | 800 | &error_message, |
| | 801 | comp.bin_file.options.optimize_mode == .Debug, |
| | 802 | comp.bin_file.options.optimize_mode == .ReleaseSmall, |
| | 803 | comp.time_report, |
| | 804 | comp.bin_file.options.tsan, |
| | 805 | comp.bin_file.options.lto, |
| | 806 | null, |
| | 807 | emit_bin_path, |
| | 808 | emit_llvm_ir_path, |
| | 809 | null, |
| | 810 | )) { |
| | 811 | defer llvm.disposeMessage(error_message); |
| | 812 | |
| | 813 | log.err("LLVM failed to emit bin={s} ir={s}: {s}", .{ |
| | 814 | emit_bin_msg, emit_llvm_ir_msg, error_message, |
| | 815 | }); |
| | 816 | return error.FailedToEmit; |
| | 817 | } |
| | 818 | emit_bin_path = null; |
| | 819 | emit_llvm_ir_path = null; |
| | 820 | } |
| | 821 | |
| 795 | if (self.target_machine.emitToFile( | 822 | if (self.target_machine.emitToFile( |
| 796 | self.llvm_module, | 823 | self.llvm_module, |
| 797 | &error_message, | 824 | &error_message, |