From 82047633281252aed14b44831e8920950f8c7dd6 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 15 Jun 2021 11:48:19 +0200 Subject: [PATCH] zld: use ld64 defaults for searching system libs By default, `ld64` uses `-search_paths_first` which firstly tries to find a dylib, followed by an archive in each directory. --- src/link/MachO.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 4de1708ff8..8c1d092f12 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -758,10 +758,11 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { } } - // Search for static libraries first, then dynamic libraries. - // TODO Respect flags such as -search_paths_first to the linker. + // Assume ld64 default: -search_paths_first + // Look in each directory for a dylib (tbd), and then for archive + // TODO implement alternative: -search_dylibs_first // TODO text-based API, or .tbd files. - const exts = &[_][]const u8{ "a", "dylib" }; + const exts = &[_][]const u8{ "dylib", "a" }; for (search_lib_names.items) |l_name| { var found = false;