zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 99922c2708bbbda4fcdc16a45a5d3071dd1495c0 (tree)
parent 089ebeb8736e9186c14d8228fa5594c518dcdb4b
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sun,  7 Jan 2024 22:16:00 -0700

Compilation: only add __MSVCRT_VERSION__ for -lc

prevents it from being defined twice when building mingw-w64 libs.

Diffstat:
Msrc/Compilation.zig | 22+++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/Compilation.zig b/src/Compilation.zig @@ -5086,12 +5086,17 @@ pub fn addCCArgs( try argv.append(libunwind_include_path); } - if (comp.config.link_libc and target.isGnuLibC()) { - const target_version = target.os.version_range.linux.glibc; - const glibc_minor_define = try std.fmt.allocPrint(arena, "-D__GLIBC_MINOR__={d}", .{ - target_version.minor, - }); - try argv.append(glibc_minor_define); + if (comp.config.link_libc) { + if (target.isGnuLibC()) { + const target_version = target.os.version_range.linux.glibc; + const glibc_minor_define = try std.fmt.allocPrint(arena, "-D__GLIBC_MINOR__={d}", .{ + target_version.minor, + }); + try argv.append(glibc_minor_define); + } else if (target.isMinGW()) { + try argv.append("-D__MSVCRT_VERSION__=0xE00"); // use ucrt + + } } const llvm_triple = try @import("codegen/llvm.zig").targetTriple(arena, target); @@ -5100,10 +5105,9 @@ pub fn addCCArgs( if (target.os.tag == .windows) switch (ext) { .c, .cpp, .m, .mm, .h, .cu, .rc, .assembly, .assembly_with_cpp => { const minver: u16 = @truncate(@intFromEnum(target.os.getVersionRange().windows.min) >> 16); - try argv.appendSlice(&.{ + try argv.append( try std.fmt.allocPrint(arena, "-D_WIN32_WINNT=0x{x:0>4}", .{minver}), - "-D__MSVCRT_VERSION__=0xE00", // use ucrt - }); + ); }, else => {}, };