From 0c796adb87491359dcf56efc75fde763e43b733e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 22 Apr 2026 15:30:58 +0200 Subject: [PATCH] zig cc: define __CRT__NO_INLINE for MinGW-w64 targets See added comment for why. --- src/Compilation.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Compilation.zig b/src/Compilation.zig index e8948ef112..7f26ac5c1b 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -6367,6 +6367,13 @@ fn addCommonCCArgs( try argv.append( try std.fmt.allocPrint(arena, "-D_WIN32_WINNT=0x{x:0>4}", .{minver}), ); + + // MinGW-w64's inline functions in headers (e.g. `fabs`), which are emitted with `linkonce_odr` + // linkage, sometimes cause duplicate symbol errors due to us providing the same symbols with + // `weak` linkage in compiler-rt or libzigc. So just disable them. Besides, they undermine the + // goal of moving more libc code to Zig, and they're also just kind of unnecessary since LLVM is + // perfectly capable of recognizing and optimizing libcalls. + try argv.append("-D__CRT__NO_INLINE"); } else if (target.isFreeBSDLibC()) { // https://docs.freebsd.org/en/books/porters-handbook/versions const min_ver = target.os.version_range.semver.min;