From ec3962f9c7e918795d7aa4f0b5160b2cf9b7f28c Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 20 Nov 2023 08:22:41 +0000 Subject: [PATCH] directxmath.wrap: Fix cpuid mismatch on MinGW This fixes a build failure with meson 1.3.0, which was caused by a bugfix in Meson that made the cc.compile() check succeed on MSYS2 MinGW and enable DirectXMath SIMD, which in turn triggered the broken `__cpuid()` issue mentioned in the meson.build file. Upstream fix: https://github.com/microsoft/DirectXMath/pull/172 Part-of: --- subprojects/directxmath.wrap | 1 + .../gst-libs/gst/d3d11/meson.build | 1 - ...gument-cpuid-when-using-recent-MinGW.patch | 43 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 subprojects/packagefiles/DirectXMath-dec2022/0001-Inc-Use-two-argument-cpuid-when-using-recent-MinGW.patch diff --git a/subprojects/directxmath.wrap b/subprojects/directxmath.wrap index 2624355a80..7d01190d01 100644 --- a/subprojects/directxmath.wrap +++ b/subprojects/directxmath.wrap @@ -8,6 +8,7 @@ patch_url = https://wrapdb.mesonbuild.com/v2/directxmath_3.1.8-1/get_patch patch_hash = 854f9c065319885f3de5b381cc77454913377a84c8ae6756795fe3eaa99b81f7 source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/directxmath_3.1.8-1/dec2022.tar.gz wrapdb_version = 3.1.8-1 +diff_files = DirectXMath-dec2022/0001-Inc-Use-two-argument-cpuid-when-using-recent-MinGW.patch [provide] directxmath = directxmath_dep diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build index 6511b72028..5abb1360f4 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/meson.build @@ -205,7 +205,6 @@ endif # https://learn.microsoft.com/en-us/windows/win32/dxmath/pg-xnamath-internals#windows-sse-versus-sse2 # x86 with Windows 7 or older may not support SSE2 if host_machine.cpu_family() != 'x86' - # XXX: __cpuid() mismatch in case of some mingw toolchain have_dx_math_simd = cxx.compiles(''' #include #include diff --git a/subprojects/packagefiles/DirectXMath-dec2022/0001-Inc-Use-two-argument-cpuid-when-using-recent-MinGW.patch b/subprojects/packagefiles/DirectXMath-dec2022/0001-Inc-Use-two-argument-cpuid-when-using-recent-MinGW.patch new file mode 100644 index 0000000000..5057c80ccc --- /dev/null +++ b/subprojects/packagefiles/DirectXMath-dec2022/0001-Inc-Use-two-argument-cpuid-when-using-recent-MinGW.patch @@ -0,0 +1,43 @@ +From 77c86dfd0d5866c5d98980b2ec6b7ed9b0fd3b14 Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan +Date: Mon, 20 Nov 2023 13:36:04 +0530 +Subject: [PATCH] Inc: Use two-argument cpuid when using recent MinGW + +Since 2021, when building with MinGW if `intrin.h` is included +(directly or indirectly), it will redefine `__cpuid` to use the +intrinsic version of it, instead of the macro defined by GCC's +`cpuid.h`. Detect this case, and use the two-argument prototype +instead. + +https://github.com/mingw-w64/mingw-w64/commit/d2374f898457b0f4ea8bd4084a94f2dafc87a99a + +Upstream PR: https://github.com/microsoft/DirectXMath/pull/172 +--- + Inc/DirectXMathMisc.inl | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Inc/DirectXMathMisc.inl b/Inc/DirectXMathMisc.inl +index 5f88da6..5c68e8d 100644 +--- a/Inc/DirectXMathMisc.inl ++++ b/Inc/DirectXMathMisc.inl +@@ -1973,7 +1973,7 @@ inline bool XMVerifyCPUSupport() noexcept + { + #if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) + int CPUInfo[4] = { -1 }; +-#if defined(__clang__) || defined(__GNUC__) ++#if defined(__clang__) || (defined(__GNUC__) && defined(__cpuid)) + __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); + #else + __cpuid(CPUInfo, 0); +@@ -1987,7 +1987,7 @@ inline bool XMVerifyCPUSupport() noexcept + return false; + #endif + +-#if defined(__clang__) || defined(__GNUC__) ++#if defined(__clang__) || (defined(__GNUC__) && defined(__cpuid)) + __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); + #else + __cpuid(CPUInfo, 1); +-- +2.41.0 +