| ... | @@ -23,6 +23,7 @@ const LlvmObject = @import("../codegen/llvm.zig").Object; | ... | @@ -23,6 +23,7 @@ const LlvmObject = @import("../codegen/llvm.zig").Object; |
| 23 | | 23 | |
| 24 | base: link.File, | 24 | base: link.File, |
| 25 | llvm_object: *LlvmObject, | 25 | llvm_object: *LlvmObject, |
| | 26 | ptx_file_name: []const u8, |
| 26 | | 27 | |
| 27 | pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx { | 28 | pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx { |
| 28 | if (!build_options.have_llvm) return error.PtxArchNotSupported; | 29 | if (!build_options.have_llvm) return error.PtxArchNotSupported; |
| ... | @@ -46,6 +47,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx { | ... | @@ -46,6 +47,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx { |
| 46 | .allocator = gpa, | 47 | .allocator = gpa, |
| 47 | }, | 48 | }, |
| 48 | .llvm_object = llvm_object, | 49 | .llvm_object = llvm_object, |
| | 50 | .ptx_file_name = try std.mem.join(gpa, "", &[_][]const u8{ options.root_name, ".ptx" }), |
| 49 | }; | 51 | }; |
| 50 | | 52 | |
| 51 | return nvptx; | 53 | return nvptx; |
| ... | @@ -63,6 +65,7 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option | ... | @@ -63,6 +65,7 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option |
| 63 | pub fn deinit(self: *NvPtx) void { | 65 | pub fn deinit(self: *NvPtx) void { |
| 64 | if (!build_options.have_llvm) return; | 66 | if (!build_options.have_llvm) return; |
| 65 | self.llvm_object.destroy(self.base.allocator); | 67 | self.llvm_object.destroy(self.base.allocator); |
| | 68 | self.base.allocator.free(self.ptx_file_name); |
| 66 | } | 69 | } |
| 67 | | 70 | |
| 68 | pub fn updateFunc(self: *NvPtx, module: *Module, func: *Module.Fn, air: Air, liveness: Liveness) !void { | 71 | pub fn updateFunc(self: *NvPtx, module: *Module, func: *Module.Fn, air: Air, liveness: Liveness) !void { |
| ... | @@ -111,8 +114,9 @@ pub fn flushModule(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.No | ... | @@ -111,8 +114,9 @@ pub fn flushModule(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.No |
| 111 | // This is required by the LLVM PTX backend. | 114 | // This is required by the LLVM PTX backend. |
| 112 | comp.bin_file.options.emit = null; | 115 | comp.bin_file.options.emit = null; |
| 113 | comp.emit_asm = .{ | 116 | comp.emit_asm = .{ |
| 114 | .directory = outfile.directory, | 117 | // 'null' means using the default cache dir: zig-cache/o/... |
| 115 | .basename = comp.bin_file.intermediary_basename.?, | 118 | .directory = null, |
| | 119 | .basename = self.ptx_file_name, |
| 116 | }; | 120 | }; |
| 117 | defer { | 121 | defer { |
| 118 | comp.bin_file.options.emit = outfile; | 122 | comp.bin_file.options.emit = outfile; |