[packages/qtscriptgenerator] - fix format string error - fix memory alignments (from debian) - replacing all of CXXFLAGS causes m
baggins
baggins at pld-linux.org
Sat Jan 25 11:26:18 CET 2014
commit 8767a79196de8ce24efe874f18fd15e8a49dae2d
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Sat Jan 25 11:25:09 2014 +0100
- fix format string error
- fix memory alignments (from debian)
- replacing all of CXXFLAGS causes miscomiplation, just add our optflags to make
format-security.patch | 11 ++++
memory-alignment-fix.patch | 125 +++++++++++++++++++++++++++++++++++++++++++++
optflags.patch | 12 +++++
qtscriptgenerator.spec | 14 +++--
4 files changed, 158 insertions(+), 4 deletions(-)
---
diff --git a/qtscriptgenerator.spec b/qtscriptgenerator.spec
index 084ab52..e16395d 100644
--- a/qtscriptgenerator.spec
+++ b/qtscriptgenerator.spec
@@ -14,6 +14,9 @@ Source0: http://qtscriptgenerator.googlecode.com/files/%{name}-src-%{version}.ta
# Source0-md5: 9f82b0aa212f7938de37df46cd27165c
Patch0: %{name}-qthreadpool.patch
Patch1: %{name}-no_phonon.patch
+Patch2: format-security.patch
+Patch3: memory-alignment-fix.patch
+Patch4: optflags.patch
URL: http://code.google.com/p/qtscriptgenerator/
BuildRequires: QtCore-devel
BuildRequires: QtGui-devel
@@ -48,6 +51,9 @@ within Qt Script.
%setup -q -n %{name}-src-%{version}
%patch0 -p0
%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
%build
export QTDIR="%{_libdir}/qt4"
@@ -56,10 +62,10 @@ export INCLUDE="%{_includedir}/qt4"
for dir in generator qtbindings tools/qsexec/src; do
cd $dir
qmake-qt4
- %{__make} \
- CXX="%{__cxx}" \
- CXXFLAGS="%{rpmcxxflags} -fPIC"\
- CFLAGS="%{rpmcflags}"
+ %{__make} \
+ CXX="%{__cxx}" \
+ OPTCXXFLAGS="%{rpmcxxflags} -fPIC" \
+ OPTCFLAGS="%{rpmcflags} -fPIC"
test "$dir" == "generator" && ./generator
cd -
diff --git a/format-security.patch b/format-security.patch
new file mode 100644
index 0000000..18735ad
--- /dev/null
+++ b/format-security.patch
@@ -0,0 +1,11 @@
+--- a/generator/reporthandler.cpp
++++ b/generator/reporthandler.cpp
+@@ -57,7 +57,7 @@ void ReportHandler::warning(const QStrin
+ if (db && db->isSuppressedWarning(warningText)) {
+ ++m_suppressed_count;
+ } else if (!m_reported_warnings.contains(warningText)) {
+- qDebug(qPrintable(warningText));
++ qDebug() << warningText;
+ ++m_warning_count;
+
+ m_reported_warnings.insert(warningText);
diff --git a/memory-alignment-fix.patch b/memory-alignment-fix.patch
new file mode 100644
index 0000000..cb314c1
--- /dev/null
+++ b/memory-alignment-fix.patch
@@ -0,0 +1,125 @@
+From: Modestas Vainius <modestas at vainius.eu>
+Subject: [PATCH] Memory alignment fixes
+
+Fixes various memory alignment issues which cause generator to crash on
+alignment-sensitive architectures.
+
+Signed-off-by: Modestas Vainius <modestas at vainius.eu>
+
+---
+ generator/parser/ast.h | 2 +-
+ generator/parser/list.h | 2 +-
+ generator/parser/rpp/pp-symbol.h | 9 +++++++--
+ generator/parser/rxx_allocator.h | 17 +++++++++++++++++
+ generator/parser/smallobject.h | 6 ++++++
+ 5 files changed, 32 insertions(+), 4 deletions(-)
+
+--- a/generator/parser/ast.h
++++ b/generator/parser/ast.h
+@@ -880,7 +880,7 @@ struct QEnumsAST : public DeclarationAST
+ template <class _Tp>
+ _Tp *CreateNode(pool *memory_pool)
+ {
+- _Tp *node = reinterpret_cast<_Tp*>(memory_pool->allocate(sizeof(_Tp)));
++ _Tp *node = reinterpret_cast<_Tp*>(memory_pool->allocate(sizeof(_Tp), strideof(_Tp)));
+ node->kind = _Tp::__node_kind;
+ return node;
+ }
+--- a/generator/parser/list.h
++++ b/generator/parser/list.h
+@@ -54,7 +54,7 @@ struct ListNode
+
+ static ListNode *create(const Tp &element, pool *p)
+ {
+- ListNode<Tp> *node = new (p->allocate(sizeof(ListNode))) ListNode();
++ ListNode<Tp> *node = new (p->allocate(sizeof(ListNode), strideof(ListNode))) ListNode();
+ node->element = element;
+ node->index = 0;
+ node->next = node;
+--- a/generator/parser/rpp/pp-symbol.h
++++ b/generator/parser/rpp/pp-symbol.h
+@@ -51,6 +51,11 @@ class pp_symbol
+ static rxx_allocator<char>__allocator;
+ return __allocator;
+ }
++ static rxx_allocator<pp_fast_string> &ppfs_allocator_instance ()
++ {
++ static rxx_allocator<pp_fast_string>__ppfs_allocator;
++ return __ppfs_allocator;
++ }
+
+ public:
+ static int &N()
+@@ -66,7 +71,7 @@ public:
+ memcpy(data, __data, __size);
+ data[__size] = '\0';
+
+- char *where = allocator_instance ().allocate (sizeof (pp_fast_string));
++ pp_fast_string *where = ppfs_allocator_instance ().allocate (sizeof (pp_fast_string));
+ return new (where) pp_fast_string (data, __size);
+ }
+
+@@ -86,7 +91,7 @@ public:
+ std::copy (__first, __last, data);
+ data[__size] = '\0';
+
+- char *where = allocator_instance ().allocate (sizeof (pp_fast_string));
++ pp_fast_string *where = ppfs_allocator_instance ().allocate (sizeof (pp_fast_string));
+ return new (where) pp_fast_string (data, __size);
+ }
+
+--- a/generator/parser/rxx_allocator.h
++++ b/generator/parser/rxx_allocator.h
+@@ -48,6 +48,17 @@
+ #include <cstring>
+ #include <memory>
+
++// Stride calculation
++template <typename T>
++struct Tchar {
++ T t;
++ char c;
++};
++
++#define strideof(T) \
++ ((sizeof(Tchar<T>) > sizeof(T)) ? \
++ sizeof(Tchar<T>)-sizeof(T) : sizeof(T))
++
+ template <class _Tp> class rxx_allocator {
+ public:
+ typedef _Tp value_type;
+@@ -106,6 +117,12 @@ public:
+ return p;
+ }
+
++ pointer allocate(size_type __n, size_type stride, const void* = 0) {
++ if (reinterpret_cast<size_type>(_M_current_block + _M_current_index) % stride > 0)
++ _M_current_index += stride - reinterpret_cast<size_type>(_M_current_block + _M_current_index) % stride;
++ return allocate(__n);
++ }
++
+ void deallocate(pointer __p, size_type __n) {}
+
+ size_type max_size() const { return size_type(-1) / sizeof(_Tp); }
+--- a/generator/parser/smallobject.h
++++ b/generator/parser/smallobject.h
+@@ -52,6 +52,7 @@ class pool
+
+ public:
+ inline void *allocate(std::size_t __size);
++ inline void *allocate(std::size_t __size, std::size_t __stride);
+ };
+
+ inline void *pool::allocate(std::size_t __size)
+@@ -59,6 +60,11 @@ inline void *pool::allocate(std::size_t
+ return __alloc.allocate(__size);
+ }
+
++inline void *pool::allocate(std::size_t __size, std::size_t __stride)
++{
++ return __alloc.allocate(__size, __stride);
++}
++
+ #endif
+
+ // kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/optflags.patch b/optflags.patch
new file mode 100644
index 0000000..3e86a78
--- /dev/null
+++ b/optflags.patch
@@ -0,0 +1,12 @@
+--- qtscriptgenerator-src-0.2.0/generator/generator.pri~ 2012-01-23 12:30:03.000000000 +0100
++++ qtscriptgenerator-src-0.2.0/generator/generator.pri 2014-01-25 11:21:38.203799933 +0100
+@@ -60,6 +60,9 @@
+
+ QT = core xml
+
++QMAKE_CXXFLAGS += $(OPTCXXFLAGS)
++QMAKE_CFLAGS += $(OPTCFLAGS)
++
+ win32-msvc.net {
+ QMAKE_CXXFLAGS += /Zm500
+ QMAKE_CXXFLAGS -= -Zm200
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/qtscriptgenerator.git/commitdiff/8767a79196de8ce24efe874f18fd15e8a49dae2d
More information about the pld-cvs-commit
mailing list