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 {...@@ -966,6 +966,8 @@ pub const File = struct {
966 }966 }
967967
968 pub fn linkAsArchive(base: *File, comp: *Compilation, prog_node: *std.Progress.Node) FlushError!void {968 pub fn linkAsArchive(base: *File, comp: *Compilation, prog_node: *std.Progress.Node) FlushError!void {
969 const emit = base.options.emit orelse return;
970
969 const tracy = trace(@src());971 const tracy = trace(@src());
970 defer tracy.end();972 defer tracy.end();
971973
...@@ -973,8 +975,8 @@ pub const File = struct {...@@ -973,8 +975,8 @@ pub const File = struct {
973 defer arena_allocator.deinit();975 defer arena_allocator.deinit();
974 const arena = arena_allocator.allocator();976 const arena = arena_allocator.allocator();
975977
976 const directory = base.options.emit.?.directory; // Just an alias to make it shorter to type.978 const directory = 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});979 const full_out_path = try directory.join(arena, &[_][]const u8{emit.sub_path});
978 const full_out_path_z = try arena.dupeZ(u8, full_out_path);980 const full_out_path_z = try arena.dupeZ(u8, full_out_path);
979981
980 // If there is no Zig code to compile, then we should skip flushing the output file982 // 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(...@@ -1452,6 +1452,8 @@ pub fn updateDeclExports(
1452 if (self.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports);1452 if (self.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports);
1453 }1453 }
14541454
1455 if (self.base.options.emit == null) return;
1456
1455 const gpa = self.base.allocator;1457 const gpa = self.base.allocator;
14561458
1457 const decl = mod.declPtr(decl_index);1459 const decl = mod.declPtr(decl_index);
src/link/Elf.zig+2
...@@ -2865,6 +2865,8 @@ pub fn updateDeclExports(...@@ -2865,6 +2865,8 @@ pub fn updateDeclExports(
2865 if (self.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports);2865 if (self.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports);
2866 }2866 }
28672867
2868 if (self.base.options.emit == null) return;
2869
2868 const tracy = trace(@src());2870 const tracy = trace(@src());
2869 defer tracy.end();2871 defer tracy.end();
28702872
src/link/MachO.zig+2
...@@ -2386,6 +2386,8 @@ pub fn updateDeclExports(...@@ -2386,6 +2386,8 @@ pub fn updateDeclExports(
2386 return llvm_object.updateDeclExports(mod, decl_index, exports);2386 return llvm_object.updateDeclExports(mod, decl_index, exports);
2387 }2387 }
23882388
2389 if (self.base.options.emit == null) return;
2390
2389 const tracy = trace(@src());2391 const tracy = trace(@src());
2390 defer tracy.end();2392 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...@@ -106,10 +106,11 @@ pub fn flushModule(self: *NvPtx, comp: *Compilation, prog_node: *std.Progress.No
106 if (build_options.skip_non_native) {106 if (build_options.skip_non_native) {
107 @panic("Attempted to compile for architecture that was disabled by build configuration");107 @panic("Attempted to compile for architecture that was disabled by build configuration");
108 }108 }
109 const outfile = comp.bin_file.options.emit orelse return;
110
109 const tracy = trace(@src());111 const tracy = trace(@src());
110 defer tracy.end();112 defer tracy.end();
111113
112 const outfile = comp.bin_file.options.emit.?;
113 // We modify 'comp' before passing it to LLVM, but restore value afterwards.114 // We modify 'comp' before passing it to LLVM, but restore value afterwards.
114 // We tell LLVM to not try to build a .o, only an "assembly" file.115 // We tell LLVM to not try to build a .o, only an "assembly" file.
115 // This is required by the LLVM PTX backend.116 // This is required by the LLVM PTX backend.
src/link/Wasm.zig+2
...@@ -1712,6 +1712,8 @@ pub fn updateDeclExports(...@@ -1712,6 +1712,8 @@ pub fn updateDeclExports(
1712 if (wasm.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports);1712 if (wasm.llvm_object) |llvm_object| return llvm_object.updateDeclExports(mod, decl_index, exports);
1713 }1713 }
17141714
1715 if (wasm.base.options.emit == null) return;
1716
1715 const decl = mod.declPtr(decl_index);1717 const decl = mod.declPtr(decl_index);
1716 const atom_index = try wasm.getOrCreateAtomForDecl(decl_index);1718 const atom_index = try wasm.getOrCreateAtomForDecl(decl_index);
1717 const atom = wasm.getAtom(atom_index);1719 const atom = wasm.getAtom(atom_index);