[Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

View: New views
12 Messages — Rating Filter:   Alert me  

[Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Bugzilla from arvidjaar@mail.ru :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm trying to build aqemu. It fails on printf format error, but
disabling it in specs is ineffective; Makefile is generated by qmake and
C(XX)FLAGS are statically set in Makefile.

Unfortunately using make CFLAGS=... does not work either because CFLAGS
are built from other variables as well:

CXXFLAGS      = -pipe -O2 -g -pipe -Wformat -Werror=format-security -
Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-
buffer-size=4 -Wall -W -D_REENTRANT $(DEFINES)

I hope, that it is possible to override template CFLAGS during qmake
invocation. Is it possible?


signature.asc (204 bytes) Download Attachment

Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Amrein-Marie Christophe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le dimanche 05 juillet 2009 à 13:23 +0400, Andrey Borzenkov a écrit :

> I'm trying to build aqemu. It fails on printf format error, but
> disabling it in specs is ineffective; Makefile is generated by qmake and
> C(XX)FLAGS are statically set in Makefile.
>
> Unfortunately using make CFLAGS=... does not work either because CFLAGS
> are built from other variables as well:
>
> CXXFLAGS      = -pipe -O2 -g -pipe -Wformat -Werror=format-security -
> Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-
> buffer-size=4 -Wall -W -D_REENTRANT $(DEFINES)
>
> I hope, that it is possible to override template CFLAGS during qmake
> invocation. Is it possible?


Use %{qmake_qt4} to create the Makefiles in your rpm .spec file.


Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Bugzilla from arvidjaar@mail.ru :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 05 of July 2009 13:31:05 Amrein-Marie Christophe wrote:

> Le dimanche 05 juillet 2009 à 13:23 +0400, Andrey Borzenkov a écrit :
> > I'm trying to build aqemu. It fails on printf format error, but
> > disabling it in specs is ineffective; Makefile is generated by
> > qmake and C(XX)FLAGS are statically set in Makefile.
> >
> > Unfortunately using make CFLAGS=... does not work either because
> > CFLAGS are built from other variables as well:
> >
> > CXXFLAGS      = -pipe -O2 -g -pipe -Wformat -Werror=format-security
> > - Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
> > --param=ssp- buffer-size=4 -Wall -W -D_REENTRANT $(DEFINES)
> >
> > I hope, that it is possible to override template CFLAGS during
> > qmake invocation. Is it possible?
>
> Use %{qmake_qt4} to create the Makefiles in your rpm .spec file.
This does not work because our qmake templates *unconditionally* add
options (have you actually tried it? Passing QMAKE_CXXFLAGS at qmake
invocation was the first thing I tried :) )

+ CPPFLAGS='-O2 -g -pipe  -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-
protector --param=ssp-buffer-size=4 -DPIC -fPIC'
+ export CPPFLAGS
+ /usr/lib/qt4/bin/qmake 'QMAKE_CFLAGS=-O2 -g -pipe  -Wp,-
D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-
size=4 -DPIC -fPIC' 'QMAKE_CXXFLAGS=-O2 -g -pipe  -Wp,-
D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-
size=4 -DPIC -fPIC' 'QMAKE_LFLAGS= -Wl,--as-needed -Wl,--no-undefined -
Wl,-z,relro' AQEMU.pro
+ make
make -f Makefile.Release
...
g++ -c -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-
protector --param=ssp-buffer-size=4 -DPIC -fPIC -O2 -g -pipe -Wformat -
Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-
protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -DVNC_DISPLAY
-DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -
DQT_SHARED -I/usr/lib/qt4/mkspecs/linux-g++ -I. -
I/usr/lib/qt4/include/QtCore -I/usr/lib/qt4/include/QtNetwork -
I/usr/lib/qt4/include/QtGui -I/usr/lib/qt4/include/QtXml -
I/usr/lib/qt4/include -I/usr/lib/qt4/include/QtTest -I. -Irelease -I. -o
release/About_Window.o About_Window.cpp


signature.asc (204 bytes) Download Attachment

Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Amrein-Marie Christophe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le dimanche 05 juillet 2009 à 14:08 +0400, Andrey Borzenkov a écrit :

> On Sunday 05 of July 2009 13:31:05 Amrein-Marie Christophe wrote:
> > Le dimanche 05 juillet 2009 à 13:23 +0400, Andrey Borzenkov a écrit :
> > > I'm trying to build aqemu. It fails on printf format error, but
> > > disabling it in specs is ineffective; Makefile is generated by
> > > qmake and C(XX)FLAGS are statically set in Makefile.
> > >
> > > Unfortunately using make CFLAGS=... does not work either because
> > > CFLAGS are built from other variables as well:
> > >
> > > CXXFLAGS      = -pipe -O2 -g -pipe -Wformat -Werror=format-security
> > > - Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
> > > --param=ssp- buffer-size=4 -Wall -W -D_REENTRANT $(DEFINES)
> > >
> > > I hope, that it is possible to override template CFLAGS during
> > > qmake invocation. Is it possible?
> >
> > Use %{qmake_qt4} to create the Makefiles in your rpm .spec file.
>
> This does not work because our qmake templates *unconditionally* add
> options (have you actually tried it? Passing QMAKE_CXXFLAGS at qmake
> invocation was the first thing I tried :) )

