authorgravatar for gwenzek@users.noreply.github.comGuillaume Wenzek <gwenzek@users.noreply.github.com> 2022-11-16 10:50:35+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-11-16 18:49:04-05:00
log699e7f721b36e1f8afb9d87c9005e4345a321aa9
tree8558087b138f3d5d973d7c8da17553760269a84f
parent07671838b0cbf96c787fa94653bd5ceacdd47701

fix Nvptx backend outputing files at the top level of zig-cache


2 files changed, 7 insertions(+), 3 deletions(-)

lib/std/zig.zig+1-1
......@@ -193,7 +193,7 @@ pub fn binNameAlloc(allocator: std.mem.Allocator, options: BinNameOptions) error
193193 target.libPrefix(), root_name,
194194 }),
195195 },
196 .nvptx => return std.fmt.allocPrint(allocator, "{s}", .{root_name}),
196 .nvptx => return std.fmt.allocPrint(allocator, "{s}.ptx", .{root_name}),
197197 .dxcontainer => @panic("TODO what's the file extension for these?"),
198198 }
199199}
src/link/NvPtx.zig+6-2
......@@ -23,6 +23,7 @@ const LlvmObject = @import("../codegen/llvm.zig").Object;
2323
2424base: link.File,
2525llvm_object: *LlvmObject,
26ptx_file_name: []const u8,
2627
2728pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx {
2829 if (!build_options.have_llvm) return error.PtxArchNotSupported;
......@@ -46,6 +47,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx {
4647 .allocator = gpa,
4748 },
4849 .llvm_object = llvm_object,
50 .ptx_file_name = try std.mem.join(gpa, "", &[_][]const u8{ options.root_name, ".ptx" }),
4951 };
5052
5153 return nvptx;
......@@ -63,6 +65,7 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option
6365pub fn deinit(self: *NvPtx) void {
6466 if (!build_options.have_llvm) return;
6567 self.llvm_object.destroy(self.base.allocator);
68 self.base.allocator.free(self.ptx_file_name);
6669}
6770
6871pub 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
111114 // This is required by the LLVM PTX backend.
112115 comp.bin_file.options.emit = null;
113116 comp.emit_asm = .{
114 .directory = outfile.directory,
115 .basename = comp.bin_file.intermediary_basename.?,
117 // 'null' means using the default cache dir: zig-cache/o/...
118 .directory = null,
119 .basename = self.ptx_file_name,
116120 };
117121 defer {
118122 comp.bin_file.options.emit = outfile;