Patchwork [RFC,1/4] qt4: fix compile error in Qt 4.8.0 with gcc 4.6

login
register
mail settings
Submitter Paul Eggleton
Date Feb. 9, 2012, 5:57 p.m.
Message ID <6dd3f664169b2ffd249da4e86f5f16b8c4316c99.1328809777.git.paul.eggleton@linux.intel.com>
Download mbox | patch
Permalink /patch/21051/
State New
Headers show

Comments

Paul Eggleton - Feb. 9, 2012, 5:57 p.m.
Fix the following compile error (by disabling -Werror for QtWebKit):

./wtf/NullPtr.h:48:1: error: identifier 'nullptr' will become a keyword in C++0x [-Werror=c++0x-compat]

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 meta/recipes-qt/qt4/qt-4.8.0.inc                   |    1 +
 .../recipes-qt/qt4/qt-4.8.0/webkit_no_werror.patch |   19 +++++++++++++++++++
 meta/recipes-qt/qt4/qt4-embedded_4.8.0.bb          |    2 +-
 meta/recipes-qt/qt4/qt4-x11-free_4.8.0.bb          |    2 +-
 4 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-qt/qt4/qt-4.8.0/webkit_no_werror.patch
Khem Raj - Feb. 9, 2012, 9:19 p.m.
On Thu, Feb 9, 2012 at 9:57 AM, Paul Eggleton
<paul.eggleton@linux.intel.com> wrote:
> +Fix the following error during compiling with gcc 4.6:
> +
> +./wtf/NullPtr.h:48:1: error: identifier 'nullptr' will become a keyword in C++0x [-Werror=c++0x-compat]
> +
> +Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
> +
> +Upstream-Status: Pending
> +
> +--- qt-everywhere-opensource-src-4.8.0.orig/src/3rdparty/webkit/Source/WebKit.pri
> ++++ qt-everywhere-opensource-src-4.8.0/src/3rdparty/webkit/Source/WebKit.pri
> +@@ -102,8 +102,6 @@ CONFIG -= warn_on
> +
> + # Treat warnings as errors on x86/Linux/GCC
> + linux-g++* {
> +-    isEqual(QT_ARCH,x86_64)|isEqual(QT_ARCH,i386): QMAKE_CXXFLAGS += -Werror
> +-

since there is a namespace conflict that should be fixed IMO removing
Wrror is not quite the right
thing to do here IMO. Its a workaround but probably upstream wont
accept it. So change
nullptr here to something like qt_nullptr in source tree
Paul Eggleton - Feb. 10, 2012, 1:56 p.m.
On Thursday 09 February 2012 13:19:22 Khem Raj wrote:
> since there is a namespace conflict that should be fixed IMO removing
> Wrror is not quite the right thing to do here IMO.

So removing -Werror is somewhat heavy-handed, yes; perhaps we can simply
add -Wno-error=c++0x-compat and mark this patch as inappropriate for
upstreaming instead?

> Its a workaround but probably upstream wont
> accept it. So change nullptr here to something like qt_nullptr in source
> tree

What the code is attempting to do is provide its own "nullptr" if it isn't
being provided as part of the language:

------------------------------
#if __has_feature(cxx_nullptr) || (GCC_VERSION_AT_LEAST(4, 6, 0) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && _MSC_VER >= 1600 && !COMPILER(INTEL))

#define HAVE_NULLPTR 1

#else

namespace std {
    class nullptr_t { };
}

extern std::nullptr_t nullptr;

#endif
------------------------------

gcc 4.6 is preempting this and complaining about the use of the identifier. I
don't think renaming it is going to be acceptable upstream either.

Cheers,
Paul
Phil Blundell - Feb. 10, 2012, 2:03 p.m.
On Fri, 2012-02-10 at 13:56 +0000, Paul Eggleton wrote:
> What the code is attempting to do is provide its own "nullptr" if it isn't
> being provided as part of the language:
> 
> ------------------------------
> #if __has_feature(cxx_nullptr) || (GCC_VERSION_AT_LEAST(4, 6, 0) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && _MSC_VER >= 1600 && !COMPILER(INTEL))
> 
> #define HAVE_NULLPTR 1
> 
> #else
> 
> namespace std {
>     class nullptr_t { };
> }
> 
> extern std::nullptr_t nullptr;
> 
> #endif
> ------------------------------
> 
> gcc 4.6 is preempting this and complaining about the use of the identifier. I
> don't think renaming it is going to be acceptable upstream either.

Does it work if you build with -std=c++0x?  If Qt is doing the above
then presumably it is at least attempting to be compatible with C++0X.

p.
Paul Eggleton - Feb. 10, 2012, 2:09 p.m.
On Friday 10 February 2012 14:03:06 Phil Blundell wrote:
> On Fri, 2012-02-10 at 13:56 +0000, Paul Eggleton wrote:
> > What the code is attempting to do is provide its own "nullptr" if it isn't
> > being provided as part of the language:
> > 
> > ------------------------------
> > #if __has_feature(cxx_nullptr) || (GCC_VERSION_AT_LEAST(4, 6, 0) &&
> > defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && _MSC_VER >=
> > 1600 && !COMPILER(INTEL))
> > 
> > #define HAVE_NULLPTR 1
> > 
> > #else
> > 
> > namespace std {
> > 
> >     class nullptr_t { };
> > 
> > }
> > 
> > extern std::nullptr_t nullptr;
> > 
> > #endif
> > ------------------------------
> > 
> > gcc 4.6 is preempting this and complaining about the use of the
> > identifier. I don't think renaming it is going to be acceptable upstream
> > either.

