Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Jul 2014 08:37:55 +0000 (UTC)
From:      Raphael Kubo da Costa <rakuco@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r362770 - in head: Mk devel/qt4-corelib devel/qt4/files
Message-ID:  <201407240837.s6O8btxp002944@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rakuco
Date: Thu Jul 24 08:37:55 2014
New Revision: 362770
URL: http://svnweb.freebsd.org/changeset/ports/362770
QAT: https://qat.redports.org/buildarchive/r362770/

Log:
  Backport my patch to make Qt correctly detect clang's support for C++11 features.
  
  So far, Qt4 was basing its check for compiler support for C++11 features
  (auto types, lambdas, rvalue references and others) on the values of
  __GNUC__ and __GNUC_MINOR__. This works for GCC, but not for clang, whose
  __GNUC_MINOR__ is stuck at 2. In practice, this meant Qt programs built
  using clang were never able to use C++11 features which are conditionally
  available in classes such as QList. This patch makes the detection more in
  line with what Qt5 does (checks for GCC and clang are in separate sections
  and are done differently).
  
  I couldn't find cases of this negatively affecting any port so far, but it
  is useful to have -- Akonadi's unit tests require C++11 support in Qt, for
  example.
  
  Only qt4-corelibs's PORTREVISION was bumped to make the new qglobal.h be
  installed. Checks for these C++11 features are only present in headers of
  other Qt4 ports, so there's no need to rebuild them.

Added:
  head/devel/qt4/files/extrapatch-src-corelib-global-qglobal.h   (contents, props changed)
Modified:
  head/Mk/bsd.qt.mk
  head/devel/qt4-corelib/Makefile

