Last active
October 15, 2022 00:32
-
-
Save JohannesKauffmann/0b7e149b4fff9a0d7c3f7afd3d89f78f to your computer and use it in GitHub Desktop.
Qt 5.15 patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From c01763ea13416e974fa438a972c9739d5abb8ec3 Mon Sep 17 00:00:00 2001 | |
From: Johannes Kauffmann <[email protected]> | |
Date: Tue, 11 Oct 2022 23:06:28 +0200 | |
Subject: [PATCH] qsimd: Workaround 32bits MinGW compiler bug | |
GCC PR 58372 [1] causes ICE compiling qsimd.cpp on 32bits MinGW. Work | |
around this by detecting 32bits MinGW on the affected GCC versions: | |
GCC <= 7.3.0 and GCC <= 8.2.0 on 8.x. | |
The wiki [2] lists i686-8.1.0-release-posix-dwarf-rt_v6-rev0 as a | |
reference configuration for Qt 5.15, so someone could easily bump into | |
this when compiling 5.15 for 32bits on debug configuration. | |
[1]. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58372 | |
[2]. https://wiki.qt.io/MinGW | |
Fixes: QTBUG-70487 | |
--- | |
src/corelib/tools/qsimd.cpp | 2 +- | |
src/corelib/tools/qsimd_p.h | 19 ++++++++++++++++++- | |
2 files changed, 19 insertions(+), 2 deletions(-) | |
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp | |
index 798ac93ad2..08c34a2b83 100644 | |
--- a/src/corelib/tools/qsimd.cpp | |
+++ b/src/corelib/tools/qsimd.cpp | |
@@ -598,7 +598,7 @@ void qDumpCPUFeatures() | |
puts(""); | |
} | |
-#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) | |
+#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) && !QTBUG_70487 | |
# ifdef Q_PROCESSOR_X86_64 | |
# define _rdrandXX_step _rdrand64_step | |
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h | |
index 26e98c4542..b3405b0af9 100644 | |
--- a/src/corelib/tools/qsimd_p.h | |
+++ b/src/corelib/tools/qsimd_p.h | |
@@ -346,7 +346,24 @@ extern Q_CORE_EXPORT QBasicAtomicInteger<unsigned> qt_cpu_features[2]; | |
#endif | |
Q_CORE_EXPORT quint64 qDetectCpuFeatures(); | |
-#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) && !defined(QT_BOOTSTRAPPED) | |
+/* | |
+ * Work around GCC PR 58372, causing ICE when compiling qsimd.cpp | |
+ * on MinGW32 or MinGW-w64 targeting 32bits. | |
+ * | |
+ * It affects GCC <= 7.3.0 for 7.x and GCC <= 8.2.0 for 8.x. | |
+ * It is fixed completely for GCC 9 and beyond [1]. | |
+ * | |
+ * [1]. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58372 | |
+ */ | |
+#if defined(Q_CC_GNU) && !defined(__clang__) && /* Clang disguises as GCC */ \ | |
+ defined(__MINGW32__) && defined(__MINGW64__) && /* MinGW32 or MinGW-w64 targeting 32bit only */ \ | |
+ (Q_CC_GNU < 704 || (Q_CC_GNU >= 800 && Q_CC_GNU < 803)) /* affected GCC versions */ | |
+# define QTBUG_70487 1 | |
+#else | |
+# define QTBUG_70487 0 | |
+#endif | |
+ | |
+#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) && !defined(QT_BOOTSTRAPPED) && !QTBUG_70487 | |
Q_CORE_EXPORT qsizetype qRandomCpu(void *, qsizetype) noexcept; | |
#else | |
static inline qsizetype qRandomCpu(void *, qsizetype) noexcept | |
-- | |
2.38.0.windows.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment