diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-08-01 20:30:34 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-08-03 09:52:14 -0700 |
| commit | e477352af3fdd34e1ff1fb0d8167ba3f7333b3b9 (patch) | |
| tree | 07b18e77d276fe016c2fa13df1f2fd073ff57450 /src/main.zig | |
| parent | c65a06188173a4f1c911bfd44084a9dea57fe330 (diff) | |
| download | zig-e477352af3fdd34e1ff1fb0d8167ba3f7333b3b9.tar.gz zig-e477352af3fdd34e1ff1fb0d8167ba3f7333b3b9.zip | |
CLI: Windows: system DLLs no longer trigger native paths detection
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/main.zig b/src/main.zig index f05c141af6..bd306fa49e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2623,6 +2623,12 @@ fn buildOutputType( name: []const u8, info: SystemLib, }) = .{}; + + var resolved_system_libs: std.MultiArrayList(struct { + name: []const u8, + lib: Compilation.SystemLib, + }) = .{}; + for (system_libs.keys(), system_libs.values()) |lib_name, info| { if (target_util.is_libc_lib_name(target_info.target, lib_name)) { link_libc = true; @@ -2644,6 +2650,25 @@ fn buildOutputType( }, } + if (target_info.target.os.tag == .windows) { + const exists = mingw.libExists(arena, target_info.target, zig_lib_directory, lib_name) catch |err| { + fatal("failed to check zig installation for DLL import libs: {s}", .{ + @errorName(err), + }); + }; + if (exists) { + try resolved_system_libs.append(arena, .{ + .name = lib_name, + .lib = .{ + .needed = true, + .weak = false, + .path = undefined, + }, + }); + continue; + } + } + if (fs.path.isAbsolute(lib_name)) { fatal("cannot use absolute path as a system library: {s}", .{lib_name}); } @@ -2715,11 +2740,6 @@ fn buildOutputType( // existence via flags instead. // Similarly, if any libs in this list are statically provided, we omit // them from the resolved list and populate the link_objects array instead. - var resolved_system_libs: std.MultiArrayList(struct { - name: []const u8, - lib: Compilation.SystemLib, - }) = .{}; - { var test_path = std.ArrayList(u8).init(gpa); defer test_path.deinit(); @@ -2735,25 +2755,6 @@ fn buildOutputType( }).init(arena); syslib: for (external_system_libs.items(.name), external_system_libs.items(.info)) |lib_name, info| { - if (target_info.target.os.tag == .windows) { - const exists = mingw.libExists(arena, target_info.target, zig_lib_directory, lib_name) catch |err| { - fatal("failed to check zig installation for DLL import libs: {s}", .{ - @errorName(err), - }); - }; - if (exists) { - try resolved_system_libs.append(arena, .{ - .name = lib_name, - .lib = .{ - .needed = true, - .weak = false, - .path = undefined, - }, - }); - continue; - } - } - // Checked in the first pass above while looking for libc libraries. assert(!fs.path.isAbsolute(lib_name)); |