Modified: head/Mk/bsd.qt.mk
==============================================================================
--- head/Mk/bsd.qt.mk	Thu Jul 24 08:16:55 2014	(r362769)
+++ head/Mk/bsd.qt.mk	Thu Jul 24 08:37:55 2014	(r362770)
@@ -171,6 +171,8 @@ EXTRA_PATCHES?=	${.CURDIR:H:H}/devel/${_
 		${.CURDIR:H:H}/devel/${_QT_RELNAME}/files/extrapatch-libtool
 .  if ${_QT_VERSION:M5*}
 EXTRA_PATCHES+=	${.CURDIR:H:H}/devel/qt5-core/files/extrapatch-src__corelib__tools__qdatetime.cpp
+.  elif ${_QT_VERSION:M4*}
+EXTRA_PATCHES+=	${.CURDIR:H:H}/devel/${_QT_RELNAME}/files/extrapatch-src-corelib-global-qglobal.h
 .  endif
 . endif
 

Modified: head/devel/qt4-corelib/Makefile
==============================================================================
--- head/devel/qt4-corelib/Makefile	Thu Jul 24 08:16:55 2014	(r362769)
+++ head/devel/qt4-corelib/Makefile	Thu Jul 24 08:37:55 2014	(r362770)
@@ -3,7 +3,7 @@
 
 PORTNAME=	corelib
 DISTVERSION=	${QT4_VERSION}
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	devel
 PKGNAMEPREFIX=	qt4-
 

Added: head/devel/qt4/files/extrapatch-src-corelib-global-qglobal.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/qt4/files/extrapatch-src-corelib-global-qglobal.h	Thu Jul 24 08:37:55 2014	(r362770)
@@ -0,0 +1,239 @@
+commit bc620055c82a8ccae49144ad99bf9226d659f852
+Author: Raphael Kubo da Costa <rakuco@FreeBSD.org>
+Date:   Sun Jul 13 23:15:00 2014 +0300
+
+    Move the C++11 support macros to a central place.
+    
+    The main objective of this commit is to make C++11 support work with
+    clang: so far, the Q_COMPILER_* definitions related to C++11 were
+    enabled based on __GNUC__ and __GNUC_MINOR__; while clang does define
+    those two, __GNUC_MINOR__ is hardcoded at "2" and thus none of the
+    macros end up being defined.
+    
+    We now make qglobal.h more similar to how qtbase's qcompilerdetection.h
+    works by separating the detection of the C++11 features supported by a
+    compiler from the detection of the compilers themselves.
+    
+    It is important to note the list of macros has not changed, the macros
+    have only been moved.
+    
+    This commit either follows the spirit of or is a cherry-pick of the
+    following qtbase ones:
+    - 4131c323a36ee8680a3b4d66a2a03a00544751c2 (Update the C++11 support
+      macros)
+    - 8dd66f42e834320c4ba0a6f2e45855d591b3b6e7 (Avoid undefined macro
+      warning for __GXX_EXPERIMENTAL_CXX0X__)
+    - fe5d5fdaf1d9b7d108727d290e24a6b0f00139c6 (clang: Use __has_feature()
+      to detect C++11 features)
+    - 0ec953c93688ec0de74cda43b91f66f4cf879e5f (Remove extra Q_COMPILER_xxx
+      defines from the MSVC section)
+    - 163dcf2b71f34a12137f200e4af5640e42e5f5e2 (Fix build with older Clang
+      versions without __has_extension)
+    - 53262b9b5b9cb536916f6d6e086a944cb17bb8d8 (Only define the MSVC C++11
+      feature macros in C++)
+    
+    Change-Id: I2ca35af1a23260a9373943f97a8a72db3fc670e4
+    Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
+
+diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
+index 158ef78..4f1384b 100644
+--- src/corelib/global/qglobal.h
++++ src/corelib/global/qglobal.h
+@@ -463,17 +463,6 @@ namespace QT_NAMESPACE {}
+ #    undef QT_HAVE_3DNOW
+ #  endif
+ 
+-#if defined(Q_CC_MSVC) && _MSC_VER >= 1600
+-#      define Q_COMPILER_RVALUE_REFS
+-#      define Q_COMPILER_AUTO_FUNCTION
+-#      define Q_COMPILER_AUTO_TYPE
+-#      define Q_COMPILER_LAMBDA
+-#      define Q_COMPILER_DECLTYPE
+-//  MSCV has std::initilizer_list, but do not support the braces initialization
+-//#      define Q_COMPILER_INITIALIZER_LISTS
+-#  endif
+-
+-
+ #elif defined(__BORLANDC__) || defined(__TURBOC__)
+ #  define Q_CC_BOR
+ #  define Q_INLINE_TEMPLATE
+@@ -505,6 +494,7 @@ namespace QT_NAMESPACE {}
+ /* work-around for missing compiler intrinsics */
+ #  define __is_empty(X) false
+ #  define __is_pod(X) false
++
+ #elif defined(__GNUC__)
+ #  define Q_CC_GNU
+ #  define Q_C_CALLBACKS
+@@ -518,6 +508,10 @@ namespace QT_NAMESPACE {}
+ #  if defined(__clang__)
+ /* Clang also masquerades as GCC 4.2.1 */
+ #    define Q_CC_CLANG
++#    if !defined(__has_extension)
++#      /* Compatibility with older Clang versions */
++#      define __has_extension __has_feature
++#    endif
+ #  endif
+ #  ifdef __APPLE__
+ #    define Q_NO_DEPRECATED_CONSTRUCTORS
+@@ -558,33 +552,6 @@ namespace QT_NAMESPACE {}
+ #      define QT_NO_ARM_EABI
+ #    endif
+ #  endif
+-#  if defined(__GXX_EXPERIMENTAL_CXX0X__)
+-#    if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
+-       /* C++0x features supported in GCC 4.3: */
+-#      define Q_COMPILER_RVALUE_REFS
+-#      define Q_COMPILER_DECLTYPE
+-#    endif
+-#    if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
+-       /* C++0x features supported in GCC 4.4: */
+-#      define Q_COMPILER_VARIADIC_TEMPLATES
+-#      define Q_COMPILER_AUTO_FUNCTION
+-#      define Q_COMPILER_AUTO_TYPE
+-#      define Q_COMPILER_EXTERN_TEMPLATES
+-#      define Q_COMPILER_DEFAULT_DELETE_MEMBERS
+-#      define Q_COMPILER_CLASS_ENUM
+-#      define Q_COMPILER_INITIALIZER_LISTS
+-#    endif
+-#    if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
+-       /* C++0x features supported in GCC 4.5: */
+-#      define Q_COMPILER_LAMBDA
+-#      define Q_COMPILER_UNICODE_STRINGS
+-#    endif
+-#    if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
+-       /* C++0x features supported in GCC 4.6: */
+-#      define Q_COMPILER_CONSTEXPR
+-#    endif
+-
+-#  endif
+ 
+ /* IBM compiler versions are a bit messy. There are actually two products:
+    the C product, and the C++ product. The C++ compiler is always packaged
+@@ -829,12 +796,33 @@ namespace QT_NAMESPACE {}
+ #  error "Qt has not been tested with this compiler - talk to qt-bugs@trolltech.com"
+ #endif
+ 
++/*
++ * C++11 support
++ *
++ *  Paper           Macro                               SD-6 macro
++ *  N2541           Q_COMPILER_AUTO_FUNCTION
++ *  N1984 N2546     Q_COMPILER_AUTO_TYPE
++ *  N2437           Q_COMPILER_CLASS_ENUM
++ *  N2235           Q_COMPILER_CONSTEXPR                __cpp_constexpr = 200704
++ *  N2343 N3276     Q_COMPILER_DECLTYPE                 __cpp_decltype = 200707
++ *  N2346           Q_COMPILER_DEFAULT_DELETE_MEMBERS
++ *  N1987           Q_COMPILER_EXTERN_TEMPLATES
++ *  N2672           Q_COMPILER_INITIALIZER_LISTS
++ *  N2658 N2927     Q_COMPILER_LAMBDA                   __cpp_lambdas = 200907
++ *  N2118 N2844 N3053 Q_COMPILER_RVALUE_REFS            __cpp_rvalue_references = 200610
++ *  N2442           Q_COMPILER_UNICODE_STRINGS          __cpp_unicode_literals = 200710
++ *  N2242 N2555     Q_COMPILER_VARIADIC_TEMPLATES       __cpp_variadic_templates = 200704
++ *
++ * For any future version of the C++ standard, we use only the SD-6 macro.
++ * For full listing, see
++ *  http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
++ */
+ 
+ #ifdef Q_CC_INTEL
+ #  if __INTEL_COMPILER < 1200
+ #    define Q_NO_TEMPLATE_FRIENDS
+ #  endif
+-#  if defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__GXX_EXPERIMENTAL_CPP0X__)
++#  if __cplusplus >= 201103L
+ #    if __INTEL_COMPILER >= 1100
+ #      define Q_COMPILER_RVALUE_REFS
+ #      define Q_COMPILER_EXTERN_TEMPLATES
+@@ -849,6 +837,91 @@ namespace QT_NAMESPACE {}
+ #  endif
+ #endif
+ 
++#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
++#  if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
++    /* Detect C++ features using __has_feature(), see http://clang.llvm.org/docs/LanguageExtensions.html#cxx11 */
++#    if __has_feature(cxx_auto_type)
++#      define Q_COMPILER_AUTO_FUNCTION
++#      define Q_COMPILER_AUTO_TYPE
++#    endif
++#    if __has_feature(cxx_constexpr)
++#      define Q_COMPILER_CONSTEXPR
++#    endif
++#    if __has_feature(cxx_decltype) /* && __has_feature(cxx_decltype_incomplete_return_types) */
++#      define Q_COMPILER_DECLTYPE
++#    endif
++#    if __has_feature(cxx_defaulted_functions) && __has_feature(cxx_deleted_functions)
++#      define Q_COMPILER_DEFAULT_DELETE_MEMBERS
++#    endif
++#    if __has_feature(cxx_generalized_initializers)
++#      define Q_COMPILER_INITIALIZER_LISTS
++#    endif
++#    if __has_feature(cxx_lambdas)
++#      define Q_COMPILER_LAMBDA
++#    endif
++#    if __has_feature(cxx_rvalue_references)
++#      define Q_COMPILER_RVALUE_REFS
++#    endif
++#    if __has_feature(cxx_strong_enums)
++#      define Q_COMPILER_CLASS_ENUM
++#    endif
++#    if __has_feature(cxx_unicode_literals)
++#      define Q_COMPILER_UNICODE_STRINGS
++#    endif
++#    if __has_feature(cxx_variadic_templates)
++#      define Q_COMPILER_VARIADIC_TEMPLATES
++#    endif
++    /* Features that have no __has_feature() check */
++#    if ((__clang_major__ * 100) + __clang_minor__) >= 209 /* since clang 2.9 */
++#      define Q_COMPILER_EXTERN_TEMPLATES
++#    endif
++#  endif
++#endif
++
++#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG)
++#  if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
++#    if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
++       /* C++0x features supported in GCC 4.3: */
++#      define Q_COMPILER_RVALUE_REFS
++#      define Q_COMPILER_DECLTYPE
++#    endif
++#    if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
++       /* C++0x features supported in GCC 4.4: */
++#      define Q_COMPILER_VARIADIC_TEMPLATES
++#      define Q_COMPILER_AUTO_FUNCTION
++#      define Q_COMPILER_AUTO_TYPE
++#      define Q_COMPILER_EXTERN_TEMPLATES
++#      define Q_COMPILER_DEFAULT_DELETE_MEMBERS
++#      define Q_COMPILER_CLASS_ENUM
++#      define Q_COMPILER_INITIALIZER_LISTS
++#    endif
++#    if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
++       /* C++0x features supported in GCC 4.5: */
++#      define Q_COMPILER_LAMBDA
++#      define Q_COMPILER_UNICODE_STRINGS
++#    endif
++#    if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
++       /* C++0x features supported in GCC 4.6: */
++#      define Q_COMPILER_CONSTEXPR
++#    endif
++#  endif
++#endif
++
++#if defined(Q_CC_MSVC) && !defined(Q_CC_INTEL)
++#  if defined(__cplusplus)
++#    if _MSC_VER >= 1600
++       /* C++11 features supported in VC10 = VC2010: */
++#      define Q_COMPILER_AUTO_FUNCTION
++#      define Q_COMPILER_AUTO_TYPE
++#      define Q_COMPILER_DECLTYPE
++#      define Q_COMPILER_LAMBDA
++#      define Q_COMPILER_RVALUE_REFS
++//  MSVC's library has std::initializer_list, but the compiler does not support the braces initialization
++//#      define Q_COMPILER_INITIALIZER_LISTS
++#    endif
++#  endif
++#endif
++
+ #ifndef Q_PACKED
+ #  define Q_PACKED
+ #  undef Q_NO_PACKED_REFERENCE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407240837.s6O8btxp002944>