authorgravatar for gwenzek@users.noreply.github.comGuillaume Wenzek <gwenzek@users.noreply.github.com> 2022-09-07 11:16:48+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-15 10:39:19-07:00
log004fca2c6496b7760b453dabc1d8041621d011ca
treef0c6f72942291e72eb19e6d4869a9c55ed6cacfa
parentb3dc80a1e33cf78205666d01a6dcf53bd5a4698f

restore comp when leaving flushModule


1 files changed, 14 insertions(+), 8 deletions(-)

src/link/NvPtx.zig+14-8
......@@ -109,13 +109,19 @@ pub fn flushModule(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.No
109109 const tracy = trace(@src());
110110 defer tracy.end();
111111
112 var hack_comp = comp;
113 if (comp.bin_file.options.emit) |emit| {
114 hack_comp.emit_asm = .{
115 .directory = emit.directory,
116 .basename = comp.bin_file.intermediary_basename.?,
117 };
118 hack_comp.bin_file.options.emit = null;
112 const outfile = comp.bin_file.options.emit.?;
113 // !!! We modify 'comp' before passing it to LLVM, but restore value afterwards
114 // We tell LLVM to not try to build a .o, only an "assembly" file.
115 // This is required by the LLVM PTX backend.
116 comp.bin_file.options.emit = null;
117 comp.emit_asm = .{
118 .directory = outfile.directory,
119 .basename = comp.bin_file.intermediary_basename.?,
120 };
121 defer {
122 comp.bin_file.options.emit = outfile;
123 comp.emit_asm = null;
119124 }
120 return try self.llvm_object.flushModule(hack_comp, prog_node);
125
126 try self.llvm_object.flushModule(comp, prog_node);
121127}