To Marc Epsie (x11/qt4 maintainer) and ports list, The attached qt4-gcc8.diff is a set of patches for x11/qt4 to build it with lang/gcc/8 in OpenBSD ports. This is the same diff that I mailed on 19 Jan, but I got an error from the mailer daemon, and I didn't resend qt4-gcc8.diff until now. My diff is missing the REVISION bump.
For now, OpenBSD only uses ports-gcc 4.9 or clang, so nothing is broken. If, in the future, OpenBSD would switch ports-gcc from 4.9 to a newer version, then ports-gcc arches will fail to build qt4. The last release of qt4 was in 2015; the code is old; most problems are in qt4's old WebKit. I am using this diff on powerpc with gcc-8.2.0p0 to package qt4 and build ports that depend on qt4. I use lang/gcc/8 as ports-gcc by editing infrastructure/mk/gcc4.port.mk (MODGCC4_VERSION?=8) and devel/llvm/Makefile (GCC_VER = 8.2.0). I also tested this diff on amd64 with gcc-4.9.4p15, gcc-8.2.0p0, and base-clang 6. (To use ports-gcc, I did something like `make prepare` then `make package COMPILER=ports-gcc`. The package built with gcc is probably bad because I'm mixing libestdc++ from ports-gcc with libc++ from base-clang.) I didn't try to build qt4 with base-gcc. The new chunk in patch-configure allows gcc >= 6 to build QtWebKit. The other patches fix compiler errors. My patch comments mention "gcc 6" because I used the patches with lang/gcc/6 before I switched to gcc 8. The only change from gcc 6 to 8 was to edit patch*HashSet_h; I didn't try gcc 6 with this edit. Other distros (like Debian and NetBSD) probably have qt4 patches for newer gcc. It might be better to use their patches instead of mine. I saw some of NetBSD's patches, but I didn't want to copy their bigger changes to JavaScriptCore. The 2 patches named patch*MathExtras_h are unique to OpenBSD. -- George Koehler <kern...@gmail.com>
Index: patches/patch-configure =================================================================== RCS file: /cvs/ports/x11/qt4/patches/patch-configure,v retrieving revision 1.27 diff -u -p -r1.27 patch-configure --- patches/patch-configure 3 Jun 2015 07:28:01 -0000 1.27 +++ patches/patch-configure 11 Jan 2019 04:16:12 -0000 @@ -1,6 +1,7 @@ $OpenBSD: patch-configure,v 1.27 2015/06/03 07:28:01 dcoppa Exp $ ---- configure.orig Thu May 7 16:14:56 2015 -+++ configure Sun May 31 13:28:28 2015 +Index: configure +--- configure.orig ++++ configure @@ -918,7 +918,7 @@ CFG_SILENT=no CFG_GRAPHICS_SYSTEM=default CFG_RUNTIME_SYSTEM= @@ -37,3 +38,12 @@ $OpenBSD: patch-configure,v 1.27 2015/06 [ '!' -z "$QCONFIG_H" ] && mv -f "$QCONFIG_H" "$QMAKE_QCONFIG_H" #move qmake's qconfig.h to qconfig.h.qmake [ '!' -z "$OLD_QCONFIG_H" ] && mv -f "${OLD_QCONFIG_H}.old" "$OLD_QCONFIG_H" #put back qconfig.h [ "$QMAKE_BUILD_ERROR" = "yes" ] && exit 2 +@@ -7734,7 +7734,7 @@ case "$XPLATFORM" in + *-g++*) + # Check gcc's version + case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in +- 5*|4*|3.4*) ++ [1-9][0-9]*|[4-9]*|3.4*) + ;; + 3.3*) + canBuildWebKit="no" Index: patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Structure_cpp =================================================================== RCS file: patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Structure_cpp diff -N patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Structure_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Structure_cpp 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Prevent "error: cannot bind bitfield..." in gcc 6. +https://bugs.webkit.org/show_bug.cgi?id=59261 + +Index: src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.cpp +--- src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.cpp.orig ++++ src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.cpp +@@ -157,7 +157,7 @@ Structure::~Structure() + { + if (m_previous) { + if (m_nameInPrevious) +- m_previous->table.remove(StructureTransitionTableHash::Key(RefPtr<UString::Rep>(m_nameInPrevious.get()), m_attributesInPrevious), m_specificValueInPrevious); ++ m_previous->table.remove(StructureTransitionTableHash::Key(RefPtr<UString::Rep>(m_nameInPrevious.get()), +m_attributesInPrevious), m_specificValueInPrevious); + else + m_previous->table.removeAnonymousSlotTransition(m_anonymousSlotsInPrevious); + Index: patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Structure_h =================================================================== RCS file: patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Structure_h diff -N patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Structure_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Structure_h 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,17 @@ +$OpenBSD$ + +Prevent "error: cannot bind bitfield..." in gcc 6. +https://bugs.webkit.org/show_bug.cgi?id=59261 + +Index: src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.h +--- src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.h.orig ++++ src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.h +@@ -317,7 +317,7 @@ namespace JSC { + TransitionTable* transitionTable = new TransitionTable; + setTransitionTable(transitionTable); + if (existingTransition) +- add(StructureTransitionTableHash::Key(RefPtr<UString::Rep>(existingTransition->m_nameInPrevious.get()), existingTransition->m_attributesInPrevious), existingTransition, existingTransition->m_specificValueInPrevious); ++ add(StructureTransitionTableHash::Key(RefPtr<UString::Rep>(existingTransition->m_nameInPrevious.get()), +existingTransition->m_attributesInPrevious), existingTransition, existingTransition->m_specificValueInPrevious); + } + } // namespace JSC + Index: patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_HashTable_h =================================================================== RCS file: patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_HashTable_h diff -N patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_HashTable_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_HashTable_h 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,16 @@ +$OpenBSD$ + +Disable QTWTF::swap to prevent conflict with std::swap in gcc 6. + +Index: src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashTable.h +--- src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashTable.h.orig ++++ src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashTable.h +@@ -257,7 +257,7 @@ namespace WTF { + + using std::swap; + +-#if !COMPILER(MSVC) && !OS(QNX) && !defined(_LIBCPP_VERSION) ++#if 0 && !COMPILER(MSVC) && !OS(QNX) && !defined(_LIBCPP_VERSION) + // The Dinkumware C++ library (used by MSVC and QNX) and clang's libc++ have a swap for pairs defined. + + // swap pairs by component, in case of pair members that specialize swap Index: patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_MathExtras_h =================================================================== RCS file: patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_MathExtras_h diff -N patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_MathExtras_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_MathExtras_h 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,18 @@ +$OpenBSD$ + +Don't define ::isfinite and ::signbit. These conflict with +std::isfinite and std::signbit in gcc 6, cause errors +'call of overloaded... is ambigous'. + +Index: src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h +--- src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h.orig ++++ src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h +@@ -85,7 +85,7 @@ inline bool signbit(double x) { return x < 0.0; } // F + + #endif + +-#if OS(OPENBSD) ++#if 0 && OS(OPENBSD) + + #ifndef isfinite + inline bool isfinite(double x) { return finite(x); } Index: patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_TypeTraits_h =================================================================== RCS file: patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_TypeTraits_h diff -N patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_TypeTraits_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_TypeTraits_h 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,26 @@ +$OpenBSD$ + +Disable __GLIBCXX__ code to prevent error from gcc 6: +error: 'std::tr1' has not been declared + +Index: src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h +--- src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h.orig ++++ src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h +@@ -24,7 +24,7 @@ + + #include "Platform.h" + +-#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) ++#if (0 && defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) + #include <type_traits> + #endif + +@@ -166,7 +166,7 @@ namespace WTF { + typedef T Type; + }; + +-#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) ++#if (0 && defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) + + // GCC's libstdc++ 20070724 and later supports C++ TR1 type_traits in the std namespace. + // VC10 (VS2010) and later support C++ TR1 type_traits in the std::tr1 namespace. Index: patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_HashSet_h =================================================================== RCS file: patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_HashSet_h diff -N patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_HashSet_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_HashSet_h 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,36 @@ +$OpenBSD$ + +Prevent error from gcc 6: +HashSet.h:191:32: error: could not convert ... +from 'std::pair<WTF::HashTableIterator<...>, bool>' +to 'std::pair<WTF::HashTableConstIteratorAdapter<...>, bool>' + +gcc 6 accepts 'pair<iterator, bool>(p.first, p.second)' but gcc 8 +needs 'iterator(p.first)' to convert the iterator. + +The iterator_const_cast for MSVC doesn't work in gcc 6. + +Index: src/3rdparty/webkit/Source/JavaScriptCore/wtf/HashSet.h +--- src/3rdparty/webkit/Source/JavaScriptCore/wtf/HashSet.h.orig ++++ src/3rdparty/webkit/Source/JavaScriptCore/wtf/HashSet.h +@@ -188,7 +188,8 @@ namespace WTF { + #if COMPILER(MSVC) && _MSC_VER >= 1700 + return iterator_const_cast(m_impl.add(value)); + #else +- return m_impl.add(value); ++ pair<typename HashTableType::iterator, bool> p = m_impl.add(value); ++ return pair<iterator, bool>(iterator(p.first), p.second); + #endif + } + +@@ -201,7 +202,9 @@ namespace WTF { + #if COMPILER(MSVC) && _MSC_VER >= 1700 + return iterator_const_cast(m_impl.template addPassingHashCode<T, T, Adapter>(value, value)); + #else +- return m_impl.template addPassingHashCode<T, T, Adapter>(value, value); ++ pair<typename HashTableType::iterator, bool> p = ++ m_impl.template addPassingHashCode<T, T, Adapter>(value, value); ++ return pair<iterator, bool>(iterator(p.first), p.second); + #endif + } + Index: patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_MathExtras_h =================================================================== RCS file: patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_MathExtras_h diff -N patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_MathExtras_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_MathExtras_h 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,18 @@ +$OpenBSD$ + +Don't define ::isfinite and ::signbit. These conflict with +std::isfinite and std::signbit in gcc 6, cause errors +'call of overloaded... is ambigous'. + +Index: src/3rdparty/webkit/Source/JavaScriptCore/wtf/MathExtras.h +--- src/3rdparty/webkit/Source/JavaScriptCore/wtf/MathExtras.h.orig ++++ src/3rdparty/webkit/Source/JavaScriptCore/wtf/MathExtras.h +@@ -99,7 +99,7 @@ inline bool signbit(double x) { return copysign(1.0, x + + #endif + +-#if OS(OPENBSD) ++#if 0 && OS(OPENBSD) + + #ifndef isfinite + inline bool isfinite(double x) { return finite(x); } Index: patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_TypeTraits_h =================================================================== RCS file: patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_TypeTraits_h diff -N patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_TypeTraits_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_TypeTraits_h 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,26 @@ +$OpenBSD$ + +Disable __GLIBCXX__ code to prevent error from gcc 6: +error: 'std::tr1' has not been declared + +Index: src/3rdparty/webkit/Source/JavaScriptCore/wtf/TypeTraits.h +--- src/3rdparty/webkit/Source/JavaScriptCore/wtf/TypeTraits.h.orig ++++ src/3rdparty/webkit/Source/JavaScriptCore/wtf/TypeTraits.h +@@ -24,7 +24,7 @@ + + #include "Platform.h" + +-#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) ++#if (0 && defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) + #include <type_traits> + #endif + +@@ -179,7 +179,7 @@ namespace WTF { + typedef T Type; + }; + +-#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) ++#if (0 && defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) + + // GCC's libstdc++ 20070724 and later supports C++ TR1 type_traits in the std namespace. + // VC10 (VS2010) and later support C++ TR1 type_traits in the std::tr1 namespace. Index: patches/patch-src_3rdparty_webkit_Source_WebCore_dom_Element_cpp =================================================================== RCS file: patches/patch-src_3rdparty_webkit_Source_WebCore_dom_Element_cpp diff -N patches/patch-src_3rdparty_webkit_Source_WebCore_dom_Element_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_3rdparty_webkit_Source_WebCore_dom_Element_cpp 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,18 @@ +$OpenBSD$ + +Prevent error from gcc 6. +Element.cpp:1083:60: error: operands to ?: have different types +'WebCore::RenderStyle*' and 'bool' + +Index: src/3rdparty/webkit/Source/WebCore/dom/Element.cpp +--- src/3rdparty/webkit/Source/WebCore/dom/Element.cpp.orig ++++ src/3rdparty/webkit/Source/WebCore/dom/Element.cpp +@@ -1080,7 +1080,7 @@ void Element::recalcStyle(StyleChange change) + { + // Ref currentStyle in case it would otherwise be deleted when setRenderStyle() is called. + RefPtr<RenderStyle> currentStyle(renderStyle()); +- bool hasParentStyle = parentNodeForRenderingAndStyle() ? parentNodeForRenderingAndStyle()->renderStyle() : false; ++ bool hasParentStyle = parentNodeForRenderingAndStyle() ? bool(parentNodeForRenderingAndStyle()->renderStyle()) : false; + bool hasDirectAdjacentRules = currentStyle && currentStyle->childrenAffectedByDirectAdjacentRules(); + bool hasIndirectAdjacentRules = currentStyle && currentStyle->childrenAffectedByForwardPositionalRules(); + Index: patches/patch-src_plugins_accessible_widgets_itemviews_cpp =================================================================== RCS file: patches/patch-src_plugins_accessible_widgets_itemviews_cpp diff -N patches/patch-src_plugins_accessible_widgets_itemviews_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_plugins_accessible_widgets_itemviews_cpp 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,23 @@ +$OpenBSD$ + +Fix build with gcc 6: +error: invalid conversion from 'int' to +'QItemSelectionModel::SelectionFlag' [-fpermissive] + +Columns & Deselect = 0x0040 & 0x0004 = 0 is an int, but +Columns | Deselect calls Qt's operator | and returns a Qt internal type +to allow the conversion. Qt also allows a conversion from constant 0, +but gcc 6 seems not to allow Columns & Deselect as constant 0. + +Index: src/plugins/accessible/widgets/itemviews.cpp +--- src/plugins/accessible/widgets/itemviews.cpp.orig ++++ src/plugins/accessible/widgets/itemviews.cpp +@@ -393,7 +393,7 @@ bool QAccessibleTable2::unselectColumn(int column) + QModelIndex index = view()->model()->index(0, column, view()->rootIndex()); + if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection) + return false; +- view()->selectionModel()->select(index, QItemSelectionModel::Columns & QItemSelectionModel::Deselect); ++ view()->selectionModel()->select(index, QItemSelectionModel::Columns | QItemSelectionModel::Deselect); + return true; + } + Index: patches/patch-src_xmlpatterns_api_qcoloroutput_p_h =================================================================== RCS file: patches/patch-src_xmlpatterns_api_qcoloroutput_p_h diff -N patches/patch-src_xmlpatterns_api_qcoloroutput_p_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_xmlpatterns_api_qcoloroutput_p_h 11 Jan 2019 04:16:12 -0000 @@ -0,0 +1,21 @@ +$OpenBSD$ + +Use unsigned arithmetic to prevent signed overflow error from gcc 6. +error: shift expression '(1048575 << 20)' overflows [-fpermissive] +error: enumerator value for 'BackgroundMask' is not an integer constant + +BackgroundMask overflows because it sets bits 20 to 39, but there are +no bits above 31 in an int. + +Index: src/xmlpatterns/api/qcoloroutput_p.h +--- src/xmlpatterns/api/qcoloroutput_p.h.orig ++++ src/xmlpatterns/api/qcoloroutput_p.h +@@ -71,7 +71,7 @@ namespace QPatternist + BackgroundShift = 20, + SpecialShift = 20, + ForegroundMask = ((1 << ForegroundShift) - 1) << ForegroundShift, +- BackgroundMask = ((1 << BackgroundShift) - 1) << BackgroundShift ++ BackgroundMask = ((1U << BackgroundShift) - 1) << BackgroundShift + }; + + public: