authorgravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2026-07-30 17:48:35+02:00
committergravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2026-07-30 17:48:35+02:00
logd3f6408a418e459a0b0f77d63e05e311c4ea71e8
tree77f287fc48ef1171a75eda320f752f53adfcf3d2
parent7ad63f2e5bf3d93e27a5233dcdcc341a5df1ebbe
signaturelock-open Commit is signed but in an unrecognized format.

link: simplify OpenBSD versioned shlib search

And add a bit more detail about the intent in the comment.

1 files changed, 9 insertions(+), 12 deletions(-)

src/link.zig+9-12
......@@ -2240,8 +2240,8 @@ fn resolveLibInput(
22402240 }
22412241
22422242 // In the case of OpenBSD, dynamic libraries are always versioned, without
2243 // unversioned symlinks, so we need to look for the highest-versioned shared
2244 // library.
2243 // unversioned symlinks. OpenBSD patches LLD to select the highest-versioned
2244 // shared library, and this code is intended to match that upstream behavior.
22452245 if (target.isOpenBSDLibC() and link_mode == .dynamic) versioned: {
22462246 const prefix = try std.fmt.allocPrint(arena, "lib{s}.so.", .{lib_name});
22472247
......@@ -2251,11 +2251,8 @@ fn resolveLibInput(
22512251 };
22522252 defer dir.close(io);
22532253
2254 var best_match_version = std.SemanticVersion{
2255 .major = 0,
2256 .minor = 0,
2257 .patch = 0,
2258 };
2254 var best_match_major: u32 = 0;
2255 var best_match_minor: u32 = 0;
22592256 var best_match: ?[]const u8 = null;
22602257
22612258 var iter = dir.iterate();
......@@ -2270,12 +2267,12 @@ fn resolveLibInput(
22702267 const major_str = sit.next() orelse continue;
22712268 const minor_str = sit.next() orelse continue;
22722269 if (sit.next() != null) continue;
2273 const major = std.fmt.parseInt(usize, major_str, 10) catch continue;
2274 const minor = std.fmt.parseInt(usize, minor_str, 10) catch continue;
2270 const major = std.fmt.parseInt(u32, major_str, 10) catch continue;
2271 const minor = std.fmt.parseInt(u32, minor_str, 10) catch continue;
22752272
2276 if (major > best_match_version.major or (major == best_match_version.major and minor >= best_match_version.minor)) {
2277 best_match_version.major = major;
2278 best_match_version.minor = minor;
2273 if (major > best_match_major or (major == best_match_major and minor >= best_match_minor)) {
2274 best_match_major = major;
2275 best_match_minor = minor;
22792276 best_match = try arena.dupe(u8, entry.name);
22802277 }
22812278 }