aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-05-04 19:15:31 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-05-04 19:15:31 -0700
commitba127058d1fcf3ca042794244eee052915998b1a (patch)
tree6656d5e03d77e22aef099379174cd9e798a71e2f /src/main.zig
parent080e870a717124204cbfa58a1f29061a701b0362 (diff)
downloadzig-ba127058d1fcf3ca042794244eee052915998b1a.tar.gz
zig-ba127058d1fcf3ca042794244eee052915998b1a.zip
CLI: detect MinGW-flavored static libraries
Ideally on Windows, static libraries look like "foo.lib". However, CMake and other build systems will unfortunately produce static libraries that instead look like "libfoo.a". This patch makes Zig's CLI resolve "-lfoo" arguments into static libraries that match this other pattern. This patch fixes an issue with zig-bootstrap where it won't find the LLVM, Clang, and LLD libraries.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index 4d69bd51c7..9487f2e962 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -2118,6 +2118,25 @@ fn buildOutputType(
continue :syslib;
}
+ // Unfortunately, in the case of MinGW we also need to look for `libfoo.a`.
+ if (target_info.target.isMinGW()) {
+ for (lib_dirs.items) |lib_dir_path| {
+ test_path.clearRetainingCapacity();
+ try test_path.writer().print("{s}" ++ sep ++ "lib{s}.a", .{
+ lib_dir_path, lib_name,
+ });
+ fs.cwd().access(test_path.items, .{}) catch |err| switch (err) {
+ error.FileNotFound => continue,
+ else => |e| fatal("unable to search for static library '{s}': {s}", .{
+ test_path.items, @errorName(e),
+ }),
+ };
+ try link_objects.append(.{ .path = try arena.dupe(u8, test_path.items) });
+ system_libs.orderedRemoveAt(i);
+ continue :syslib;
+ }
+ }
+
std.log.scoped(.cli).debug("depending on system for -l{s}", .{lib_name});
i += 1;