@@ -364,10 +364,7 @@ pub const MiscTask = enum {
364364
365365 @"mingw-w64 crt2.o" ,
366366 @"mingw-w64 dllcrt2.o" ,
367- @"mingw-w64 mingw32.lib" ,
368- @"mingw-w64 msvcrt-os.lib" ,
369- @"mingw-w64 mingwex.lib" ,
370- @"mingw-w64 uuid.lib" ,
367+ @"mingw-w64 CRT lib" ,
371368};
372369
373370pub const MiscError = struct {
@@ -1684,21 +1681,28 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
16841681 if (comp .wantBuildMinGWFromSource ()) {
16851682 if (! target_util .canBuildLibC (target )) return error .LibCUnavailable ;
16861683
1687- const static_lib_jobs = [_ ]Job {
1688- .{ .mingw_crt_file = .mingw32_lib },
1689- .{ .mingw_crt_file = .msvcrt_os_lib },
1690- .{ .mingw_crt_file = .mingwex_lib },
1691- .{ .mingw_crt_file = .uuid_lib },
1692- };
16931684 const crt_job : Job = .{ .mingw_crt_file = if (is_dyn_lib ) .dllcrt2_o else .crt2_o };
1694- try comp .work_queue .ensureUnusedCapacity (static_lib_jobs .len + 1 );
1695- comp .work_queue .writeAssumeCapacity (& static_lib_jobs );
1696- comp .work_queue .writeItemAssumeCapacity (crt_job );
1685+ try comp .work_queue .writeItem (crt_job );
1686+
1687+ var add_libc = true ;
1688+ var it = comp .bin_file .options .system_libs .iterator ();
1689+ while (it .next ()) | entry | {
1690+ const name = entry .key_ptr .* ;
1691+ if (std .mem .startsWith (u8 , name , "msvcr" ) or std .mem .startsWith (u8 , name , "ucrt" ) or std .mem .startsWith (u8 , name , "crtdll" )) {
1692+ add_libc = false ;
1693+ break ;
1694+ }
1695+ }
1696+ if (add_libc ) {
1697+ try comp .bin_file .options .system_libs .put (comp .gpa , "ucrt" , .{});
1698+ }
16971699
16981700 // When linking mingw-w64 there are some import libs we always need.
16991701 for (mingw .always_link_libs ) | name | {
17001702 try comp .bin_file .options .system_libs .put (comp .gpa , name , .{});
17011703 }
1704+
1705+ try mingw .processSystemLibs (comp );
17021706 }
17031707 // Generate Windows import libs.
17041708 if (target .os .tag == .windows ) {
0 commit comments