Skip to content

Commit 2cfd33b

Browse files
Claudeclaude
andcommitted
Skip all linker work when --no-link is set
Move no_link_obj check to beginning of flushModuleInner to avoid all linking overhead including ZigObject flush and object parsing. When using -fllvm with --no-link, LLVM handles object emission directly so we don't need any linker operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 0cab656 commit 2cfd33b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/link/Elf.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,11 @@ fn flushModuleInner(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id) !void {
839839
const gpa = comp.gpa;
840840
const diags = &comp.link_diags;
841841

842+
// Skip linking entirely if --no-link flag is set
843+
if (comp.no_link_obj) {
844+
return;
845+
}
846+
842847
const module_obj_path: ?Path = if (self.base.zcu_object_sub_path) |path| .{
843848
.root_dir = self.base.emit.root_dir,
844849
.sub_path = if (fs.path.dirname(self.base.emit.sub_path)) |dirname|
@@ -849,11 +854,6 @@ fn flushModuleInner(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id) !void {
849854

850855
if (self.zigObjectPtr()) |zig_object| try zig_object.flush(self, tid);
851856

852-
// Skip linking if --no-link flag is set (after ZigObject flush, before parsing objects)
853-
if (comp.no_link_obj) {
854-
return;
855-
}
856-
857857
// Parse LLVM-generated object file(s)
858858
if (module_obj_path) |path| {
859859
const partition_count = self.base.zcu_object_partition_count;

0 commit comments

Comments
 (0)