> Does it work if you build with -std=c++0x?

It does, yes (well, compiling the above code on its own anyway).
Paul Eggleton - Feb. 10, 2012, 7:31 p.m.
On Friday 10 February 2012 13:56:44 Paul Eggleton wrote:
> On Thursday 09 February 2012 13:19:22 Khem Raj wrote:
> > since there is a namespace conflict that should be fixed IMO removing
> > Wrror is not quite the right thing to do here IMO.
> 
> So removing -Werror is somewhat heavy-handed, yes; perhaps we can simply
> add -Wno-error=c++0x-compat and mark this patch as inappropriate for
> upstreaming instead?

So, I dug further into this, and I discovered that the reason for this 
breaking was that the Qt configure script thought we were not using g++ as the 
C++ compiler (!) thus it did not detect the gcc version, and therefore when it 
came to the check to see if gcc 4.6+ was being used in order to add the -Wno-
c++0x-compat option to CXXFLAGS (which it already has code to do), the version 
was not set and the option was not added.

I've updated the contrib branch to fix this as well as reformat the other patch 
as Koen requested.

Cheers,
Paul
Khem Raj - Feb. 10, 2012, 8:36 p.m.
On Fri, Feb 10, 2012 at 11:31 AM, Paul Eggleton
<paul.eggleton@linux.intel.com> wrote:
>
> So, I dug further into this, and I discovered that the reason for this
> breaking was that the Qt configure script thought we were not using g++ as the
> C++ compiler (!) thus it did not detect the gcc version, and therefore when it
> came to the check to see if gcc 4.6+ was being used in order to add the -Wno-
> c++0x-compat option to CXXFLAGS (which it already has code to do), the version
> was not set and the option was not added.
>
> I've updated the contrib branch to fix this as well as reformat the other patch
> as Koen requested.

Thanks for redoing it.

Patch

diff --git a/meta/recipes-qt/qt4/qt-4.8.0.inc b/meta/recipes-qt/qt4/qt-4.8.0.inc
index 2addbb2..e251f0a 100644
--- a/meta/recipes-qt/qt4/qt-4.8.0.inc
+++ b/meta/recipes-qt/qt4/qt-4.8.0.inc
@@ -14,6 +14,7 @@  SRC_URI = "http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-${PV}.
            file://fix-translations.patch \
            file://add_nostrip_for_debug_packages.diff \
            file://qmake_cxx_eval.patch \
+           file://webkit_no_werror.patch \
            file://g++.conf \
            file://linux.conf \
            "
diff --git a/meta/recipes-qt/qt4/qt-4.8.0/webkit_no_werror.patch b/meta/recipes-qt/qt4/qt-4.8.0/webkit_no_werror.patch
new file mode 100644
index 0000000..90eb60e
--- /dev/null
+++ b/meta/recipes-qt/qt4/qt-4.8.0/webkit_no_werror.patch
@@ -0,0 +1,19 @@ 
+Fix the following error during compiling with gcc 4.6:
+
+./wtf/NullPtr.h:48:1: error: identifier 'nullptr' will become a keyword in C++0x [-Werror=c++0x-compat]
+
+Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
+
+Upstream-Status: Pending
+
+--- qt-everywhere-opensource-src-4.8.0.orig/src/3rdparty/webkit/Source/WebKit.pri
++++ qt-everywhere-opensource-src-4.8.0/src/3rdparty/webkit/Source/WebKit.pri
+@@ -102,8 +102,6 @@ CONFIG -= warn_on
+ 
+ # Treat warnings as errors on x86/Linux/GCC
+ linux-g++* {
+-    isEqual(QT_ARCH,x86_64)|isEqual(QT_ARCH,i386): QMAKE_CXXFLAGS += -Werror
+-
+     greaterThan(QT_GCC_MAJOR_VERSION, 3):greaterThan(QT_GCC_MINOR_VERSION, 5) {
+         if (!contains(QMAKE_CXXFLAGS, -std=c++0x) && !contains(QMAKE_CXXFLAGS, -std=gnu++0x)) {
+             # We need to deactivate those warnings because some names conflicts with upcoming c++0x types (e.g.nullptr).
diff --git a/meta/recipes-qt/qt4/qt4-embedded_4.8.0.bb b/meta/recipes-qt/qt4/qt4-embedded_4.8.0.bb
index 5c1c97e..efbc02a 100644
--- a/meta/recipes-qt/qt4/qt4-embedded_4.8.0.bb
+++ b/meta/recipes-qt/qt4/qt4-embedded_4.8.0.bb
@@ -1,7 +1,7 @@ 
 require qt-${PV}.inc
 require qt4-embedded.inc
 
-PR = "${INC_PR}.0"
+PR = "${INC_PR}.1"
 
 DEFAULT_PREFERENCE = "-1"
 
diff --git a/meta/recipes-qt/qt4/qt4-x11-free_4.8.0.bb b/meta/recipes-qt/qt4/qt4-x11-free_4.8.0.bb
index edd3e0e..6a0b0b8 100644
--- a/meta/recipes-qt/qt4/qt4-x11-free_4.8.0.bb
+++ b/meta/recipes-qt/qt4/qt4-x11-free_4.8.0.bb
@@ -1,7 +1,7 @@ 
 require qt4-x11-free.inc
 require qt-${PV}.inc
 
-PR = "${INC_PR}.0"
+PR = "${INC_PR}.1"
 
 DEFAULT_PREFERENCE = "-1"