stage2: fix logic for default -femit-implib path

Previously when using `--enable-cache` and creating a Windows DLL,
without overriding the `-femit-implib` option, Zig would incorrectly
dump the .lib file to the current working directory, rather than
outputting it into the artifact directory, next to the .dll file.

Fixed.
This commit is contained in:
Andrew Kelley 2021-11-24 23:09:27 -07:00
parent 078a7ff198
commit c9352ef9d6

View File

@ -2130,18 +2130,20 @@ fn buildOutputType(
}
}
const default_implib_basename = try std.fmt.allocPrint(arena, "{s}.lib", .{root_name});
var emit_implib_resolved = emit_implib.resolve(default_implib_basename) catch |err| {
switch (emit_implib) {
.yes => |p| {
fatal("unable to open directory from argument '-femit-implib', '{s}': {s}", .{
p, @errorName(err),
});
var emit_implib_resolved = switch (emit_implib) {
.no => Emit.Resolved{ .data = null, .dir = null },
.yes => |p| emit_implib.resolve(default_implib_basename) catch |err| {
fatal("unable to open directory from argument '-femit-implib', '{s}': {s}", .{
p, @errorName(err),
});
},
.yes_default_path => Emit.Resolved{
.data = Compilation.EmitLoc{
.directory = emit_bin_loc.?.directory,
.basename = default_implib_basename,
},
.yes_default_path => {
fatal("unable to open directory 'docs': {s}", .{@errorName(err)});
},
.no => unreachable,
}
.dir = null,
},
};
defer emit_implib_resolved.deinit();