Well, I built an rpm package for test. I just used:

>
> + CPPFLAGS='-O2 -g -pipe  -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-
> protector --param=ssp-buffer-size=4 -DPIC -fPIC'
> + export CPPFLAGS
> + /usr/lib/qt4/bin/qmake 'QMAKE_CFLAGS=-O2 -g -pipe  -Wp,-
> D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-
> size=4 -DPIC -fPIC' 'QMAKE_CXXFLAGS=-O2 -g -pipe  -Wp,-
> D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-
> size=4 -DPIC -fPIC' 'QMAKE_LFLAGS= -Wl,--as-needed -Wl,--no-undefined -
> Wl,-z,relro' AQEMU.pro
> + make
> make -f Makefile.Release
> ...
> g++ -c -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-
> protector --param=ssp-buffer-size=4 -DPIC -fPIC -O2 -g -pipe -Wformat -
> Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-
> protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -DVNC_DISPLAY
> -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -
> DQT_SHARED -I/usr/lib/qt4/mkspecs/linux-g++ -I. -
> I/usr/lib/qt4/include/QtCore -I/usr/lib/qt4/include/QtNetwork -
> I/usr/lib/qt4/include/QtGui -I/usr/lib/qt4/include/QtXml -
> I/usr/lib/qt4/include -I/usr/lib/qt4/include/QtTest -I. -Irelease -I. -o
> release/About_Window.o About_Window.cpp


Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Amrein-Marie Christophe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le dimanche 05 juillet 2009 à 14:17 +0200, Amrein-Marie Christophe a
écrit :

> Le dimanche 05 juillet 2009 à 14:08 +0400, Andrey Borzenkov a écrit :
> > On Sunday 05 of July 2009 13:31:05 Amrein-Marie Christophe wrote:
> > > Le dimanche 05 juillet 2009 à 13:23 +0400, Andrey Borzenkov a écrit :
> > > > I'm trying to build aqemu. It fails on printf format error, but
> > > > disabling it in specs is ineffective; Makefile is generated by
> > > > qmake and C(XX)FLAGS are statically set in Makefile.
> > > >
> > > > Unfortunately using make CFLAGS=... does not work either because
> > > > CFLAGS are built from other variables as well:
> > > >
> > > > CXXFLAGS      = -pipe -O2 -g -pipe -Wformat -Werror=format-security
> > > > - Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
> > > > --param=ssp- buffer-size=4 -Wall -W -D_REENTRANT $(DEFINES)
> > > >
> > > > I hope, that it is possible to override template CFLAGS during
> > > > qmake invocation. Is it possible?
> > >
> > > Use %{qmake_qt4} to create the Makefiles in your rpm .spec file.
> >
> > This does not work because our qmake templates *unconditionally* add
> > options (have you actually tried it? Passing QMAKE_CXXFLAGS at qmake
> > invocation was the first thing I tried :) )
>
Well, I built an rpm package for test. I just used:

