From c9352ef9d6d9f1bca94c25710e11de0ae171605f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 24 Nov 2021 23:09:27 -0700 Subject: [PATCH] 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. --- src/main.zig | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main.zig b/src/main.zig index c2e7d293ec..87086bf874 100644 --- a/src/main.zig +++ b/src/main.zig @@ -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();