diff options
| author | Guillaume Wenzek <gwenzek@users.noreply.github.com> | 2022-09-07 11:16:48 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-10-15 10:39:19 -0700 |
| commit | 004fca2c6496b7760b453dabc1d8041621d011ca (patch) | |
| tree | f0c6f72942291e72eb19e6d4869a9c55ed6cacfa | |
| parent | b3dc80a1e33cf78205666d01a6dcf53bd5a4698f (diff) | |
| download | zig-004fca2c6496b7760b453dabc1d8041621d011ca.tar.gz zig-004fca2c6496b7760b453dabc1d8041621d011ca.zip | |
restore comp when leaving flushModule
| -rw-r--r-- | src/link/NvPtx.zig | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/link/NvPtx.zig b/src/link/NvPtx.zig index 7bf51c7ad3..eeea371d00 100644 --- a/src/link/NvPtx.zig +++ b/src/link/NvPtx.zig @@ -109,13 +109,19 @@ pub fn flushModule(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.No const tracy = trace(@src()); defer tracy.end(); - var hack_comp = comp; - if (comp.bin_file.options.emit) |emit| { - hack_comp.emit_asm = .{ - .directory = emit.directory, - .basename = comp.bin_file.intermediary_basename.?, - }; - hack_comp.bin_file.options.emit = null; + const outfile = comp.bin_file.options.emit.?; + // !!! We modify 'comp' before passing it to LLVM, but restore value afterwards + // We tell LLVM to not try to build a .o, only an "assembly" file. + // This is required by the LLVM PTX backend. + comp.bin_file.options.emit = null; + comp.emit_asm = .{ + .directory = outfile.directory, + .basename = comp.bin_file.intermediary_basename.?, + }; + defer { + comp.bin_file.options.emit = outfile; + comp.emit_asm = null; } - return try self.llvm_object.flushModule(hack_comp, prog_node); + + try self.llvm_object.flushModule(comp, prog_node); } |
