----------------------------------------------- commit af40c03de86197db4cdd83bc54b039e3b83bc083 (build/stable, local) from: Sébastien Marie date: Thu Apr 15 08:22:55 2021 UTC openbsd: use crt for libs too diff ac9f86caa383b3632f3f51ae1412c54a4a687980 edeaa19171183988fc295571578317941f8b7b9b blob - f60a7423a2fef6ab9be14298e0e35f593279e5a1 blob + f78aa2f5adf0ae9000ac5c7c51ab160031bca1ec --- src/link/Elf.zig +++ src/link/Elf.zig @@ -1529,8 +1529,13 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { if (target_util.libc_needs_crti_crtn(target)) { try argv.append(try comp.get_libc_crt_file(arena, "crti.o")); } - if (target.os.tag == .openbsd) { + } + + if (target.os.tag == .openbsd and self.base.options.link_libc) { + if (self.base.options.output_mode == .Exe) { try argv.append(try comp.get_libc_crt_file(arena, "crtbegin.o")); + } else if (self.base.options.output_mode == .Lib) { + try argv.append(try comp.get_libc_crt_file(arena, "crtbeginS.o")); } } @@ -1688,12 +1693,17 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { if (link_in_crt) { if (target.isAndroid()) { try argv.append(try comp.get_libc_crt_file(arena, "crtend_android.o")); - } else if (target.os.tag == .openbsd) { - try argv.append(try comp.get_libc_crt_file(arena, "crtend.o")); } else if (target_util.libc_needs_crti_crtn(target)) { try argv.append(try comp.get_libc_crt_file(arena, "crtn.o")); } } + if (self.base.options.link_libc and target.os.tag == .openbsd) { + if (self.base.options.output_mode == .Exe) { + try argv.append(try comp.get_libc_crt_file(arena, "crtend.o")); + } else if (self.base.options.output_mode == .Lib) { + try argv.append(try comp.get_libc_crt_file(arena, "crtendS.o")); + } + } if (allow_shlib_undefined) { try argv.append("--allow-shlib-undefined");