Skip to content

Commit 5493a46

Browse files
Claudeclaude
andcommitted
Write LLVM object to final path when using --no-link with LLD
When --no-link is set with -flld, emit LLVM object directly to final output path instead of intermediate path, since LLD won't run to copy/link it. Fixes empty .o file issue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent b17d0f2 commit 5493a46

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/link/Elf.zig

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,21 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod
817817
const diags = &comp.link_diags;
818818

819819
if (self.llvm_object) |llvm_object| {
820-
try self.base.emitLlvmObject(arena, llvm_object, prog_node);
821820
const use_lld = build_options.have_llvm and comp.config.use_lld;
821+
822+
// With --no-link, write LLVM object directly to final output path
823+
if (comp.no_link_obj and use_lld) {
824+
try comp.emitLlvmObject(arena, .{
825+
.root_dir = self.base.emit.root_dir,
826+
.sub_path = std.fs.path.dirname(self.base.emit.sub_path) orelse "",
827+
}, .{
828+
.directory = null,
829+
.basename = self.base.emit.sub_path,
830+
}, llvm_object, prog_node);
831+
} else {
832+
try self.base.emitLlvmObject(arena, llvm_object, prog_node);
833+
}
834+
822835
if (use_lld) return;
823836
}
824837

0 commit comments

Comments
 (0)