authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-01 20:30:34-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-03 09:52:14-07:00
loge477352af3fdd34e1ff1fb0d8167ba3f7333b3b9
tree07b18e77d276fe016c2fa13df1f2fd073ff57450
parentc65a06188173a4f1c911bfd44084a9dea57fe330

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


1 files changed, 25 insertions(+), 24 deletions(-)

src/main.zig+25-24
......@@ -2623,6 +2623,12 @@ fn buildOutputType(
26232623 name: []const u8,
26242624 info: SystemLib,
26252625 }) = .{};
2626
2627 var resolved_system_libs: std.MultiArrayList(struct {
2628 name: []const u8,
2629 lib: Compilation.SystemLib,
2630 }) = .{};
2631
26262632 for (system_libs.keys(), system_libs.values()) |lib_name, info| {
26272633 if (target_util.is_libc_lib_name(target_info.target, lib_name)) {
26282634 link_libc = true;
......@@ -2644,6 +2650,25 @@ fn buildOutputType(
26442650 },
26452651 }
26462652
2653 if (target_info.target.os.tag == .windows) {
2654 const exists = mingw.libExists(arena, target_info.target, zig_lib_directory, lib_name) catch |err| {
2655 fatal("failed to check zig installation for DLL import libs: {s}", .{
2656 @errorName(err),
2657 });
2658 };
2659 if (exists) {
2660 try resolved_system_libs.append(arena, .{
2661 .name = lib_name,
2662 .lib = .{
2663 .needed = true,
2664 .weak = false,
2665 .path = undefined,
2666 },
2667 });
2668 continue;
2669 }
2670 }
2671
26472672 if (fs.path.isAbsolute(lib_name)) {
26482673 fatal("cannot use absolute path as a system library: {s}", .{lib_name});
26492674 }
......@@ -2715,11 +2740,6 @@ fn buildOutputType(
27152740 // existence via flags instead.
27162741 // Similarly, if any libs in this list are statically provided, we omit
27172742 // them from the resolved list and populate the link_objects array instead.
2718 var resolved_system_libs: std.MultiArrayList(struct {
2719 name: []const u8,
2720 lib: Compilation.SystemLib,
2721 }) = .{};
2722
27232743 {
27242744 var test_path = std.ArrayList(u8).init(gpa);
27252745 defer test_path.deinit();
......@@ -2735,25 +2755,6 @@ fn buildOutputType(
27352755 }).init(arena);
27362756
27372757 syslib: for (external_system_libs.items(.name), external_system_libs.items(.info)) |lib_name, info| {
2738 if (target_info.target.os.tag == .windows) {
2739 const exists = mingw.libExists(arena, target_info.target, zig_lib_directory, lib_name) catch |err| {
2740 fatal("failed to check zig installation for DLL import libs: {s}", .{
2741 @errorName(err),
2742 });
2743 };
2744 if (exists) {
2745 try resolved_system_libs.append(arena, .{
2746 .name = lib_name,
2747 .lib = .{
2748 .needed = true,
2749 .weak = false,
2750 .path = undefined,
2751 },
2752 });
2753 continue;
2754 }
2755 }
2756
27572758 // Checked in the first pass above while looking for libc libraries.
27582759 assert(!fs.path.isAbsolute(lib_name));
27592760