authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-14 19:09:38-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:19-07:00
log6b44bddf5dd4a50c79cd1a4d3596cc07d868dd63
tree250504693547a4dbd3fbec11f53433f8df9722b4
parentc49957dbe82d7f0db555160b50306335bfa03165

linker: remove bad NvPtx flushModule implementation

it's not supposed to mutate Compilation like this.

1 files changed, 9 insertions(+), 23 deletions(-)

src/link/NvPtx.zig+9-23
...@@ -98,9 +98,9 @@ pub fn updateExports(...@@ -98,9 +98,9 @@ pub fn updateExports(
98 exported: Module.Exported,98 exported: Module.Exported,
99 exports: []const *Module.Export,99 exports: []const *Module.Export,
100) !void {100) !void {
101 if (build_options.skip_non_native and builtin.object_format != .nvptx) {101 if (build_options.skip_non_native and builtin.object_format != .nvptx)
102 @panic("Attempted to compile for object format that was disabled by build configuration");102 @panic("Attempted to compile for object format that was disabled by build configuration");
103 }103
104 return self.llvm_object.updateExports(module, exported, exports);104 return self.llvm_object.updateExports(module, exported, exports);
105}105}
106106
...@@ -113,27 +113,13 @@ pub fn flush(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.Node) li...@@ -113,27 +113,13 @@ pub fn flush(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.Node) li
113}113}
114114
115pub fn flushModule(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.Node) link.File.FlushError!void {115pub fn flushModule(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.Node) link.File.FlushError!void {
116 if (build_options.skip_non_native) {116 if (build_options.skip_non_native)
117 @panic("Attempted to compile for architecture that was disabled by build configuration");117 @panic("Attempted to compile for architecture that was disabled by build configuration");
118 }
119 const outfile = comp.bin_file.options.emit orelse return;
120
121 const tracy = trace(@src());
122 defer tracy.end();
123
124 // We modify 'comp' before passing it to LLVM, but restore value afterwards.
125 // We tell LLVM to not try to build a .o, only an "assembly" file.
126 // This is required by the LLVM PTX backend.
127 comp.bin_file.options.emit = null;
128 comp.emit_asm = .{
129 // 'null' means using the default cache dir: zig-cache/o/...
130 .directory = null,
131 .basename = self.base.emit.sub_path,
132 };
133 defer {
134 comp.bin_file.options.emit = outfile;
135 comp.emit_asm = null;
136 }
137118
138 try self.llvm_object.flushModule(comp, prog_node);119 // The code that was here before mutated the Compilation's file emission mechanism.
120 // That's not supposed to happen in flushModule, so I deleted the code.
121 _ = self;
122 _ = comp;
123 _ = prog_node;
124 @panic("TODO: rewrite the NvPtx.flushModule function");
139}125}