authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-11 01:59:39-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-11 01:59:39-07:00
logb020d83265b10544f4f1f4da1502dba0ebb445d6
treef87585d7728cf310b227dd9a89e2a52a5e88e126
parent3108b8010ecfd9fc7bc9734af357700b8b913f71

mingw-w64: pass -D__USE_MINGW_ANSI_STDIO=0 for crt files

Thanks to Martin Storsjö for explaining this to me on IRC: __USE_MINGW_ANSI_STDIO redirects stdio functions towards mingw-w64 reimplementations of them (since msvcrt.dll lacks lots of things). For x86 with "long double", this is also needed to get long doubles formatted properly. It's enabled by default by headers when building in C99 mode, unless you're targeting UCRT. The headers normally enable this automatically - or you can request it enabled with -D__USE_MINGW_ANSI_STDIO=1. However, the mingw-w64-crt files are expected to be built with this explicitly turned off. Since there's a half dozen various ways of configuring the CRT and various features, the mingw-w64-crt files specifically need to be built in a very hardcoded configuration, which is different from how end user source files are compiled. This commit removes a patch that we were carrying previously. See #7356

1 files changed, 5 insertions(+), 0 deletions(-)

src/mingw.zig+5
...@@ -91,6 +91,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -91,6 +91,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
91 "-D_CRTBLD",91 "-D_CRTBLD",
92 "-D_WIN32_WINNT=0x0f00",92 "-D_WIN32_WINNT=0x0f00",
93 "-D__MSVCRT_VERSION__=0x700",93 "-D__MSVCRT_VERSION__=0x700",
94 "-D__USE_MINGW_ANSI_STDIO=0",
94 });95 });
95 c_source_files[i] = .{96 c_source_files[i] = .{
96 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{97 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
...@@ -114,6 +115,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -114,6 +115,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
114 "-D_CRTBLD",115 "-D_CRTBLD",
115 "-D_WIN32_WINNT=0x0f00",116 "-D_WIN32_WINNT=0x0f00",
116 "-D__MSVCRT_VERSION__=0x700",117 "-D__MSVCRT_VERSION__=0x700",
118 "-D__USE_MINGW_ANSI_STDIO=0",
117119
118 "-isystem",120 "-isystem",
119 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }),121 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }),
...@@ -162,6 +164,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -162,6 +164,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
162 "-D_CRTBLD",164 "-D_CRTBLD",
163 "-D_WIN32_WINNT=0x0f00",165 "-D_WIN32_WINNT=0x0f00",
164 "-D__MSVCRT_VERSION__=0x700",166 "-D__MSVCRT_VERSION__=0x700",
167 "-D__USE_MINGW_ANSI_STDIO=0",
165168
166 "-isystem",169 "-isystem",
167 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }),170 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }),
...@@ -224,6 +227,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {...@@ -224,6 +227,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
224 "-D_CRTBLD",227 "-D_CRTBLD",
225 "-D_WIN32_WINNT=0x0f00",228 "-D_WIN32_WINNT=0x0f00",
226 "-D__MSVCRT_VERSION__=0x700",229 "-D__MSVCRT_VERSION__=0x700",
230 "-D__USE_MINGW_ANSI_STDIO=0",
227231
228 "-isystem",232 "-isystem",
229 try comp.zig_lib_directory.join(arena, &[_][]const u8{233 try comp.zig_lib_directory.join(arena, &[_][]const u8{
...@@ -269,6 +273,7 @@ fn add_cc_args(...@@ -269,6 +273,7 @@ fn add_cc_args(
269 "-D_CRTBLD",273 "-D_CRTBLD",
270 "-D_WIN32_WINNT=0x0f00",274 "-D_WIN32_WINNT=0x0f00",
271 "-D__MSVCRT_VERSION__=0x700",275 "-D__MSVCRT_VERSION__=0x700",
276 "-D__USE_MINGW_ANSI_STDIO=0",
272 });277 });
273}278}
274279