Fix clang-cl build with disabled x86 intrinsics

clang-cl's intrinsics support is broken, it doesn't declare the AVX2
intrinsics if they are disabled and this doesn't match GCC or MSVC
behavior: https://github.com/llvm/llvm-project/issues/53520

This fix allows to disable x86 intrinsiscs during configuration of
clang-cl build.

clang-cl build is still not guaranteed to work with enabled x86 intrinsics.

Change-Id: Icd295f6b4d868adf10bcd425d5280c56b43cb9f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Peter Varga 2022-12-13 17:59:03 +01:00
parent 514a6cb7dc
commit 702ffc45d6
3 changed files with 12 additions and 2 deletions

View File

@ -1274,6 +1274,16 @@ if (TEST_architecture_arch STREQUAL x86_64 OR TEST_architecture_arch STREQUAL i3
MESSAGE [=[ MESSAGE [=[
All x86 intrinsics and SIMD support were disabled. If this was in error, check All x86 intrinsics and SIMD support were disabled. If this was in error, check
the result of the build in config.tests/x86intrin and report at https://bugreports.qt.io. the result of the build in config.tests/x86intrin and report at https://bugreports.qt.io.
]=]
)
elseif (MSVC AND CLANG)
# Warn only
qt_configure_add_report_entry(
TYPE WARNING
CONDITION (NOT QT_FEATURE_x86intrin)
MESSAGE [=[
x86 intrinsics support is disabled for clang-cl build. This might be necessary due to
https://github.com/llvm/llvm-project/issues/53520
]=] ]=]
) )
else() else()

View File

@ -180,7 +180,7 @@ static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgr
// correct, but Clang, ICC and MSVC don't realize that it's a constant and // correct, but Clang, ICC and MSVC don't realize that it's a constant and
// the math call stays in the compiled code. // the math call stays in the compiled code.
#ifdef Q_PROCESSOR_X86_64 #if defined(Q_PROCESSOR_X86_64) && defined(__SSE2__)
// Of course, UB doesn't apply if we use intrinsics, in which case we are // Of course, UB doesn't apply if we use intrinsics, in which case we are
// allowed to dpeend on exactly the processor's behavior. This // allowed to dpeend on exactly the processor's behavior. This
// implementation uses the truncating conversions from Scalar Double to // implementation uses the truncating conversions from Scalar Double to

View File

@ -55,7 +55,7 @@
#if defined(Q_PROCESSOR_X86) && defined(Q_CC_MSVC) #if defined(Q_PROCESSOR_X86) && defined(Q_CC_MSVC)
// MSVC doesn't define __SSE2__, so do it ourselves // MSVC doesn't define __SSE2__, so do it ourselves
# if (defined(_M_X64) || _M_IX86_FP >= 2) # if (defined(_M_X64) || _M_IX86_FP >= 2) && defined(QT_COMPILER_SUPPORTS_SSE2)
# define __SSE__ 1 # define __SSE__ 1
# define __SSE2__ 1 # define __SSE2__ 1
# endif # endif