authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-04 22:41:34-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-08 11:52:38-07:00
log3f4c73ae938f228e13ccc4f2442d7a6cd38111be
tree7a4cf25ce2246e8aef321a4812c47546982f64dc
parentc26bace6066fde8c0b6ca0ad8559ddb273a85e04

mingw: update from msvcrt to ucrt


3 files changed, 23 insertions(+), 159 deletions(-)

src/Compilation.zig-1
......@@ -1821,7 +1821,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
18211821
18221822 const static_lib_jobs = [_]Job{
18231823 .{ .mingw_crt_file = .mingw32_lib },
1824 .{ .mingw_crt_file = .msvcrt_os_lib },
18251824 .{ .mingw_crt_file = .mingwex_lib },
18261825 .{ .mingw_crt_file = .uuid_lib },
18271826 };
src/link/Coff/lld.zig-1
......@@ -410,7 +410,6 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node)
410410
411411 try argv.append(try comp.get_libc_crt_file(arena, "mingw32.lib"));
412412 try argv.append(try comp.get_libc_crt_file(arena, "mingwex.lib"));
413 try argv.append(try comp.get_libc_crt_file(arena, "msvcrt-os.lib"));
414413 try argv.append(try comp.get_libc_crt_file(arena, "uuid.lib"));
415414
416415 for (mingw.always_link_libs) |name| {
src/mingw.zig+23-157
......@@ -14,7 +14,6 @@ pub const CRTFile = enum {
1414 crt2_o,
1515 dllcrt2_o,
1616 mingw32_lib,
17 msvcrt_os_lib,
1817 mingwex_lib,
1918 uuid_lib,
2019};
......@@ -34,12 +33,9 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
3433 try args.appendSlice(&[_][]const u8{
3534 "-D_SYSCRT=1",
3635 "-DCRTDLL=1",
37 "-U__CRTDLL__",
38 "-D__MSVCRT__",
39 // Uncomment these 3 things for crtu
36 // Uncommenting this makes mingw-w64 look for wmain instead of main.
4037 //"-DUNICODE",
4138 //"-D_UNICODE",
42 //"-DWPRFLAG=1",
4339 });
4440 var files = [_]Compilation.CSourceFile{
4541 .{
......@@ -59,8 +55,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
5955 try args.appendSlice(&[_][]const u8{
6056 "-D_SYSCRT=1",
6157 "-DCRTDLL=1",
62 "-U__CRTDLL__",
63 "-D__MSVCRT__",
6458 });
6559 var files = [_]Compilation.CSourceFile{
6660 .{
......@@ -107,56 +101,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
107101 return comp.build_crt_file("mingw32", .Lib, .@"mingw-w64 mingw32.lib", prog_node, &c_source_files);
108102 },
109103
110 .msvcrt_os_lib => {
111 const extra_flags = try arena.dupe([]const u8, &[_][]const u8{
112 "-DHAVE_CONFIG_H",
113 "-D__LIBMSVCRT__",
114 "-D__LIBMSVCRT_OS__",
115
116 "-I",
117 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "mingw", "include" }),
118
119 "-std=gnu99",
120 "-D_CRTBLD",
121 "-D__MSVCRT_VERSION__=0x700",
122 "-D__USE_MINGW_ANSI_STDIO=0",
123
124 "-isystem",
125 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }),
126 });
127 var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena);
128
129 for (msvcrt_common_src) |dep| {
130 (try c_source_files.addOne()).* = .{
131 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "mingw", dep }),
132 .extra_flags = extra_flags,
133 .owner = undefined,
134 };
135 }
136 if (comp.getTarget().cpu.arch == .x86) {
137 for (msvcrt_i386_src) |dep| {
138 (try c_source_files.addOne()).* = .{
139 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
140 "libc", "mingw", dep,
141 }),
142 .extra_flags = extra_flags,
143 .owner = undefined,
144 };
145 }
146 } else {
147 for (msvcrt_other_src) |dep| {
148 (try c_source_files.addOne()).* = .{
149 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
150 "libc", "mingw", dep,
151 }),
152 .extra_flags = extra_flags,
153 .owner = undefined,
154 };
155 }
156 }
157 return comp.build_crt_file("msvcrt-os", .Lib, .@"mingw-w64 msvcrt-os.lib", prog_node, c_source_files.items);
158 },
159
160104 .mingwex_lib => {
161105 const extra_flags = try arena.dupe([]const u8, &[_][]const u8{
162106 "-DHAVE_CONFIG_H",
......@@ -542,78 +486,7 @@ const mingw32_lib_deps = [_][]const u8{
542486 "cxa_thread_atexit.c",
543487 "tls_atexit.c",
544488};
545const msvcrt_common_src = [_][]const u8{
546 "misc" ++ path.sep_str ++ "_create_locale.c",
547 "misc" ++ path.sep_str ++ "_free_locale.c",
548 "misc" ++ path.sep_str ++ "onexit_table.c",
549 "misc" ++ path.sep_str ++ "register_tls_atexit.c",
550 "stdio" ++ path.sep_str ++ "acrt_iob_func.c",
551 "stdio" ++ path.sep_str ++ "snprintf_alias.c",
552 "stdio" ++ path.sep_str ++ "vsnprintf_alias.c",
553 "stdio" ++ path.sep_str ++ "_vscprintf.c",
554 "misc" ++ path.sep_str ++ "_configthreadlocale.c",
555 "misc" ++ path.sep_str ++ "_get_current_locale.c",
556 "misc" ++ path.sep_str ++ "invalid_parameter_handler.c",
557 "misc" ++ path.sep_str ++ "output_format.c",
558 "misc" ++ path.sep_str ++ "purecall.c",
559 "secapi" ++ path.sep_str ++ "_access_s.c",
560 "secapi" ++ path.sep_str ++ "_cgets_s.c",
561 "secapi" ++ path.sep_str ++ "_cgetws_s.c",
562 "secapi" ++ path.sep_str ++ "_chsize_s.c",
563 "secapi" ++ path.sep_str ++ "_controlfp_s.c",
564 "secapi" ++ path.sep_str ++ "_cprintf_s.c",
565 "secapi" ++ path.sep_str ++ "_cprintf_s_l.c",
566 "secapi" ++ path.sep_str ++ "_ctime32_s.c",
567 "secapi" ++ path.sep_str ++ "_ctime64_s.c",
568 "secapi" ++ path.sep_str ++ "_cwprintf_s.c",
569 "secapi" ++ path.sep_str ++ "_cwprintf_s_l.c",
570 "secapi" ++ path.sep_str ++ "_gmtime32_s.c",
571 "secapi" ++ path.sep_str ++ "_gmtime64_s.c",
572 "secapi" ++ path.sep_str ++ "_localtime32_s.c",
573 "secapi" ++ path.sep_str ++ "_localtime64_s.c",
574 "secapi" ++ path.sep_str ++ "_mktemp_s.c",
575 "secapi" ++ path.sep_str ++ "_sopen_s.c",
576 "secapi" ++ path.sep_str ++ "_strdate_s.c",
577 "secapi" ++ path.sep_str ++ "_strtime_s.c",
578 "secapi" ++ path.sep_str ++ "_umask_s.c",
579 "secapi" ++ path.sep_str ++ "_vcprintf_s.c",
580 "secapi" ++ path.sep_str ++ "_vcprintf_s_l.c",
581 "secapi" ++ path.sep_str ++ "_vcwprintf_s.c",
582 "secapi" ++ path.sep_str ++ "_vcwprintf_s_l.c",
583 "secapi" ++ path.sep_str ++ "_vscprintf_p.c",
584 "secapi" ++ path.sep_str ++ "_vscwprintf_p.c",
585 "secapi" ++ path.sep_str ++ "_vswprintf_p.c",
586 "secapi" ++ path.sep_str ++ "_waccess_s.c",
587 "secapi" ++ path.sep_str ++ "_wasctime_s.c",
588 "secapi" ++ path.sep_str ++ "_wctime32_s.c",
589 "secapi" ++ path.sep_str ++ "_wctime64_s.c",
590 "secapi" ++ path.sep_str ++ "_wstrtime_s.c",
591 "secapi" ++ path.sep_str ++ "_wmktemp_s.c",
592 "secapi" ++ path.sep_str ++ "_wstrdate_s.c",
593 "secapi" ++ path.sep_str ++ "asctime_s.c",
594 "secapi" ++ path.sep_str ++ "memcpy_s.c",
595 "secapi" ++ path.sep_str ++ "memmove_s.c",
596 "secapi" ++ path.sep_str ++ "rand_s.c",
597 "secapi" ++ path.sep_str ++ "sprintf_s.c",
598 "secapi" ++ path.sep_str ++ "strerror_s.c",
599 "secapi" ++ path.sep_str ++ "vsprintf_s.c",
600 "secapi" ++ path.sep_str ++ "wmemcpy_s.c",
601 "secapi" ++ path.sep_str ++ "wmemmove_s.c",
602 "stdio" ++ path.sep_str ++ "mingw_lock.c",
603};
604const msvcrt_i386_src = [_][]const u8{
605 "misc" ++ path.sep_str ++ "lc_locale_func.c",
606 "misc" ++ path.sep_str ++ "___mb_cur_max_func.c",
607 "misc" ++ path.sep_str ++ "wassert.c",
608};
609489
610const msvcrt_other_src = [_][]const u8{
611 "misc" ++ path.sep_str ++ "__p___argv.c",
612 "misc" ++ path.sep_str ++ "__p__acmdln.c",
613 "misc" ++ path.sep_str ++ "__p__commode.c",
614 "misc" ++ path.sep_str ++ "__p__fmode.c",
615 "misc" ++ path.sep_str ++ "__p__wcmdln.c",
616};
617490const mingwex_generic_src = [_][]const u8{
618491 "complex" ++ path.sep_str ++ "_cabs.c",
619492 "complex" ++ path.sep_str ++ "cabs.c",
......@@ -669,6 +542,7 @@ const mingwex_generic_src = [_][]const u8{
669542 "complex" ++ path.sep_str ++ "ctanl.c",
670543 "crt" ++ path.sep_str ++ "dllentry.c",
671544 "crt" ++ path.sep_str ++ "dllmain.c",
545 "crt" ++ path.sep_str ++ "ucrtbase_compat.c",
672546 "gdtoa" ++ path.sep_str ++ "arithchk.c",
673547 "gdtoa" ++ path.sep_str ++ "dmisc.c",
674548 "gdtoa" ++ path.sep_str ++ "dtoa.c",
......@@ -848,6 +722,7 @@ const mingwex_generic_src = [_][]const u8{
848722 "misc" ++ path.sep_str ++ "wmemmove.c",
849723 "misc" ++ path.sep_str ++ "wmempcpy.c",
850724 "misc" ++ path.sep_str ++ "wmemset.c",
725 "misc" ++ path.sep_str ++ "__initenv.c",
851726 "stdio" ++ path.sep_str ++ "_Exit.c",
852727 "stdio" ++ path.sep_str ++ "_findfirst64i32.c",
853728 "stdio" ++ path.sep_str ++ "_findnext64i32.c",
......@@ -878,40 +753,31 @@ const mingwex_generic_src = [_][]const u8{
878753 "stdio" ++ path.sep_str ++ "lltoa.c",
879754 "stdio" ++ path.sep_str ++ "lltow.c",
880755 "stdio" ++ path.sep_str ++ "lseek64.c",
881 "stdio" ++ path.sep_str ++ "mingw_asprintf.c",
882 "stdio" ++ path.sep_str ++ "mingw_fprintf.c",
883 "stdio" ++ path.sep_str ++ "mingw_fprintfw.c",
884 "stdio" ++ path.sep_str ++ "mingw_fscanf.c",
885 "stdio" ++ path.sep_str ++ "mingw_fwscanf.c",
886 "stdio" ++ path.sep_str ++ "mingw_pformat.c",
887 "stdio" ++ path.sep_str ++ "mingw_pformatw.c",
888 "stdio" ++ path.sep_str ++ "mingw_printf.c",
889 "stdio" ++ path.sep_str ++ "mingw_printfw.c",
890 "stdio" ++ path.sep_str ++ "mingw_scanf.c",
891 "stdio" ++ path.sep_str ++ "mingw_snprintf.c",
892 "stdio" ++ path.sep_str ++ "mingw_snprintfw.c",
893 "stdio" ++ path.sep_str ++ "mingw_sprintf.c",
894 "stdio" ++ path.sep_str ++ "mingw_sprintfw.c",
895 "stdio" ++ path.sep_str ++ "mingw_sscanf.c",
896 "stdio" ++ path.sep_str ++ "mingw_swscanf.c",
897 "stdio" ++ path.sep_str ++ "mingw_vasprintf.c",
898 "stdio" ++ path.sep_str ++ "mingw_vfprintf.c",
899 "stdio" ++ path.sep_str ++ "mingw_vfprintfw.c",
900 "stdio" ++ path.sep_str ++ "mingw_vfscanf.c",
901 "stdio" ++ path.sep_str ++ "mingw_vprintf.c",
902 "stdio" ++ path.sep_str ++ "mingw_vprintfw.c",
903 "stdio" ++ path.sep_str ++ "mingw_vsnprintf.c",
904 "stdio" ++ path.sep_str ++ "mingw_vsnprintfw.c",
905 "stdio" ++ path.sep_str ++ "mingw_vsprintf.c",
906 "stdio" ++ path.sep_str ++ "mingw_vsprintfw.c",
907 "stdio" ++ path.sep_str ++ "mingw_wscanf.c",
908 "stdio" ++ path.sep_str ++ "mingw_wvfscanf.c",
909756 "stdio" ++ path.sep_str ++ "scanf.S",
910757 "stdio" ++ path.sep_str ++ "snprintf.c",
911758 "stdio" ++ path.sep_str ++ "snwprintf.c",
912759 "stdio" ++ path.sep_str ++ "strtof.c",
913760 "stdio" ++ path.sep_str ++ "strtok_r.c",
914761 "stdio" ++ path.sep_str ++ "truncate.c",
762 "stdio" ++ path.sep_str ++ "ucrt__snwprintf.c",
763 "stdio" ++ path.sep_str ++ "ucrt__vscprintf.c",
764 "stdio" ++ path.sep_str ++ "ucrt__vsnprintf.c",
765 "stdio" ++ path.sep_str ++ "ucrt__vsnwprintf.c",
766 "stdio" ++ path.sep_str ++ "ucrt_fprintf.c",
767 "stdio" ++ path.sep_str ++ "ucrt_fscanf.c",
768 "stdio" ++ path.sep_str ++ "ucrt_fwprintf.c",
769 "stdio" ++ path.sep_str ++ "ucrt_printf.c",
770 "stdio" ++ path.sep_str ++ "ucrt_scanf.c",
771 "stdio" ++ path.sep_str ++ "ucrt_snprintf.c",
772 "stdio" ++ path.sep_str ++ "ucrt_sprintf.c",
773 "stdio" ++ path.sep_str ++ "ucrt_sscanf.c",
774 "stdio" ++ path.sep_str ++ "ucrt_vfprintf.c",
775 "stdio" ++ path.sep_str ++ "ucrt_vfscanf.c",
776 "stdio" ++ path.sep_str ++ "ucrt_vprintf.c",
777 "stdio" ++ path.sep_str ++ "ucrt_vscanf.c",
778 "stdio" ++ path.sep_str ++ "ucrt_vsnprintf.c",
779 "stdio" ++ path.sep_str ++ "ucrt_vsprintf.c",
780 "stdio" ++ path.sep_str ++ "ucrt_vsscanf.c",
915781 "stdio" ++ path.sep_str ++ "ulltoa.c",
916782 "stdio" ++ path.sep_str ++ "ulltow.c",
917783 "stdio" ++ path.sep_str ++ "vasprintf.c",
......@@ -1136,9 +1002,9 @@ const uuid_src = [_][]const u8{
11361002};
11371003
11381004pub const always_link_libs = [_][]const u8{
1005 "ucrtbase",
11391006 "advapi32",
11401007 "kernel32",
1141 "msvcrt",
11421008 "ntdll",
11431009 "shell32",
11441010 "user32",