diff --git a/src/link.zig b/src/link.zig index 703dfb87394be3ae5a3af36966dbce8d1e53e46d..42322cbda88221d8af195b6eb310201c5e82825f 100644 --- a/src/link.zig +++ b/src/link.zig @@ -966,6 +966,8 @@ pub const File = struct { } pub fn linkAsArchive(base: *File, comp: *Compilation, prog_node: *std.Progress.Node) FlushError!void { + const emit = base.options.emit orelse return; + const tracy = trace(@src()); defer tracy.end(); @@ -973,8 +975,8 @@ pub const File = struct { defer arena_allocator.deinit(); const arena = arena_allocator.allocator(); - const directory = base.options.emit.?.directory; // Just an alias to make it shorter to type. - const full_out_path = try directory.join(arena, &[_][]const u8{base.options.emit.?.sub_path}); + const directory = emit.directory; // Just an alias to make it shorter to type. + const full_out_path = try directory.join(arena, &[_][]const u8{emit.sub_path}); const full_out_path_z = try arena.dupeZ(u8, full_out_path); // If there is no Zig code to compile, then we should skip flushing the output file diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 8720fc1037b3cd1ca1595d2dd6179e3cc89135cc..f1b914c3681921c010fa2f00436df230c7b6811b 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -1452,6 +1452,8 @@ pub fn updateDeclExports( if (self.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports); } + if (self.base.options.emit == null) return; + const gpa = self.base.allocator; const decl = mod.declPtr(decl_index); diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 4bb049e0740323dc1c84cd046e2760499e2065d2..ec4da9c728e2c2acbb5bacb09ff36bf63df44688 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -2865,6 +2865,8 @@ pub fn updateDeclExports( if (self.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports); } + if (self.base.options.emit == null) return; + const tracy = trace(@src()); defer tracy.end(); diff --git a/src/link/MachO.zig b/src/link/MachO.zig index d124a1f51c4bbba99dbb7e671bd36dc1c24b8306..44e6acc3976d5abfa4c8405001db1ea53fe64cf8 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -2386,6 +2386,8 @@ pub fn updateDeclExports( return llvm_object.updateDeclExports(mod, decl_index, exports); } + if (self.base.options.emit == null) return; + const tracy = trace(@src()); defer tracy.end(); diff --git a/src/link/NvPtx.zig b/src/link/NvPtx.zig index fc3d659770cf9791911221933f2f231091e826b4..fd1504a3d3e6bbfb2218889cc58acff10c0032c4 100644 --- a/src/link/NvPtx.zig +++ b/src/link/NvPtx.zig @@ -106,10 +106,11 @@ pub fn flushModule(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.No if (build_options.skip_non_native) { @panic("Attempted to compile for architecture that was disabled by build configuration"); } + const outfile = comp.bin_file.options.emit orelse return; + const tracy = trace(@src()); defer tracy.end(); - 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. diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index c2a2de398f9bb6ca5d2e0ae30d382d21a8cc7bc7..11294daa8430fe14aebd247adf998b193f38a750 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -1712,6 +1712,8 @@ pub fn updateDeclExports( if (wasm.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports); } + if (wasm.base.options.emit == null) return; + const decl = mod.declPtr(decl_index); const atom_index = try wasm.getOrCreateAtomForDecl(decl_index); const atom = wasm.getAtom(atom_index);