# %{qmake_qt4} AQEMU.pro
# %make

And the "litteral error" issue was resolved with qDebug("%s", ...)
because I didn't think it was your issue.

> >
> > + CPPFLAGS='-O2 -g -pipe  -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-
> > protector --param=ssp-buffer-size=4 -DPIC -fPIC'
> > + export CPPFLAGS
> > + /usr/lib/qt4/bin/qmake 'QMAKE_CFLAGS=-O2 -g -pipe  -Wp,-
> > D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-
> > size=4 -DPIC -fPIC' 'QMAKE_CXXFLAGS=-O2 -g -pipe  -Wp,-
> > D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-
> > size=4 -DPIC -fPIC' 'QMAKE_LFLAGS= -Wl,--as-needed -Wl,--no-undefined -
> > Wl,-z,relro' AQEMU.pro
> > + make
> > make -f Makefile.Release
> > ...
> > g++ -c -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-
> > protector --param=ssp-buffer-size=4 -DPIC -fPIC -O2 -g -pipe -Wformat -
> > Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-
> > protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -DVNC_DISPLAY
> > -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -
> > DQT_SHARED -I/usr/lib/qt4/mkspecs/linux-g++ -I. -
> > I/usr/lib/qt4/include/QtCore -I/usr/lib/qt4/include/QtNetwork -
> > I/usr/lib/qt4/include/QtGui -I/usr/lib/qt4/include/QtXml -
> > I/usr/lib/qt4/include -I/usr/lib/qt4/include/QtTest -I. -Irelease -I. -o
> > release/About_Window.o About_Window.cpp


Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Bugzilla from arvidjaar@mail.ru :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 05 of July 2009 16:19:08 Amrein-Marie Christophe wrote:

> And the "litteral error" issue was resolved with qDebug("%s", ...)
> because I didn't think it was your issue.
>

Pardon me, but I did not ask how to patch source code. I thought,
question was clear enough.


signature.asc (204 bytes) Download Attachment

Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Christophe Fergeau-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrey Borzenkov a écrit :
> Pardon me, but I did not ask how to patch source code. I thought,
> question was clear enough.
>  

Why you want to workaround the problem by changing the CFLAGS rather
than fixing it in the source is a good question though ;)

Christophe



Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Jérôme Martin-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le jeudi 9 juillet 2009, Christophe Fergeau a écrit :
> Andrey Borzenkov a écrit :
> > Pardon me, but I did not ask how to patch source code. I thought,
> > question was clear enough.
>
> Why you want to workaround the problem by changing the CFLAGS rather
> than fixing it in the source is a good question though ;)
>
> Christophe
May be because it is not possible :
http://qa.mandriva.com/show_bug.cgi?id=51155



signature.asc (204 bytes) Download Attachment

Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Anssi Hannula-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrey Borzenkov wrote:

> On Sunday 05 of July 2009 13:31:05 Amrein-Marie Christophe wrote:
>> Le dimanche 05 juillet 2009 à 13:23 +0400, Andrey Borzenkov a écrit :
>>> I'm trying to build aqemu. It fails on printf format error, but
>>> disabling it in specs is ineffective; Makefile is generated by
>>> qmake and C(XX)FLAGS are statically set in Makefile.
>>>
>>> Unfortunately using make CFLAGS=... does not work either because
>>> CFLAGS are built from other variables as well:
>>>
>>> CXXFLAGS      = -pipe -O2 -g -pipe -Wformat -Werror=format-security
>>> - Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
>>> --param=ssp- buffer-size=4 -Wall -W -D_REENTRANT $(DEFINES)
>>>
>>> I hope, that it is possible to override template CFLAGS during
>>> qmake invocation. Is it possible?
>> Use %{qmake_qt4} to create the Makefiles in your rpm .spec file.
>
> This does not work because our qmake templates *unconditionally* add
> options (have you actually tried it? Passing QMAKE_CXXFLAGS at qmake
> invocation was the first thing I tried :) )

