Commit c9352ef9d6

Andrew Kelley <andrew@ziglang.org>
2021-11-25 07:09:27
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.
1 parent 078a7ff
Changed files (1)
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),
-                });
-            },
-            .yes_default_path => {
-                fatal("unable to open directory 'docs': {s}", .{@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,
             },
-            .no => unreachable,
-        }
+            .dir = null,
+        },
     };
     defer emit_implib_resolved.deinit();