| ... | @@ -759,19 +759,21 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { | ... | @@ -759,19 +759,21 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 759 | } | 759 | } |
| 760 | } | 760 | } |
| 761 | | 761 | |
| | 762 | // Search for static libraries first, then dynamic libraries. |
| | 763 | // TODO Respect flags such as -search_paths_first to the linker. |
| 762 | // TODO text-based API, or .tbd files. | 764 | // TODO text-based API, or .tbd files. |
| 763 | const exts = &[_][]const u8{ "dylib", "a" }; | 765 | const exts = &[_][]const u8{ "a", "dylib" }; |
| 764 | | 766 | |
| 765 | for (search_lib_names.items) |l_name| { | 767 | for (search_lib_names.items) |l_name| { |
| 766 | var found = false; | 768 | var found = false; |
| 767 | | 769 | |
| 768 | for (exts) |ext| ext: { | 770 | ext: for (exts) |ext| { |
| 769 | const l_name_ext = try std.fmt.allocPrint(arena, "lib{s}.{s}", .{ l_name, ext }); | 771 | const l_name_ext = try std.fmt.allocPrint(arena, "lib{s}.{s}", .{ l_name, ext }); |
| 770 | | 772 | |
| 771 | for (search_lib_dirs.items) |lib_dir| { | 773 | for (search_lib_dirs.items) |lib_dir| { |
| 772 | const full_path = try fs.path.join(arena, &[_][]const u8{ lib_dir, l_name_ext }); | 774 | const full_path = try fs.path.join(arena, &[_][]const u8{ lib_dir, l_name_ext }); |
| 773 | | 775 | |
| 774 | // Check if the dylib file exists. | 776 | // Check if the lib file exists. |
| 775 | const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) { | 777 | const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) { |
| 776 | error.FileNotFound => continue, | 778 | error.FileNotFound => continue, |
| 777 | else => |e| return e, | 779 | else => |e| return e, |
| ... | @@ -2517,8 +2519,7 @@ fn allocatedSizeLinkedit(self: *MachO, start: u64) u64 { | ... | @@ -2517,8 +2519,7 @@ fn allocatedSizeLinkedit(self: *MachO, start: u64) u64 { |
| 2517 | | 2519 | |
| 2518 | return min_pos - start; | 2520 | return min_pos - start; |
| 2519 | } | 2521 | } |
| 2520 | | 2522 | fn checkForCollision(start: u64, end: u64, off: u64, size: u64) callconv(.Inline) ?u64 { |
| 2521 | inline fn checkForCollision(start: u64, end: u64, off: u64, size: u64) ?u64 { | | |
| 2522 | const increased_size = padToIdeal(size); | 2523 | const increased_size = padToIdeal(size); |
| 2523 | const test_end = off + increased_size; | 2524 | const test_end = off + increased_size; |
| 2524 | if (end > off and start < test_end) { | 2525 | if (end > off and start < test_end) { |