mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
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.
This commit is contained in:
parent
080e870a71
commit
ba127058d1
1 changed files with 19 additions and 0 deletions
19
src/main.zig
19
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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue