@@ -306,6 +306,7 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
306306 return jitCmd (gpa , arena , cmd_args , .{
307307 .cmd_name = "resinator" ,
308308 .root_src_path = "resinator/main.zig" ,
309+ .windows_libs = &.{"advapi32" },
309310 .depend_on_aro = true ,
310311 .prepend_zig_lib_dir_path = true ,
311312 .server = use_server ,
@@ -3631,7 +3632,6 @@ fn buildOutputType(
36313632 } else if (target .os .tag == .windows ) {
36323633 try test_exec_args .appendSlice (arena , &.{
36333634 "--subsystem" , "console" ,
3634- "-lkernel32" , "-lntdll" ,
36353635 });
36363636 }
36373637
@@ -3845,7 +3845,8 @@ fn createModule(
38453845 .only_compiler_rt = > continue ,
38463846 }
38473847
3848- if (target .isMinGW ()) {
3848+ // We currently prefer import libraries provided by MinGW-w64 even for MSVC.
3849+ if (target .os .tag == .windows ) {
38493850 const exists = mingw .libExists (arena , target , create_module .dirs .zig_lib , lib_name ) catch | err | {
38503851 fatal ("failed to check zig installation for DLL import libs: {s}" , .{
38513852 @errorName (err ),
@@ -5221,6 +5222,12 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
52215222
52225223 try root_mod .deps .put (arena , "@build" , build_mod );
52235224
5225+ var windows_libs : std .StringArrayHashMapUnmanaged (void ) = .empty ;
5226+
5227+ if (resolved_target .result .os .tag == .windows ) {
5228+ try windows_libs .put (arena , "advapi32" , {});
5229+ }
5230+
52245231 const comp = Compilation .create (gpa , arena , .{
52255232 .dirs = dirs ,
52265233 .root_name = "build" ,
@@ -5242,6 +5249,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
52425249 .cache_mode = .whole ,
52435250 .reference_trace = reference_trace ,
52445251 .debug_compile_errors = debug_compile_errors ,
5252+ .windows_lib_names = windows_libs .keys (),
52455253 }) catch | err | {
52465254 fatal ("unable to create compilation: {s}" , .{@errorName (err )});
52475255 };
@@ -5345,6 +5353,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
53455353const JitCmdOptions = struct {
53465354 cmd_name : []const u8 ,
53475355 root_src_path : []const u8 ,
5356+ windows_libs : []const []const u8 = &.{},
53485357 prepend_zig_lib_dir_path : bool = false ,
53495358 prepend_global_cache_path : bool = false ,
53505359 prepend_zig_exe_path : bool = false ,
@@ -5461,6 +5470,13 @@ fn jitCmd(
54615470 try root_mod .deps .put (arena , "aro" , aro_mod );
54625471 }
54635472
5473+ var windows_libs : std .StringArrayHashMapUnmanaged (void ) = .empty ;
5474+
5475+ if (resolved_target .result .os .tag == .windows ) {
5476+ try windows_libs .ensureUnusedCapacity (arena , options .windows_libs .len );
5477+ for (options .windows_libs ) | lib | windows_libs .putAssumeCapacity (lib , {});
5478+ }
5479+
54645480 const comp = Compilation .create (gpa , arena , .{
54655481 .dirs = dirs ,
54665482 .root_name = options .cmd_name ,
@@ -5471,6 +5487,7 @@ fn jitCmd(
54715487 .self_exe_path = self_exe_path ,
54725488 .thread_pool = & thread_pool ,
54735489 .cache_mode = .whole ,
5490+ .windows_lib_names = windows_libs .keys (),
54745491 }) catch | err | {
54755492 fatal ("unable to create compilation: {s}" , .{@errorName (err )});
54765493 };
0 commit comments