@@ -306,6 +306,7 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
306
306
return jitCmd (gpa , arena , cmd_args , .{
307
307
.cmd_name = "resinator" ,
308
308
.root_src_path = "resinator/main.zig" ,
309
+ .windows_libs = &.{"advapi32" },
309
310
.depend_on_aro = true ,
310
311
.prepend_zig_lib_dir_path = true ,
311
312
.server = use_server ,
@@ -3631,7 +3632,6 @@ fn buildOutputType(
3631
3632
} else if (target .os .tag == .windows ) {
3632
3633
try test_exec_args .appendSlice (arena , &.{
3633
3634
"--subsystem" , "console" ,
3634
- "-lkernel32" , "-lntdll" ,
3635
3635
});
3636
3636
}
3637
3637
@@ -3845,7 +3845,8 @@ fn createModule(
3845
3845
.only_compiler_rt = > continue ,
3846
3846
}
3847
3847
3848
- if (target .isMinGW ()) {
3848
+ // We currently prefer import libraries provided by MinGW-w64 even for MSVC.
3849
+ if (target .os .tag == .windows ) {
3849
3850
const exists = mingw .libExists (arena , target , create_module .dirs .zig_lib , lib_name ) catch | err | {
3850
3851
fatal ("failed to check zig installation for DLL import libs: {s}" , .{
3851
3852
@errorName (err ),
@@ -5221,6 +5222,12 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
5221
5222
5222
5223
try root_mod .deps .put (arena , "@build" , build_mod );
5223
5224
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
+
5224
5231
const comp = Compilation .create (gpa , arena , .{
5225
5232
.dirs = dirs ,
5226
5233
.root_name = "build" ,
@@ -5242,6 +5249,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
5242
5249
.cache_mode = .whole ,
5243
5250
.reference_trace = reference_trace ,
5244
5251
.debug_compile_errors = debug_compile_errors ,
5252
+ .windows_lib_names = windows_libs .keys (),
5245
5253
}) catch | err | {
5246
5254
fatal ("unable to create compilation: {s}" , .{@errorName (err )});
5247
5255
};
@@ -5345,6 +5353,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
5345
5353
const JitCmdOptions = struct {
5346
5354
cmd_name : []const u8 ,
5347
5355
root_src_path : []const u8 ,
5356
+ windows_libs : []const []const u8 = &.{},
5348
5357
prepend_zig_lib_dir_path : bool = false ,
5349
5358
prepend_global_cache_path : bool = false ,
5350
5359
prepend_zig_exe_path : bool = false ,
@@ -5461,6 +5470,13 @@ fn jitCmd(
5461
5470
try root_mod .deps .put (arena , "aro" , aro_mod );
5462
5471
}
5463
5472
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
+
5464
5480
const comp = Compilation .create (gpa , arena , .{
5465
5481
.dirs = dirs ,
5466
5482
.root_name = options .cmd_name ,
@@ -5471,6 +5487,7 @@ fn jitCmd(
5471
5487
.self_exe_path = self_exe_path ,
5472
5488
.thread_pool = & thread_pool ,
5473
5489
.cache_mode = .whole ,
5490
+ .windows_lib_names = windows_libs .keys (),
5474
5491
}) catch | err | {
5475
5492
fatal ("unable to create compilation: {s}" , .{@errorName (err )});
5476
5493
};
0 commit comments