From e331e8171987a59a882c63e1156e7a3a8eb871a1 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 16 Oct 2024 14:47:34 -0700 Subject: [PATCH] link.Elf: refactor output mode checking --- src/link/Elf.zig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 59694c6ae9..74d7a6e643 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -790,8 +790,15 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod if (comp.verbose_link) try self.dumpArgv(comp); if (self.zigObjectPtr()) |zig_object| try zig_object.flush(self, tid); - if (self.base.isStaticLib()) return relocatable.flushStaticLib(self, comp, module_obj_path); - if (self.base.isObject()) return relocatable.flushObject(self, comp, module_obj_path); + + switch (comp.config.output_mode) { + .Obj => return relocatable.flushObject(self, comp, module_obj_path), + .Lib => switch (comp.config.link_mode) { + .dynamic => {}, + .static => return relocatable.flushStaticLib(self, comp, module_obj_path), + }, + .Exe => {}, + } const csu = try comp.getCrtPaths(arena);