Look at /usr/lib/qt4/mkspecs/common/g++.conf.

So, pass QMAKE_CXXFLAGS_RELEASE="%optflags" to qmake, it works :)

Probably %qmake_qt4 should also be fixed.

--
Anssi Hannula

Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Amrein-Marie Christophe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le vendredi 10 juillet 2009 à 16:33 +0300, Anssi Hannula a écrit :

> Andrey Borzenkov wrote:
> > On Sunday 05 of July 2009 13:31:05 Amrein-Marie Christophe wrote:
> >> Le dimanche 05 juillet 2009 à 13:23 +0400, Andrey Borzenkov a écrit :
> >>> I'm trying to build aqemu. It fails on printf format error, but
> >>> disabling it in specs is ineffective; Makefile is generated by
> >>> qmake and C(XX)FLAGS are statically set in Makefile.
> >>>
> >>> Unfortunately using make CFLAGS=... does not work either because
> >>> CFLAGS are built from other variables as well:
> >>>
> >>> CXXFLAGS      = -pipe -O2 -g -pipe -Wformat -Werror=format-security
> >>> - Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
> >>> --param=ssp- buffer-size=4 -Wall -W -D_REENTRANT $(DEFINES)
> >>>
> >>> I hope, that it is possible to override template CFLAGS during
> >>> qmake invocation. Is it possible?
> >> Use %{qmake_qt4} to create the Makefiles in your rpm .spec file.
> >
> > This does not work because our qmake templates *unconditionally* add
> > options (have you actually tried it? Passing QMAKE_CXXFLAGS at qmake
> > invocation was the first thing I tried :) )
>
> Look at /usr/lib/qt4/mkspecs/common/g++.conf.
>
> So, pass QMAKE_CXXFLAGS_RELEASE="%optflags" to qmake, it works :)
>
> Probably %qmake_qt4 should also be fixed.
>

What to fix? %qmake_qt4 use "-Werror=format-security" for security
reason. When you compile this package, gcc complains about using
qDebug() incorrectly because of "-Werror=format-security".


Here is qDebug signature in qglobal.h (in Qt4 include directory):
  Q_CORE_EXPORT void qDebug(const char *, ...)"

Here is how aqemu use it in Utils.cpp:
  qDebug(QChar *)


That's it. No need to modify %qmake_qt4. Just need to fix the source
code.

Perhaps I don't understand the wall point here and I'm wrong. If so, I
would like to understand why so I keep reading incoming messages.


Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Anssi Hannula-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Amrein-Marie Christophe wrote:

> Le vendredi 10 juillet 2009 à 16:33 +0300, Anssi Hannula a écrit :
>> Andrey Borzenkov wrote:
>>> On Sunday 05 of July 2009 13:31:05 Amrein-Marie Christophe wrote:
>>>> Le dimanche 05 juillet 2009 à 13:23 +0400, Andrey Borzenkov a écrit :
>>>>> I'm trying to build aqemu. It fails on printf format error, but
>>>>> disabling it in specs is ineffective; Makefile is generated by
>>>>> qmake and C(XX)FLAGS are statically set in Makefile.
>>>>>
>>>>> Unfortunately using make CFLAGS=... does not work either because
>>>>> CFLAGS are built from other variables as well:
>>>>>
>>>>> CXXFLAGS      = -pipe -O2 -g -pipe -Wformat -Werror=format-security
>>>>> - Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
>>>>> --param=ssp- buffer-size=4 -Wall -W -D_REENTRANT $(DEFINES)
>>>>>
>>>>> I hope, that it is possible to override template CFLAGS during
>>>>> qmake invocation. Is it possible?
>>>> Use %{qmake_qt4} to create the Makefiles in your rpm .spec file.
>>> This does not work because our qmake templates *unconditionally* add
>>> options (have you actually tried it? Passing QMAKE_CXXFLAGS at qmake
>>> invocation was the first thing I tried :) )
>> Look at /usr/lib/qt4/mkspecs/common/g++.conf.
>>
>> So, pass QMAKE_CXXFLAGS_RELEASE="%optflags" to qmake, it works :)
>>
>> Probably %qmake_qt4 should also be fixed.
>>
>
> What to fix? %qmake_qt4 use "-Werror=format-security" for security
> reason. When you compile this package, gcc complains about using
> qDebug() incorrectly because of "-Werror=format-security".

