Skip to content

Commit

Permalink
link: add more respect for -fno-emit-bin
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk authored and QusaiHroub committed Aug 3, 2023
1 parent bedca92 commit 54ec19b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/link.zig
Original file line number Diff line number Diff line change
Expand Up @@ -966,15 +966,17 @@ 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();

var arena_allocator = std.heap.ArenaAllocator.init(base.allocator);
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
Expand Down
2 changes: 2 additions & 0 deletions src/link/Coff.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/link/Elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 2 additions & 0 deletions src/link/MachO.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 2 additions & 1 deletion src/link/NvPtx.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/link/Wasm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 54ec19b

Please sign in to comment.