commit 91b8d9e370f0dfc62f7bf7297ce9a7e22bae9f67 (tree)
parent 6064477928421c748c01db5e84401c4f9e220125
Author: Guillaume Wenzek <gwenzek@users.noreply.github.com>
Date: Wed, 16 Nov 2022 10:50:35 +0100
fix Nvptx backend outputing files at the top level of zig-cache
Diffstat:
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/std/zig.zig b/lib/std/zig.zig
@@ -193,7 +193,7 @@ pub fn binNameAlloc(allocator: std.mem.Allocator, options: BinNameOptions) error
target.libPrefix(), root_name,
}),
},
- .nvptx => return std.fmt.allocPrint(allocator, "{s}", .{root_name}),
+ .nvptx => return std.fmt.allocPrint(allocator, "{s}.ptx", .{root_name}),
.dxcontainer => @panic("TODO what's the file extension for these?"),
}
}
diff --git a/src/link/NvPtx.zig b/src/link/NvPtx.zig
@@ -23,6 +23,7 @@ const LlvmObject = @import("../codegen/llvm.zig").Object;
base: link.File,
llvm_object: *LlvmObject,
+ptx_file_name: []const u8,
pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx {
if (!build_options.have_llvm) return error.PtxArchNotSupported;
@@ -46,6 +47,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx {
.allocator = gpa,
},
.llvm_object = llvm_object,
+ .ptx_file_name = try std.mem.join(gpa, "", &[_][]const u8{ options.root_name, ".ptx" }),
};
return nvptx;
@@ -63,6 +65,7 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option
pub fn deinit(self: *NvPtx) void {
if (!build_options.have_llvm) return;
self.llvm_object.destroy(self.base.allocator);
+ self.base.allocator.free(self.ptx_file_name);
}
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
// 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.?,
+ // 'null' means using the default cache dir: zig-cache/o/...
+ .directory = null,
+ .basename = self.ptx_file_name,
};
defer {
comp.bin_file.options.emit = outfile;