CLI: Windows: system DLLs no longer trigger native paths detection

This commit is contained in:
Andrew Kelley 2023-08-01 20:30:34 -07:00
parent c65a061881
commit e477352af3

View file

@ -2623,6 +2623,12 @@ fn buildOutputType(
name: []const u8, name: []const u8,
info: SystemLib, 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| { for (system_libs.keys(), system_libs.values()) |lib_name, info| {
if (target_util.is_libc_lib_name(target_info.target, lib_name)) { if (target_util.is_libc_lib_name(target_info.target, lib_name)) {
link_libc = true; 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)) { if (fs.path.isAbsolute(lib_name)) {
fatal("cannot use absolute path as a system library: {s}", .{lib_name}); fatal("cannot use absolute path as a system library: {s}", .{lib_name});
} }
@ -2715,11 +2740,6 @@ fn buildOutputType(
// existence via flags instead. // existence via flags instead.
// Similarly, if any libs in this list are statically provided, we omit // Similarly, if any libs in this list are statically provided, we omit
// them from the resolved list and populate the link_objects array instead. // 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); var test_path = std.ArrayList(u8).init(gpa);
defer test_path.deinit(); defer test_path.deinit();
@ -2735,25 +2755,6 @@ fn buildOutputType(
}).init(arena); }).init(arena);
syslib: for (external_system_libs.items(.name), external_system_libs.items(.info)) |lib_name, info| { 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. // Checked in the first pass above while looking for libc libraries.
assert(!fs.path.isAbsolute(lib_name)); assert(!fs.path.isAbsolute(lib_name));