authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-28 10:42:16+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-28 12:17:26+02:00
log5aff1d5d6fde5f95576cd639e6fa80281524e2d6
tree7051c0c161cf8e00c3fb0ee58c7195ae021d7ad3
parentb94787afd7e0b06c2daea76ca5a812962794ed00

zld: frameworks do not need dylib ext on older macs


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

src/link/MachO.zig+12-7
...@@ -584,24 +584,29 @@ fn resolveLib(...@@ -584,24 +584,29 @@ fn resolveLib(
584 // Look in each directory for a dylib (next, tbd), and then for archive584 // Look in each directory for a dylib (next, tbd), and then for archive
585 // TODO implement alternative: -search_dylibs_first585 // TODO implement alternative: -search_dylibs_first
586 const exts = switch (lib_kind) {586 const exts = switch (lib_kind) {
587 .lib => &[_][]const u8{ "dylib", "tbd", "a" },587 .lib => &[_]?[]const u8{ "dylib", "tbd", "a" },
588 .framework => &[_][]const u8{ "dylib", "tbd" },588 .framework => &[_]?[]const u8{ null, "dylib", "tbd" },
589 };589 };
590590
591 for (exts) |ext| {591 for (exts) |ext| {
592 const lib_name_ext = blk: {592 const lib_name_ext = if (ext) |some|
593 try std.fmt.allocPrint(arena, "{s}.{s}", .{ lib_name, some })
594 else
595 lib_name;
596 const with_prefix = blk: {
593 switch (lib_kind) {597 switch (lib_kind) {
594 .lib => break :blk try std.fmt.allocPrint(arena, "lib{s}.{s}", .{ lib_name, ext }),598 .lib => {
599 break :blk try std.fmt.allocPrint(arena, "lib{s}", .{lib_name_ext});
600 },
595 .framework => {601 .framework => {
596 const prefix = try std.fmt.allocPrint(arena, "{s}.framework", .{lib_name});602 const prefix = try std.fmt.allocPrint(arena, "{s}.framework", .{lib_name});
597 const nn = try std.fmt.allocPrint(arena, "{s}.{s}", .{ lib_name, ext });603 break :blk try fs.path.join(arena, &[_][]const u8{ prefix, lib_name_ext });
598 break :blk try fs.path.join(arena, &[_][]const u8{ prefix, nn });
599 },604 },
600 }605 }
601 };606 };
602607
603 for (lib_dirs) |dir| {608 for (lib_dirs) |dir| {
604 const full_path = try fs.path.join(arena, &[_][]const u8{ dir, lib_name_ext });609 const full_path = try fs.path.join(arena, &[_][]const u8{ dir, with_prefix });
605610
606 // Check if the lib file exists.611 // Check if the lib file exists.
607 const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) {612 const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) {