[kde-freebsd] Fixing devel/qt4-corelib to build with clang

Dimitry Andric dimitry at andric.com
Tue May 7 20:54:10 UTC 2013


Hi,

I finally had some time to figure out why devel/qt4-corelib could not be
built with clang.  In particular, src/corelib/tools/qsimd.cpp fails
with:

  clang++ -c -O2 -pipe -fno-strict-aliasing -pthread -I/usr/local/include/glib-2.0 -I/usr/local/include -O2 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -pthread -D_THREAD_SAFE -fPIC -DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_USE_ICU -DHB_EXPORT=Q_CORE_EXPORT -DGNU_LIBICONV -DQT_NO_DEBUG -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -DQT_HAVE_AVX -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/usr/local/share/qt4/mkspecs/freebsd-clang -I. -I../../include -I../../include/QtCore -I.rcc/release-shared -Iglobal -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared -I/usr/local/include/qt4 -I/usr/local/include -o .obj/release-shared/qsimd.o tools/qsimd.cpp
  In file included from tools/qsimd.cpp:42:
  In file included from tools/qsimd_p.h:203:
  In file included from /usr/include/clang/3.3/mm3dnow.h:27:
  /usr/include/clang/3.3/mmintrin.h:28:2: error: "MMX instruction set not enabled"
  #error "MMX instruction set not enabled"

... and then a whole bunch of other errors.  The problem is in
src/corelib/tools/qsimd_p.h, where various SIMD-related headers are
included, depending on configure-time detection.  For example, for SSE3
it does:

  #if defined(QT_HAVE_SSE3) && (defined(__SSE3__) || defined(Q_CC_MSVC))
  #include <pmmintrin.h>
  #endif

And it does similar includes for other intrinsics.  Note that it tests
both QT_HAVE_SSE3 (which is a configure-time feature), and __SSE3__,
which is defined by the compiler, if it supports SSE3 in the current
mode.  That is, if you either pass -msse3 on the command line, or use a
-march= or -mcpu= setting which is high enough to support the SSE3
feature.

However, for 3DNow intrinsics, the header has something different:

  #if defined(QT_HAVE_3DNOW)
  #include <mm3dnow.h>
  #endif

As you can see, there is no test whether the compiler defines __3dNOW__,
so if the configuration stage enables QT_HAVE_3DNOW (as it does for
clang, but not for gcc), it always includes <mm3dnow.h>, even if the
compiler's current mode does not support it.  This is a bug in Qt.

So I changed this part to the following (similar to the other intrinsics
includes):

  #if defined(QT_HAVE_3DNOW) && (defined(__3dNOW__) || defined(Q_CC_MSVC))
  #include <mm3dnow.h>
  #endif

After this, qt4-corelib successfully compiles with both clang 3.2 (which
is in stable/9) and 3.3 (which is in recent head).

I am attaching a patch for qt4-corelib, which disables USE_GCC=any
again, and adds a diff to fix up qsimd_p.h.

-Dimitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: devel__qt4-corelib-1.diff
Type: application/octet-stream
Size: 946 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-freebsd/attachments/20130507/22a57854/attachment.obj>


More information about the kde-freebsd mailing list