authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-05 22:32:35+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-06 06:15:13+02:00
log7ee6dab39fac7aa12fa9fd952bb2bdc28d5eabe8
treeb97957e62077e78f6bf49836babcdb84b4ff772f
parent9a158c1dae531f2a4e5667569bed38c27cbd4d57

Revert "Sema: Stop adding Windows implib link inputs for `extern "..."` syntax."

This reverts commit b461d07a5464aec86c533434dab0b58edfffb331. After some discussion in the team, we've decided that this is too disruptive, especially because the linker errors are less than helpful. That's a fixable problem, so we might reconsider this in the future, but revert it for now.

10 files changed, 46 insertions(+), 78 deletions(-)

build.zig-20
...@@ -452,7 +452,6 @@ pub fn build(b: *std.Build) !void {...@@ -452,7 +452,6 @@ pub fn build(b: *std.Build) !void {
452 .desc = "Run the behavior tests",452 .desc = "Run the behavior tests",
453 .optimize_modes = optimization_modes,453 .optimize_modes = optimization_modes,
454 .include_paths = &.{},454 .include_paths = &.{},
455 .windows_libs = &.{},
456 .skip_single_threaded = skip_single_threaded,455 .skip_single_threaded = skip_single_threaded,
457 .skip_non_native = skip_non_native,456 .skip_non_native = skip_non_native,
458 .skip_freebsd = skip_freebsd,457 .skip_freebsd = skip_freebsd,
...@@ -475,7 +474,6 @@ pub fn build(b: *std.Build) !void {...@@ -475,7 +474,6 @@ pub fn build(b: *std.Build) !void {
475 .desc = "Run the @cImport tests",474 .desc = "Run the @cImport tests",
476 .optimize_modes = optimization_modes,475 .optimize_modes = optimization_modes,
477 .include_paths = &.{"test/c_import"},476 .include_paths = &.{"test/c_import"},
478 .windows_libs = &.{},
479 .skip_single_threaded = true,477 .skip_single_threaded = true,
480 .skip_non_native = skip_non_native,478 .skip_non_native = skip_non_native,
481 .skip_freebsd = skip_freebsd,479 .skip_freebsd = skip_freebsd,
...@@ -496,7 +494,6 @@ pub fn build(b: *std.Build) !void {...@@ -496,7 +494,6 @@ pub fn build(b: *std.Build) !void {
496 .desc = "Run the compiler_rt tests",494 .desc = "Run the compiler_rt tests",
497 .optimize_modes = optimization_modes,495 .optimize_modes = optimization_modes,
498 .include_paths = &.{},496 .include_paths = &.{},
499 .windows_libs = &.{},
500 .skip_single_threaded = true,497 .skip_single_threaded = true,
501 .skip_non_native = skip_non_native,498 .skip_non_native = skip_non_native,
502 .skip_freebsd = skip_freebsd,499 .skip_freebsd = skip_freebsd,
...@@ -518,7 +515,6 @@ pub fn build(b: *std.Build) !void {...@@ -518,7 +515,6 @@ pub fn build(b: *std.Build) !void {
518 .desc = "Run the zigc tests",515 .desc = "Run the zigc tests",
519 .optimize_modes = optimization_modes,516 .optimize_modes = optimization_modes,
520 .include_paths = &.{},517 .include_paths = &.{},
521 .windows_libs = &.{},
522 .skip_single_threaded = true,518 .skip_single_threaded = true,
523 .skip_non_native = skip_non_native,519 .skip_non_native = skip_non_native,
524 .skip_freebsd = skip_freebsd,520 .skip_freebsd = skip_freebsd,
...@@ -540,12 +536,6 @@ pub fn build(b: *std.Build) !void {...@@ -540,12 +536,6 @@ pub fn build(b: *std.Build) !void {
540 .desc = "Run the standard library tests",536 .desc = "Run the standard library tests",
541 .optimize_modes = optimization_modes,537 .optimize_modes = optimization_modes,
542 .include_paths = &.{},538 .include_paths = &.{},
543 .windows_libs = &.{
544 "advapi32",
545 "crypt32",
546 "iphlpapi",
547 "ws2_32",
548 },
549 .skip_single_threaded = skip_single_threaded,539 .skip_single_threaded = skip_single_threaded,
550 .skip_non_native = skip_non_native,540 .skip_non_native = skip_non_native,
551 .skip_freebsd = skip_freebsd,541 .skip_freebsd = skip_freebsd,
...@@ -743,12 +733,6 @@ fn addCompilerMod(b: *std.Build, options: AddCompilerModOptions) *std.Build.Modu...@@ -743,12 +733,6 @@ fn addCompilerMod(b: *std.Build, options: AddCompilerModOptions) *std.Build.Modu
743 compiler_mod.addImport("aro", aro_mod);733 compiler_mod.addImport("aro", aro_mod);
744 compiler_mod.addImport("aro_translate_c", aro_translate_c_mod);734 compiler_mod.addImport("aro_translate_c", aro_translate_c_mod);
745735
746 if (options.target.result.os.tag == .windows) {
747 compiler_mod.linkSystemLibrary("advapi32", .{});
748 compiler_mod.linkSystemLibrary("crypt32", .{});
749 compiler_mod.linkSystemLibrary("ws2_32", .{});
750 }
751
752 return compiler_mod;736 return compiler_mod;
753}737}
754738
...@@ -1446,10 +1430,6 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {...@@ -1446,10 +1430,6 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {
1446 }),1430 }),
1447 });1431 });
14481432
1449 if (b.graph.host.result.os.tag == .windows) {
1450 doctest_exe.root_module.linkSystemLibrary("advapi32", .{});
1451 }
1452
1453 var dir = b.build_root.handle.openDir("doc/langref", .{ .iterate = true }) catch |err| {1433 var dir = b.build_root.handle.openDir("doc/langref", .{ .iterate = true }) catch |err| {
1454 std.debug.panic("unable to open '{f}doc/langref' directory: {s}", .{1434 std.debug.panic("unable to open '{f}doc/langref' directory: {s}", .{
1455 b.build_root, @errorName(err),1435 b.build_root, @errorName(err),
src/Compilation.zig+29-10
...@@ -2185,8 +2185,12 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -2185,8 +2185,12 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
2185 .emit_docs = try options.emit_docs.resolve(arena, &options, .docs),2185 .emit_docs = try options.emit_docs.resolve(arena, &options, .docs),
2186 };2186 };
21872187
2188 comp.windows_libs = try std.StringArrayHashMapUnmanaged(void).init(gpa, options.windows_lib_names, &.{});2188 errdefer {
2189 errdefer comp.windows_libs.deinit(gpa);2189 for (comp.windows_libs.keys()) |windows_lib| gpa.free(windows_lib);
2190 comp.windows_libs.deinit(gpa);
2191 }
2192 try comp.windows_libs.ensureUnusedCapacity(gpa, options.windows_lib_names.len);
2193 for (options.windows_lib_names) |windows_lib| comp.windows_libs.putAssumeCapacity(try gpa.dupe(u8, windows_lib), {});
21902194
2191 // Prevent some footguns by making the "any" fields of config reflect2195 // Prevent some footguns by making the "any" fields of config reflect
2192 // the default Module settings.2196 // the default Module settings.
...@@ -2417,13 +2421,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -2417,13 +2421,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
24172421
2418 if (comp.emit_bin != null and target.ofmt != .c) {2422 if (comp.emit_bin != null and target.ofmt != .c) {
2419 if (!comp.skip_linker_dependencies) {2423 if (!comp.skip_linker_dependencies) {
2420 // These DLLs are always loaded into every Windows process.
2421 if (target.os.tag == .windows and is_exe_or_dyn_lib) {
2422 try comp.windows_libs.ensureUnusedCapacity(gpa, 2);
2423 comp.windows_libs.putAssumeCapacity("kernel32", {});
2424 comp.windows_libs.putAssumeCapacity("ntdll", {});
2425 }
2426
2427 // If we need to build libc for the target, add work items for it.2424 // If we need to build libc for the target, add work items for it.
2428 // We go through the work queue so that building can be done in parallel.2425 // We go through the work queue so that building can be done in parallel.
2429 // If linking against host libc installation, instead queue up jobs2426 // If linking against host libc installation, instead queue up jobs
...@@ -2512,7 +2509,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -2512,7 +2509,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
25122509
2513 // When linking mingw-w64 there are some import libs we always need.2510 // When linking mingw-w64 there are some import libs we always need.
2514 try comp.windows_libs.ensureUnusedCapacity(gpa, mingw.always_link_libs.len);2511 try comp.windows_libs.ensureUnusedCapacity(gpa, mingw.always_link_libs.len);
2515 for (mingw.always_link_libs) |name| comp.windows_libs.putAssumeCapacity(name, {});2512 for (mingw.always_link_libs) |name| comp.windows_libs.putAssumeCapacity(try gpa.dupe(u8, name), {});
2516 } else {2513 } else {
2517 return error.LibCUnavailable;2514 return error.LibCUnavailable;
2518 }2515 }
...@@ -2610,6 +2607,7 @@ pub fn destroy(comp: *Compilation) void {...@@ -2610,6 +2607,7 @@ pub fn destroy(comp: *Compilation) void {
2610 comp.c_object_work_queue.deinit();2607 comp.c_object_work_queue.deinit();
2611 comp.win32_resource_work_queue.deinit();2608 comp.win32_resource_work_queue.deinit();
26122609
2610 for (comp.windows_libs.keys()) |windows_lib| gpa.free(windows_lib);
2613 comp.windows_libs.deinit(gpa);2611 comp.windows_libs.deinit(gpa);
26142612
2615 {2613 {
...@@ -7795,6 +7793,27 @@ fn getCrtPathsInner(...@@ -7795,6 +7793,27 @@ fn getCrtPathsInner(
7795 };7793 };
7796}7794}
77977795
7796pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {
7797 // Avoid deadlocking on building import libs such as kernel32.lib
7798 // This can happen when the user uses `build-exe foo.obj -lkernel32` and
7799 // then when we create a sub-Compilation for zig libc, it also tries to
7800 // build kernel32.lib.
7801 if (comp.skip_linker_dependencies) return;
7802 const target = &comp.root_mod.resolved_target.result;
7803 if (target.os.tag != .windows or target.ofmt == .c) return;
7804
7805 // This happens when an `extern "foo"` function is referenced.
7806 // If we haven't seen this library yet and we're targeting Windows, we need
7807 // to queue up a work item to produce the DLL import library for this.
7808 const gop = try comp.windows_libs.getOrPut(comp.gpa, lib_name);
7809 if (gop.found_existing) return;
7810 {
7811 errdefer _ = comp.windows_libs.pop();
7812 gop.key_ptr.* = try comp.gpa.dupe(u8, lib_name);
7813 }
7814 try comp.queueJob(.{ .windows_import_lib = gop.index });
7815}
7816
7798/// This decides the optimization mode for all zig-provided libraries, including7817/// This decides the optimization mode for all zig-provided libraries, including
7799/// compiler-rt, libcxx, libc, libunwind, etc.7818/// compiler-rt, libcxx, libc, libunwind, etc.
7800pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode {7819pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode {
src/Sema.zig+13
...@@ -8906,6 +8906,14 @@ fn resolveGenericBody(...@@ -8906,6 +8906,14 @@ fn resolveGenericBody(
8906 return sema.resolveConstDefinedValue(block, src, result, reason);8906 return sema.resolveConstDefinedValue(block, src, result, reason);
8907}8907}
89088908
8909/// Given a library name, examines if the library name should end up in
8910/// `link.File.Options.windows_libs` table (for example, libc is always
8911/// specified via dedicated flag `link_libc` instead),
8912/// and puts it there if it doesn't exist.
8913/// It also dupes the library name which can then be saved as part of the
8914/// respective `Decl` (either `ExternFn` or `Var`).
8915/// The liveness of the duped library name is tied to liveness of `Zcu`.
8916/// To deallocate, call `deinit` on the respective `Decl` (`ExternFn` or `Var`).
8909pub fn handleExternLibName(8917pub fn handleExternLibName(
8910 sema: *Sema,8918 sema: *Sema,
8911 block: *Block,8919 block: *Block,
...@@ -8955,6 +8963,11 @@ pub fn handleExternLibName(...@@ -8955,6 +8963,11 @@ pub fn handleExternLibName(
8955 .{ lib_name, lib_name },8963 .{ lib_name, lib_name },
8956 );8964 );
8957 }8965 }
8966 comp.addLinkLib(lib_name) catch |err| {
8967 return sema.fail(block, src_loc, "unable to add link lib '{s}': {s}", .{
8968 lib_name, @errorName(err),
8969 });
8970 };
8958 }8971 }
8959}8972}
89608973
src/libs/mingw.zig+2-1
...@@ -1012,7 +1012,6 @@ const mingw32_winpthreads_src = [_][]const u8{...@@ -1012,7 +1012,6 @@ const mingw32_winpthreads_src = [_][]const u8{
1012 "winpthreads" ++ path.sep_str ++ "thread.c",1012 "winpthreads" ++ path.sep_str ++ "thread.c",
1013};1013};
10141014
1015// Note: kernel32 and ntdll are always linked even without targeting MinGW-w64.
1016pub const always_link_libs = [_][]const u8{1015pub const always_link_libs = [_][]const u8{
1017 "api-ms-win-crt-conio-l1-1-0",1016 "api-ms-win-crt-conio-l1-1-0",
1018 "api-ms-win-crt-convert-l1-1-0",1017 "api-ms-win-crt-convert-l1-1-0",
...@@ -1030,6 +1029,8 @@ pub const always_link_libs = [_][]const u8{...@@ -1030,6 +1029,8 @@ pub const always_link_libs = [_][]const u8{
1030 "api-ms-win-crt-time-l1-1-0",1029 "api-ms-win-crt-time-l1-1-0",
1031 "api-ms-win-crt-utility-l1-1-0",1030 "api-ms-win-crt-utility-l1-1-0",
1032 "advapi32",1031 "advapi32",
1032 "kernel32",
1033 "ntdll",
1033 "shell32",1034 "shell32",
1034 "user32",1035 "user32",
1035};1036};
src/main.zig+2-22
...@@ -312,7 +312,6 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -312,7 +312,6 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
312 return jitCmd(gpa, arena, cmd_args, .{312 return jitCmd(gpa, arena, cmd_args, .{
313 .cmd_name = "resinator",313 .cmd_name = "resinator",
314 .root_src_path = "resinator/main.zig",314 .root_src_path = "resinator/main.zig",
315 .windows_libs = &.{"advapi32"},
316 .depend_on_aro = true,315 .depend_on_aro = true,
317 .prepend_zig_lib_dir_path = true,316 .prepend_zig_lib_dir_path = true,
318 .server = use_server,317 .server = use_server,
...@@ -337,7 +336,6 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -337,7 +336,6 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
337 return jitCmd(gpa, arena, cmd_args, .{336 return jitCmd(gpa, arena, cmd_args, .{
338 .cmd_name = "std",337 .cmd_name = "std",
339 .root_src_path = "std-docs.zig",338 .root_src_path = "std-docs.zig",
340 .windows_libs = &.{"ws2_32"},
341 .prepend_zig_lib_dir_path = true,339 .prepend_zig_lib_dir_path = true,
342 .prepend_zig_exe_path = true,340 .prepend_zig_exe_path = true,
343 .prepend_global_cache_path = true,341 .prepend_global_cache_path = true,
...@@ -3659,6 +3657,7 @@ fn buildOutputType(...@@ -3659,6 +3657,7 @@ fn buildOutputType(
3659 } else if (target.os.tag == .windows) {3657 } else if (target.os.tag == .windows) {
3660 try test_exec_args.appendSlice(arena, &.{3658 try test_exec_args.appendSlice(arena, &.{
3661 "--subsystem", "console",3659 "--subsystem", "console",
3660 "-lkernel32", "-lntdll",
3662 });3661 });
3663 }3662 }
36643663
...@@ -3862,8 +3861,7 @@ fn createModule(...@@ -3862,8 +3861,7 @@ fn createModule(
3862 .only_compiler_rt => continue,3861 .only_compiler_rt => continue,
3863 }3862 }
38643863
3865 // We currently prefer import libraries provided by MinGW-w64 even for MSVC.3864 if (target.isMinGW()) {
3866 if (target.os.tag == .windows) {
3867 const exists = mingw.libExists(arena, target, create_module.dirs.zig_lib, lib_name) catch |err| {3865 const exists = mingw.libExists(arena, target, create_module.dirs.zig_lib, lib_name) catch |err| {
3868 fatal("failed to check zig installation for DLL import libs: {s}", .{3866 fatal("failed to check zig installation for DLL import libs: {s}", .{
3869 @errorName(err),3867 @errorName(err),
...@@ -5375,14 +5373,6 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -5375,14 +5373,6 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
53755373
5376 try root_mod.deps.put(arena, "@build", build_mod);5374 try root_mod.deps.put(arena, "@build", build_mod);
53775375
5378 var windows_libs: std.StringArrayHashMapUnmanaged(void) = .empty;
5379
5380 if (resolved_target.result.os.tag == .windows) {
5381 try windows_libs.ensureUnusedCapacity(arena, 2);
5382 windows_libs.putAssumeCapacity("advapi32", {});
5383 windows_libs.putAssumeCapacity("ws2_32", {}); // for `--listen` (web interface)
5384 }
5385
5386 const comp = Compilation.create(gpa, arena, .{5376 const comp = Compilation.create(gpa, arena, .{
5387 .libc_installation = libc_installation,5377 .libc_installation = libc_installation,
5388 .dirs = dirs,5378 .dirs = dirs,
...@@ -5405,7 +5395,6 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -5405,7 +5395,6 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
5405 .cache_mode = .whole,5395 .cache_mode = .whole,
5406 .reference_trace = reference_trace,5396 .reference_trace = reference_trace,
5407 .debug_compile_errors = debug_compile_errors,5397 .debug_compile_errors = debug_compile_errors,
5408 .windows_lib_names = windows_libs.keys(),
5409 }) catch |err| {5398 }) catch |err| {
5410 fatal("unable to create compilation: {s}", .{@errorName(err)});5399 fatal("unable to create compilation: {s}", .{@errorName(err)});
5411 };5400 };
...@@ -5509,7 +5498,6 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -5509,7 +5498,6 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
5509const JitCmdOptions = struct {5498const JitCmdOptions = struct {
5510 cmd_name: []const u8,5499 cmd_name: []const u8,
5511 root_src_path: []const u8,5500 root_src_path: []const u8,
5512 windows_libs: []const []const u8 = &.{},
5513 prepend_zig_lib_dir_path: bool = false,5501 prepend_zig_lib_dir_path: bool = false,
5514 prepend_global_cache_path: bool = false,5502 prepend_global_cache_path: bool = false,
5515 prepend_zig_exe_path: bool = false,5503 prepend_zig_exe_path: bool = false,
...@@ -5626,13 +5614,6 @@ fn jitCmd(...@@ -5626,13 +5614,6 @@ fn jitCmd(
5626 try root_mod.deps.put(arena, "aro", aro_mod);5614 try root_mod.deps.put(arena, "aro", aro_mod);
5627 }5615 }
56285616
5629 var windows_libs: std.StringArrayHashMapUnmanaged(void) = .empty;
5630
5631 if (resolved_target.result.os.tag == .windows) {
5632 try windows_libs.ensureUnusedCapacity(arena, options.windows_libs.len);
5633 for (options.windows_libs) |lib| windows_libs.putAssumeCapacity(lib, {});
5634 }
5635
5636 const comp = Compilation.create(gpa, arena, .{5617 const comp = Compilation.create(gpa, arena, .{
5637 .dirs = dirs,5618 .dirs = dirs,
5638 .root_name = options.cmd_name,5619 .root_name = options.cmd_name,
...@@ -5643,7 +5624,6 @@ fn jitCmd(...@@ -5643,7 +5624,6 @@ fn jitCmd(
5643 .self_exe_path = self_exe_path,5624 .self_exe_path = self_exe_path,
5644 .thread_pool = &thread_pool,5625 .thread_pool = &thread_pool,
5645 .cache_mode = .whole,5626 .cache_mode = .whole,
5646 .windows_lib_names = windows_libs.keys(),
5647 }) catch |err| {5627 }) catch |err| {
5648 fatal("unable to create compilation: {s}", .{@errorName(err)});5628 fatal("unable to create compilation: {s}", .{@errorName(err)});
5649 };5629 };
test/standalone/simple/build.zig-8
...@@ -50,10 +50,6 @@ pub fn build(b: *std.Build) void {...@@ -50,10 +50,6 @@ pub fn build(b: *std.Build) void {
50 });50 });
51 if (case.link_libc) exe.root_module.link_libc = true;51 if (case.link_libc) exe.root_module.link_libc = true;
5252
53 if (resolved_target.result.os.tag == .windows) {
54 exe.root_module.linkSystemLibrary("advapi32", .{});
55 }
56
57 _ = exe.getEmittedBin();53 _ = exe.getEmittedBin();
5854
59 step.dependOn(&exe.step);55 step.dependOn(&exe.step);
...@@ -70,10 +66,6 @@ pub fn build(b: *std.Build) void {...@@ -70,10 +66,6 @@ pub fn build(b: *std.Build) void {
70 });66 });
71 if (case.link_libc) exe.root_module.link_libc = true;67 if (case.link_libc) exe.root_module.link_libc = true;
7268
73 if (resolved_target.result.os.tag == .windows) {
74 exe.root_module.linkSystemLibrary("advapi32", .{});
75 }
76
77 const run = b.addRunArtifact(exe);69 const run = b.addRunArtifact(exe);
78 step.dependOn(&run.step);70 step.dependOn(&run.step);
79 }71 }
test/standalone/windows_argv/build.zig-2
...@@ -47,8 +47,6 @@ pub fn build(b: *std.Build) !void {...@@ -47,8 +47,6 @@ pub fn build(b: *std.Build) !void {
47 }),47 }),
48 });48 });
4949
50 fuzz.root_module.linkSystemLibrary("advapi32", .{});
51
52 const fuzz_max_iterations = b.option(u64, "iterations", "The max fuzz iterations (default: 100)") orelse 100;50 const fuzz_max_iterations = b.option(u64, "iterations", "The max fuzz iterations (default: 100)") orelse 100;
53 const fuzz_iterations_arg = std.fmt.allocPrint(b.allocator, "{}", .{fuzz_max_iterations}) catch @panic("oom");51 const fuzz_iterations_arg = std.fmt.allocPrint(b.allocator, "{}", .{fuzz_max_iterations}) catch @panic("oom");
5452
test/standalone/windows_bat_args/build.zig-4
...@@ -28,8 +28,6 @@ pub fn build(b: *std.Build) !void {...@@ -28,8 +28,6 @@ pub fn build(b: *std.Build) !void {
28 }),28 }),
29 });29 });
3030
31 test_exe.root_module.linkSystemLibrary("advapi32", .{});
32
33 const run = b.addRunArtifact(test_exe);31 const run = b.addRunArtifact(test_exe);
34 run.addArtifactArg(echo_args);32 run.addArtifactArg(echo_args);
35 run.expectExitCode(0);33 run.expectExitCode(0);
...@@ -46,8 +44,6 @@ pub fn build(b: *std.Build) !void {...@@ -46,8 +44,6 @@ pub fn build(b: *std.Build) !void {
46 }),44 }),
47 });45 });
4846
49 fuzz.root_module.linkSystemLibrary("advapi32", .{});
50
51 const fuzz_max_iterations = b.option(u64, "iterations", "The max fuzz iterations (default: 100)") orelse 100;47 const fuzz_max_iterations = b.option(u64, "iterations", "The max fuzz iterations (default: 100)") orelse 100;
52 const fuzz_iterations_arg = std.fmt.allocPrint(b.allocator, "{}", .{fuzz_max_iterations}) catch @panic("oom");48 const fuzz_iterations_arg = std.fmt.allocPrint(b.allocator, "{}", .{fuzz_max_iterations}) catch @panic("oom");
5349
test/standalone/windows_spawn/build.zig-2
...@@ -28,8 +28,6 @@ pub fn build(b: *std.Build) void {...@@ -28,8 +28,6 @@ pub fn build(b: *std.Build) void {
28 }),28 }),
29 });29 });
3030
31 main.root_module.linkSystemLibrary("advapi32", .{});
32
33 const run = b.addRunArtifact(main);31 const run = b.addRunArtifact(main);
34 run.addArtifactArg(hello);32 run.addArtifactArg(hello);
35 run.expectExitCode(0);33 run.expectExitCode(0);
test/tests.zig-9
...@@ -2238,7 +2238,6 @@ const ModuleTestOptions = struct {...@@ -2238,7 +2238,6 @@ const ModuleTestOptions = struct {
2238 desc: []const u8,2238 desc: []const u8,
2239 optimize_modes: []const OptimizeMode,2239 optimize_modes: []const OptimizeMode,
2240 include_paths: []const []const u8,2240 include_paths: []const []const u8,
2241 windows_libs: []const []const u8,
2242 skip_single_threaded: bool,2241 skip_single_threaded: bool,
2243 skip_non_native: bool,2242 skip_non_native: bool,
2244 skip_freebsd: bool,2243 skip_freebsd: bool,
...@@ -2373,10 +2372,6 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -2373,10 +2372,6 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
23732372
2374 for (options.include_paths) |include_path| these_tests.root_module.addIncludePath(b.path(include_path));2373 for (options.include_paths) |include_path| these_tests.root_module.addIncludePath(b.path(include_path));
23752374
2376 if (target.os.tag == .windows) {
2377 for (options.windows_libs) |lib| these_tests.root_module.linkSystemLibrary(lib, .{});
2378 }
2379
2380 const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}{s}", .{2375 const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}{s}", .{
2381 options.name,2376 options.name,
2382 triple_txt,2377 triple_txt,
...@@ -2672,10 +2667,6 @@ pub fn addIncrementalTests(b: *std.Build, test_step: *Step) !void {...@@ -2672,10 +2667,6 @@ pub fn addIncrementalTests(b: *std.Build, test_step: *Step) !void {
2672 }),2667 }),
2673 });2668 });
26742669
2675 if (b.graph.host.result.os.tag == .windows) {
2676 incr_check.root_module.linkSystemLibrary("advapi32", .{});
2677 }
2678
2679 var dir = try b.build_root.handle.openDir("test/incremental", .{ .iterate = true });2670 var dir = try b.build_root.handle.openDir("test/incremental", .{ .iterate = true });
2680 defer dir.close();2671 defer dir.close();
26812672