Skip to content

Commit 6393928

Browse files
committed
link: add more respect for -fno-emit-bin
closes #16347
1 parent 38840e2 commit 6393928

File tree

6 files changed

+14
-3
lines changed

6 files changed

+14
-3
lines changed

src/link.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,15 +966,17 @@ 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

972974
var arena_allocator = std.heap.ArenaAllocator.init(base.allocator);
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

0 commit comments

Comments
 (0)