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ö <[email protected]> --- This isn't ideal, but this at least fixes the regression (unbreaking my continuous builds). Other suggested solutions were to move the mingw-w64 definition to mingw-w64-headers winnt.h too. There were arguments against that though: According to documentation, to use __fastfail, one should include intrin.h, so the function is usable with plain CRT headers too, without including the Windows platform headers. In MSVC, the fastfail intrinsic is usable without including any headers (as it is a compiler builtin). Some MSVC builtin intrinsics are usable only after the function has been declared (e.g. by headers), but apparently __fastfail is usable even without such a declaration. In MSVC setups, the function is declared both in intrin.h (which belongs to the VC include tree) and in winnt.h (which belongs to the WinSDK include tree). --- mingw-w64-tools/widl/include/winnt.h | 2 ++ .../widl/patches/0002-fastfail.patch | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 mingw-w64-tools/widl/patches/0002-fastfail.patch 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__ */ 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 000000000..1075d3908 --- /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__ */ + -- 2.34.1 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