Using
%define Werror_cflags %nil
does not work with it, since it uses QMAKE_CXXFLAGS=x (which does not
override qmake defaults flags) to set the compilation flags instead of
QMAKE_CXXFLAGS_RELEASE=x (which does override them).

--
Anssi Hannula

Re: [Cooker] How to properly override C(++) lags for Makefiles generated by qmake?

by Amrein-Marie Christophe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le vendredi 10 juillet 2009 à 20:49 +0300, Anssi Hannula a écrit :

> Amrein-Marie Christophe wrote:
> > Le vendredi 10 juillet 2009 à 16:33 +0300, Anssi Hannula a écrit :
> >> Andrey Borzenkov wrote:
> >>> On Sunday 05 of July 2009 13:31:05 Amrein-Marie Christophe wrote:
> >>>> Le dimanche 05 juillet 2009 à 13:23 +0400, Andrey Borzenkov a écrit :
> >>>>> I'm trying to build aqemu. It fails on printf format error, but
> >>>>> disabling it in specs is ineffective; Makefile is generated by
> >>>>> qmake and C(XX)FLAGS are statically set in Makefile.
> >>>>>
> >>>>> Unfortunately using make CFLAGS=... does not work either because
> >>>>> CFLAGS are built from other variables as well:
> >>>>>
> >>>>> CXXFLAGS      = -pipe -O2 -g -pipe -Wformat -Werror=format-security
> >>>>> - Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
> >>>>> --param=ssp- buffer-size=4 -Wall -W -D_REENTRANT $(DEFINES)
> >>>>>
> >>>>> I hope, that it is possible to override template CFLAGS during
> >>>>> qmake invocation. Is it possible?
> >>>> Use %{qmake_qt4} to create the Makefiles in your rpm .spec file.
> >>> This does not work because our qmake templates *unconditionally* add
> >>> options (have you actually tried it? Passing QMAKE_CXXFLAGS at qmake
> >>> invocation was the first thing I tried :) )
> >> Look at /usr/lib/qt4/mkspecs/common/g++.conf.
> >>
> >> So, pass QMAKE_CXXFLAGS_RELEASE="%optflags" to qmake, it works :)
> >>
> >> Probably %qmake_qt4 should also be fixed.
> >>
> >
> > What to fix? %qmake_qt4 use "-Werror=format-security" for security
> > reason. When you compile this package, gcc complains about using
> > qDebug() incorrectly because of "-Werror=format-security".
>
> Using
> %define Werror_cflags %nil
> does not work with it, since it uses QMAKE_CXXFLAGS=x (which does not
> override qmake defaults flags) to set the compilation flags instead of
> QMAKE_CXXFLAGS_RELEASE=x (which does override them).
>

Apparently, what I saw in qmake source code, QMAKE_CXXFLAGS,
QMAKE_CFLAGS, QMAKE_LFLAGS and a few other are not overridden. For all
those tags, what you write is added.

Example: When passing "QMAKE_CXXFLAGS=xxx", xxx is added to CXXFLAGS
(QMAKE_CXXFLAGS=xxx <=> QMAKE_CXXFLAGS+=xxx).