From d298ec3a6f4634254c6685398d49b1ba4dfa8e6b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 10 Jan 2023 11:32:46 -0800 Subject: [PATCH] Fix build with GCC 13: target specific option mismatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit range_access.h:274:5: error: inlining failed in call to ‘always_inline’ ‘constexpr std::size_t std::size(const _Tp (&)[_Nm]) noexcept [with _Tp = short unsigned int; long unsigned int _Nm = 34]’: target specific option mismatch qsimd.cpp:367:35: note: called from here Pick-to: 6.5 Change-Id: Ide4dbd0777a44ed0870efffd1739097c71991822 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/global/qsimd.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/corelib/global/qsimd.cpp b/src/corelib/global/qsimd.cpp index cc90433567..7985283d15 100644 --- a/src/corelib/global/qsimd.cpp +++ b/src/corelib/global/qsimd.cpp @@ -9,8 +9,6 @@ #include "qsimd_p.h" #include "qalgorithms.h" -#include // for std::size - #include #include @@ -64,6 +62,14 @@ QT_BEGIN_NAMESPACE +template QT_FUNCTION_TARGET_BASELINE +uint arraysize(T (&)[N]) +{ + // Same as std::size, but with QT_FUNCTION_TARGET_BASELIE, + // otherwise some versions of GCC fail to compile. + return N; +} + #if defined(Q_PROCESSOR_ARM) /* Data: neon @@ -364,7 +370,7 @@ static quint64 detectProcessorFeatures() cpuidFeatures07_00(results[Leaf07_00EBX], results[Leaf07_00ECX], results[Leaf07_00EDX]); // populate our feature list - for (uint i = 0; i < std::size(x86_locators); ++i) { + for (uint i = 0; i < arraysize(x86_locators); ++i) { uint word = x86_locators[i] / 32; uint bit = 1U << (x86_locators[i] % 32); quint64 feature = Q_UINT64_C(1) << i; @@ -583,7 +589,7 @@ uint64_t QT_MANGLE_NAMESPACE(qDetectCpuFeatures)() #endif while (char *token = strtok(disable, " ")) { disable = nullptr; - for (uint i = 0; i < std::size(features_indices); ++i) { + for (uint i = 0; i < arraysize(features_indices); ++i) { if (strcmp(token, features_string + features_indices[i]) == 0) f &= ~(Q_UINT64_C(1) << i); } @@ -598,7 +604,7 @@ uint64_t QT_MANGLE_NAMESPACE(qDetectCpuFeatures)() if (Q_UNLIKELY(!runningOnValgrind && minFeatureTest != 0 && (f & minFeatureTest) != minFeatureTest)) { quint64 missing = minFeatureTest & ~quint64(f); fprintf(stderr, "Incompatible processor. This Qt build requires the following features:\n "); - for (uint i = 0; i < std::size(features_indices); ++i) { + for (uint i = 0; i < arraysize(features_indices); ++i) { if (missing & (Q_UINT64_C(1) << i)) fprintf(stderr, "%s", features_string + features_indices[i]); } @@ -618,14 +624,14 @@ void qDumpCPUFeatures() { quint64 features = detectProcessorFeatures() & ~SimdInitialized; printf("Processor features: "); - for (uint i = 0; i < std::size(features_indices); ++i) { + for (uint i = 0; i < arraysize(features_indices); ++i) { if (features & (Q_UINT64_C(1) << i)) printf("%s%s", features_string + features_indices[i], minFeature & (Q_UINT64_C(1) << i) ? "[required]" : ""); } if ((features = (qCompilerCpuFeatures & ~features))) { printf("\n!!!!!!!!!!!!!!!!!!!!\n!!! Missing required features:"); - for (uint i = 0; i < std::size(features_indices); ++i) { + for (uint i = 0; i < arraysize(features_indices); ++i) { if (features & (Q_UINT64_C(1) << i)) printf("%s", features_string + features_indices[i]); }