Skip to content

Commit e15e70d

Browse files
committed
build: Disable default import library emission for .exe and MinGW .dll
Aligns with other compilers' behavior.
1 parent a18876e commit e15e70d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/main.zig

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3387,17 +3387,16 @@ fn buildOutputType(
33873387
.Lib => create_module.resolved_options.link_mode == .dynamic,
33883388
.Exe => true,
33893389
};
3390-
// Note that cmake when targeting Windows will try to execute
3391-
// zig cc to make an executable and output an implib too.
33923390
const implib_eligible = is_exe_or_dyn_lib and
33933391
emit_bin_loc != null and target.os.tag == .windows;
3394-
if (!implib_eligible) {
3395-
if (!emit_implib_arg_provided) {
3396-
emit_implib = .no;
3397-
} else if (emit_implib != .no) {
3392+
if (emit_implib_arg_provided) {
3393+
if (emit_implib != .no and !implib_eligible) {
33983394
fatal("the argument -femit-implib is allowed only when building a Windows DLL", .{});
33993395
}
3396+
} else if (!implib_eligible or target.abi.isGnu() or create_module.resolved_options.output_mode == .Exe) {
3397+
emit_implib = .no;
34003398
}
3399+
34013400
const default_implib_basename = if (target.abi.isGnu())
34023401
try std.fmt.allocPrint(arena, "lib{s}.dll.a", .{root_name})
34033402
else

0 commit comments

Comments
 (0)