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(...@@ -2240,8 +2240,8 @@ fn resolveLibInput(
2240 }2240 }
22412241
2242 // In the case of OpenBSD, dynamic libraries are always versioned, without2242 // In the case of OpenBSD, dynamic libraries are always versioned, without
2243 // unversioned symlinks, so we need to look for the highest-versioned shared2243 // unversioned symlinks. OpenBSD patches LLD to select the highest-versioned
2244 // library.2244 // shared library, and this code is intended to match that upstream behavior.
2245 if (target.isOpenBSDLibC() and link_mode == .dynamic) versioned: {2245 if (target.isOpenBSDLibC() and link_mode == .dynamic) versioned: {
2246 const prefix = try std.fmt.allocPrint(arena, "lib{s}.so.", .{lib_name});2246 const prefix = try std.fmt.allocPrint(arena, "lib{s}.so.", .{lib_name});
22472247
...@@ -2251,11 +2251,8 @@ fn resolveLibInput(...@@ -2251,11 +2251,8 @@ fn resolveLibInput(
2251 };2251 };
2252 defer dir.close(io);2252 defer dir.close(io);
22532253
2254 var best_match_version = std.SemanticVersion{2254 var best_match_major: u32 = 0;
2255 .major = 0,2255 var best_match_minor: u32 = 0;
2256 .minor = 0,
2257 .patch = 0,
2258 };
2259 var best_match: ?[]const u8 = null;2256 var best_match: ?[]const u8 = null;
22602257
2261 var iter = dir.iterate();2258 var iter = dir.iterate();
...@@ -2270,12 +2267,12 @@ fn resolveLibInput(...@@ -2270,12 +2267,12 @@ fn resolveLibInput(
2270 const major_str = sit.next() orelse continue;2267 const major_str = sit.next() orelse continue;
2271 const minor_str = sit.next() orelse continue;2268 const minor_str = sit.next() orelse continue;
2272 if (sit.next() != null) continue;2269 if (sit.next() != null) continue;
2273 const major = std.fmt.parseInt(usize, major_str, 10) catch continue;2270 const major = std.fmt.parseInt(u32, major_str, 10) catch continue;
2274 const minor = std.fmt.parseInt(usize, minor_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)) {2273 if (major > best_match_major or (major == best_match_major and minor >= best_match_minor)) {
2277 best_match_version.major = major;2274 best_match_major = major;
2278 best_match_version.minor = minor;2275 best_match_minor = minor;
2279 best_match = try arena.dupe(u8, entry.name);2276 best_match = try arena.dupe(u8, entry.name);
2280 }2277 }
2281 }2278 }