widl: Avoid conflicting definitions of __fastfail from Wine's winnt.h Widl uses a subset of Wine headers, on top of the host's platform headers (either Unix or Windows ones). When building widl for a Windows target, the included Wine headers end up being preferred over the toolchain's own platform headers. Wine defines the __fastfail function in the winnt.h header (as a static inline function), while mingw-w64 headers define it in _mingw.h as a extern gnu_inline function. When built with Clang, this combintion of an extern declaration and static inline, ends up producing extern definitions of the function in every compilation unit that ends up including both headers - which ends up as linker errors due to duplicate definitions. (GCC doesn't seem to produce any extern definitions in these cases.) Patch the imported winnt.h from Wine, to skip the definition of __fastfail if __MINGW_FASTFAIL_IMPL is defined (which is set by _mingw.h). Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-tools/widl/include/winnt.h b/mingw-w64-tools/widl/include/winnt.h index 14cfe64..e2971ba 100644 --- a/mingw-w64-tools/widl/include/winnt.h +++ b/mingw-w64-tools/widl/include/winnt.h
@@ -6768,6 +6768,7 @@ __WINE_ATOMIC_STORE_RELAXED( dest, &value ); } +#if !defined(__MINGW_FASTFAIL_IMPL) static FORCEINLINE DECLSPEC_NORETURN void __fastfail(unsigned int code) { #if defined(__x86_64__) || defined(__i386__) @@ -6780,6 +6781,7 @@ for (;;) __asm__ __volatile__( "udf #0xfb" :: "r" (val) : "memory" ); #endif } +#endif #endif /* __GNUC__ */
diff --git a/mingw-w64-tools/widl/patches/0002-fastfail.patch b/mingw-w64-tools/widl/patches/0002-fastfail.patch new file mode 100644 index 0000000..1075d39 --- /dev/null +++ b/mingw-w64-tools/widl/patches/0002-fastfail.patch
@@ -0,0 +1,20 @@ +diff --git a/mingw-w64-tools/widl/include/winnt.h b/mingw-w64-tools/widl/include/winnt.h +index 14cfe64af..e2971ba2b 100644 +--- a/mingw-w64-tools/widl/include/winnt.h ++++ b/mingw-w64-tools/widl/include/winnt.h +@@ -6768,6 +6768,7 @@ static FORCEINLINE void WriteNoFence( LONG volatile *dest, LONG value ) + __WINE_ATOMIC_STORE_RELAXED( dest, &value ); + } + ++#if !defined(__MINGW_FASTFAIL_IMPL) + static FORCEINLINE DECLSPEC_NORETURN void __fastfail(unsigned int code) + { + #if defined(__x86_64__) || defined(__i386__) +@@ -6780,6 +6781,7 @@ static FORCEINLINE DECLSPEC_NORETURN void __fastfail(unsigned int code) + for (;;) __asm__ __volatile__( "udf #0xfb" :: "r" (val) : "memory" ); + #endif + } ++#endif + + #endif /* __GNUC__ */ +