From 021ced683d589fae7dbc7e7fa6108a9ee11bf64c Mon Sep 17 00:00:00 2001 From: Crafter Build CI Date: Wed, 27 May 2026 02:23:53 +0000 Subject: [PATCH] fix vendored libdeflate _rotr* macros colliding with mingw stdlib.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compiler_gcc.h defined _rotl/_rotr/_rotl64/_rotr64 as macros before mingw's got a chance to declare them as functions. Any translation unit that did `#include "lib_common.h"` (which transitively pulls in compiler_gcc.h) and later included — utils.c does exactly this — would have the mingw function declarations textually substituted by the macros, producing a syntax error. Force in from compiler_gcc.h on mingw so the function declarations are parsed before the macro names get shadowed. The later #include in utils.c becomes a no-op via the header guard, and call sites still resolve to the macros below (so the generated code is unchanged on every other compiler/target). This unblocks the Crafter.Build CI's x86_64-w64-mingw32 cross-compile, which has been failing for a while when building Crafter.Asset → gdeflate → libdeflate as a dep. --- lib/gdeflate/libdeflate/common/compiler_gcc.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/gdeflate/libdeflate/common/compiler_gcc.h b/lib/gdeflate/libdeflate/common/compiler_gcc.h index 18147a2..b3f998c 100644 --- a/lib/gdeflate/libdeflate/common/compiler_gcc.h +++ b/lib/gdeflate/libdeflate/common/compiler_gcc.h @@ -203,7 +203,19 @@ typedef char __v64qi __attribute__((__vector_size__(64))); /* * Setup rotation macros similar to MSVS intrinsics. * These should recognized by compilers. + * + * mingw's declares _rotl/_rotr/_rotl64/_rotr64 as functions, so + * a translation unit that pulls compiler_gcc.h in first (libdeflate's own + * utils.c does exactly that) and then includes would see the + * function declarations mangled by these macros. Force in here + * on mingw so the declarations get parsed before the macro names get + * shadowed; the header guard makes the later #include a no-op and call + * sites still resolve to the macros below. */ +#if defined(__MINGW32__) || defined(__MINGW64__) +# include +#endif + #ifndef _rotr16 #define _rotr16(x,n) ((x>>n) + (x<<(16-n))) #endif -- 2.54.0