authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-30 11:18:09-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-30 11:19:36-07:00
log6393928d508d5a18d3a15b8c9ecbc53ffb3812ce
tree0084cfb1d96fa3357afa4ee68eab0412c60a7dd7
parent38840e2e586d71f2b38ed825ea02529f615c5f0c

link: add more respect for -fno-emit-bin

closes #16347

6 files changed, 14 insertions(+), 3 deletions(-)

src/link.zig+4-2
......@@ -966,6 +966,8 @@ pub const File = struct {
966966 }
967967
968968 pub fn linkAsArchive(base: *File, comp: *Compilation, prog_node: *std.Progress.Node) FlushError!void {
969 const emit = base.options.emit orelse return;
970
969971 const tracy = trace(@src());
970972 defer tracy.end();
971973
......@@ -973,8 +975,8 @@ pub const File = struct {
973975 defer arena_allocator.deinit();
974976 const arena = arena_allocator.allocator();
975977
976 const directory = base.options.emit.?.directory; // Just an alias to make it shorter to type.
977 const full_out_path = try directory.join(arena, &[_][]const u8{base.options.emit.?.sub_path});
978 const directory = emit.directory; // Just an alias to make it shorter to type.
979 const full_out_path = try directory.join(arena, &[_][]const u8{emit.sub_path});
978980 const full_out_path_z = try arena.dupeZ(u8, full_out_path);
979981
980982 // If there is no Zig code to compile, then we should skip flushing the output file
src/link/Coff.zig+2
......@@ -1452,6 +1452,8 @@ pub fn updateDeclExports(
14521452 if (self.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports);
14531453 }
14541454
1455 if (self.base.options.emit == null) return;
1456
14551457 const gpa = self.base.allocator;
14561458
14571459 const decl = mod.declPtr(decl_index);
src/link/Elf.zig+2
......@@ -2865,6 +2865,8 @@ pub fn updateDeclExports(
28652865 if (self.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports);
28662866 }
28672867
2868 if (self.base.options.emit == null) return;
2869
28682870 const tracy = trace(@src());
28692871 defer tracy.end();
28702872
src/link/MachO.zig+2
......@@ -2386,6 +2386,8 @@ pub fn updateDeclExports(
23862386 return llvm_object.updateDeclExports(mod, decl_index, exports);
23872387 }
23882388
2389 if (self.base.options.emit == null) return;
2390
23892391 const tracy = trace(@src());
23902392 defer tracy.end();
23912393
src/link/NvPtx.zig+2-1
......@@ -106,10 +106,11 @@ pub fn flushModule(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.No
106106 if (build_options.skip_non_native) {
107107 @panic("Attempted to compile for architecture that was disabled by build configuration");
108108 }
109 const outfile = comp.bin_file.options.emit orelse return;
110
109111 const tracy = trace(@src());
110112 defer tracy.end();
111113
112 const outfile = comp.bin_file.options.emit.?;
113114 // We modify 'comp' before passing it to LLVM, but restore value afterwards.
114115 // We tell LLVM to not try to build a .o, only an "assembly" file.
115116 // This is required by the LLVM PTX backend.
src/link/Wasm.zig+2
......@@ -1712,6 +1712,8 @@ pub fn updateDeclExports(
17121712 if (wasm.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports);
17131713 }
17141714
1715 if (wasm.base.options.emit == null) return;
1716
17151717 const decl = mod.declPtr(decl_index);
17161718 const atom_index = try wasm.getOrCreateAtomForDecl(decl_index);
17171719 const atom = wasm.getAtom(atom_index);