authorgravatar for phildrip@users.noreply.github.comPhil Richards <phildrip@users.noreply.github.com> 2023-09-26 20:25:08+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-09-26 15:25:08-04:00
log15ce9652525de2cc245203042d8c62ef30d5de1f
tree96d41cb813a1ee5e291a54bb2cf1b3a788866e96
parentf4c884617f499b52eaecc0ef674609c774052f8f
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

define `_WIN32_WINNT` for windows compilations based on target minver (#17224)


2 files changed, 8 insertions(+), 5 deletions(-)

src/Compilation.zig+8
...@@ -4880,6 +4880,14 @@ pub fn addCCArgs(...@@ -4880,6 +4880,14 @@ pub fn addCCArgs(
4880 const llvm_triple = try @import("codegen/llvm.zig").targetTriple(arena, target);4880 const llvm_triple = try @import("codegen/llvm.zig").targetTriple(arena, target);
4881 try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple });4881 try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple });
48824882
4883 if (target.os.tag == .windows) switch (ext) {
4884 .c, .cpp, .m, .mm, .h, .cu, .rc, .assembly, .assembly_with_cpp => {
4885 const minver: u16 = @truncate(@intFromEnum(target.os.getVersionRange().windows.min) >> 16);
4886 try argv.append(try std.fmt.allocPrint(argv.allocator, "-D_WIN32_WINNT=0x{x:0>4}", .{minver}));
4887 },
4888 else => {},
4889 };
4890
4883 switch (ext) {4891 switch (ext) {
4884 .c, .cpp, .m, .mm, .h, .cu, .rc => {4892 .c, .cpp, .m, .mm, .h, .cu, .rc => {
4885 try argv.appendSlice(&[_][]const u8{4893 try argv.appendSlice(&[_][]const u8{
src/mingw.zig-5
...@@ -89,7 +89,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr...@@ -89,7 +89,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
8989
90 "-std=gnu99",90 "-std=gnu99",
91 "-D_CRTBLD",91 "-D_CRTBLD",
92 "-D_WIN32_WINNT=0x0f00",
93 "-D__MSVCRT_VERSION__=0x700",92 "-D__MSVCRT_VERSION__=0x700",
94 "-D__USE_MINGW_ANSI_STDIO=0",93 "-D__USE_MINGW_ANSI_STDIO=0",
95 });94 });
...@@ -114,7 +113,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr...@@ -114,7 +113,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
114113
115 "-std=gnu99",114 "-std=gnu99",
116 "-D_CRTBLD",115 "-D_CRTBLD",
117 "-D_WIN32_WINNT=0x0f00",
118 "-D__MSVCRT_VERSION__=0x700",116 "-D__MSVCRT_VERSION__=0x700",
119 "-D__USE_MINGW_ANSI_STDIO=0",117 "-D__USE_MINGW_ANSI_STDIO=0",
120118
...@@ -163,7 +161,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr...@@ -163,7 +161,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
163161
164 "-std=gnu99",162 "-std=gnu99",
165 "-D_CRTBLD",163 "-D_CRTBLD",
166 "-D_WIN32_WINNT=0x0f00",
167 "-D__MSVCRT_VERSION__=0x700",164 "-D__MSVCRT_VERSION__=0x700",
168 "-D__USE_MINGW_ANSI_STDIO=0",165 "-D__USE_MINGW_ANSI_STDIO=0",
169166
...@@ -226,7 +223,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr...@@ -226,7 +223,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
226223
227 "-std=gnu99",224 "-std=gnu99",
228 "-D_CRTBLD",225 "-D_CRTBLD",
229 "-D_WIN32_WINNT=0x0f00",
230 "-D__MSVCRT_VERSION__=0x700",226 "-D__MSVCRT_VERSION__=0x700",
231 "-D__USE_MINGW_ANSI_STDIO=0",227 "-D__USE_MINGW_ANSI_STDIO=0",
232228
...@@ -272,7 +268,6 @@ fn add_cc_args(...@@ -272,7 +268,6 @@ fn add_cc_args(
272 try args.appendSlice(&[_][]const u8{268 try args.appendSlice(&[_][]const u8{
273 "-std=gnu11",269 "-std=gnu11",
274 "-D_CRTBLD",270 "-D_CRTBLD",
275 "-D_WIN32_WINNT=0x0f00",
276 "-D__MSVCRT_VERSION__=0x700",271 "-D__MSVCRT_VERSION__=0x700",
277 "-D__USE_MINGW_ANSI_STDIO=0",272 "-D__USE_MINGW_ANSI_STDIO=0",
278 });273 });