Skip to content

Commit

Permalink
Fix clang-cl build with disabled x86 intrinsics
Browse files Browse the repository at this point in the history
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: llvm/llvm-project#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 <[email protected]>
  • Loading branch information
stampho committed Dec 15, 2022
1 parent 514a6cb commit 702ffc4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,16 @@ if (TEST_architecture_arch STREQUAL x86_64 OR TEST_architecture_arch STREQUAL i3
MESSAGE [=[
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.
]=]
)
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()
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/global/qnumeric_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
// 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
// allowed to dpeend on exactly the processor's behavior. This
// implementation uses the truncating conversions from Scalar Double to
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/global/qsimd.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

#if defined(Q_PROCESSOR_X86) && defined(Q_CC_MSVC)
// 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 __SSE2__ 1
# endif
Expand Down

0 comments on commit 702ffc4

Please sign in to comment.