Bug 154435 - parts of kde do not build in release mode
Summary: parts of kde do not build in release mode
Status: RESOLVED WORKSFORME
Alias: None
Product: kde
Classification: I don't know
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
: 154468 154505 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-12-21 14:44 UTC by Rolf Eike Beer
Modified: 2008-06-16 15:24 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
proposed modification for kdebug.h (7.66 KB, text/plain)
2007-12-23 16:58 UTC, Vincent ETIENNE
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rolf Eike Beer 2007-12-21 14:44:57 UTC
Version:           r751213 (using KDE Devel)
Installed from:    Compiled sources
Compiler:          g++ 4.2.1 openSuSE 10.3
OS:                Linux

[  0%] Building CXX object kioslave/sieve/CMakeFiles/kio_sieve.dir/sieve.o
kdepimlibs/kioslave/sieve/sieve.cpp: In function ‘QDebug ksDebug()’:
kdepimlibs/kioslave/sieve/sieve.cpp:46: error: expected primary-expression before ‘if’
kdepimlibs/kioslave/sieve/sieve.cpp:46: error: expected ‘;’ before ‘if’
kdepimlibs/kioslave/sieve/sieve.cpp: In function ‘QDebug ksDebug(bool)’:
kdepimlibs/kioslave/sieve/sieve.cpp:47: error: expected primary-expression before ‘if’
kdepimlibs/kioslave/sieve/sieve.cpp:47: error: expected ‘;’ before ‘if’

If I set CMAKE_BUILD_TYPE to Debug it builds fine, only with Release it breaks.
Comment 1 Rolf Eike Beer 2007-12-21 14:49:40 UTC
RelWithDebugInfo also builds
Comment 2 Rolf Eike Beer 2007-12-21 22:49:36 UTC
kdebase breaks also:

kdebase/workspace/kdm/kfrontend/themer/kdmitem.cpp: In member function ‘void KdmItem::showStructure(const QString&)’:
kdebase/workspace/kdm/kfrontend/themer/kdmitem.cpp:600: error: expected primary-expression before ‘if

This is once again a kDebug() call.
Comment 3 Rolf Eike Beer 2007-12-22 16:56:11 UTC
*** Bug 154468 has been marked as a duplicate of this bug. ***
Comment 4 Vincent ETIENNE 2007-12-22 22:45:15 UTC
After commit  r751697 by tmcguire on kdepim, pluginloadbase.cpp now compiled fine but the same error appeared at :

In file included from /var/tmp/portage/kde-base/kdepim-9999.4/work/kdepim-9999.4/kmail/kmheaders.cpp:17:
/var/tmp/portage/kde-base/kdepim-9999.4/work/kdepim-9999.4/kmail/kmdebug.h: In function ‘kndbgstream kmDebug()’:
/var/tmp/portage/kde-base/kdepim-9999.4/work/kdepim-9999.4/kmail/kmdebug.h:21: erreur: expected primary-expression before ‘if’
/var/tmp/portage/kde-base/kdepim-9999.4/work/kdepim-9999.4/kmail/kmdebug.h:21: erreur: expected ‘;’ before ‘if’
/var/tmp/portage/kde-base/kdepim-9999.4/work/kdepim-9999.4/kmail/kmdebug.h: In function ‘kndbgstream kmDebug(bool)’:
/var/tmp/portage/kde-base/kdepim-9999.4/work/kdepim-9999.4/kmail/kmdebug.h:22: erreur: expected primary-expression before ‘if’
/var/tmp/portage/kde-base/kdepim-9999.4/work/kdepim-9999.4/kmail/kmdebug.h:22: erreur: expected ‘;’ before ‘if’

sorry to high-jacked a bit the thread (i came from Bug 154468), just to say there's progress but not a complete solution for now
Comment 5 Vincent ETIENNE 2007-12-23 12:45:27 UTC
trying to understand kdebug.h. Interesting piece of headers.
If i understand correctly the line 
#define kDebug 	if ( 1 ); kDebug
use in release mode is used to completely strip the debug code by the compiler as unused code and still provide a correct code  (syntax wise) ?
Perhaps would be cleaner with KDebug( ... ) instead of kDebug (a bit frightened by the recursion in define ) and more symmetric of the debug case but that's another story.

if i understand it correctly (?) in this case kDebug() should not be used to initialized a variable ( will work only in debug mode ).

so kdmitemp.cpp in kdebase need this ulta simple change :
               QDebug ds = kDebug(); 
                 if (!pfx.isEmpty()) 
                         ds << (qPrintable( pfx ) + 1); 
                 ds << objectName() << qPrintable( itemType ) << area; 
 change to : 
 
                 if (!pfx.isEmpty()) 
                         kDebug() << (qPrintable( pfx ) + 1); 
                 kDebug() << objectName() << qPrintable( itemType ) << area; 
 

and kmdebug.h in kdepim should be changed to something like this
0a11,16
> // return type of kmDebug() depends on NDEBUG define:
> #ifdef NDEBUG
> # define kmail_dbgstream kndbgstream
> #else
> # define kmail_dbgstream kdbgstream
> #endif
15,20c21,22
< #if !defined( KDE_NO_DEBUG_OUTPUT )
< static inline kdbgstream kmDebug() { return kDebug( kmail_debug_area ); }
< static inline kdbgstream kmDebug( bool cond ) { return kDebug( cond, kmail_debug_area ); }
< #else
< #define kmDebug       kDebug
< #endif
---
> static inline kmail_dbgstream kmDebug() { return kDebug( kmail_debug_area ); }
> static inline kmail_dbgstream kmDebug( bool cond ) { return kDebug( cond, kmail_debug_area ); }
 
and a small correction to certificatewizarpimpl.cpp in kleopatra for the same type of problem as KdmItem.cpp ( replace the kDebug var by implicite call to kDebug )

<     kDebug() << "requirementsAreMet(): checking \"" << key << "\" against \"" << le->text() << "\":";
---
> #ifndef NDEBUG
>     kdbgstream s = kDebug();
> #else
>     kndbgstream s = kDebug();
> #endif
>     s << "requirementsAreMet(): checking \"" << key << "\" against \"" << le->text() << "\":";
158c163
<       kDebug() << "required field is empty!";
---
>       s << "required field is empty!";
161c166
<     kDebug() << "ok" << endl;
---
>     s << "ok" << endl;

There's still a problem in kmail/kmfilteraction.cpp with ThreadWeaver::debug left but for the moment i have no clean solution


Comment 6 Rolf Eike Beer 2007-12-23 13:34:01 UTC
I'm changing the product to kdelibs as kDebug is from there.
Comment 7 Vincent ETIENNE 2007-12-23 14:21:14 UTC
for the kmfilteraction.cpp problem, i think the problem is in kdelibs/include/threadweaver/DebuggingAids.h

the line 
#define debug( x, ...) 
should be replace by a void inline
inline void debug( int severity, const char * format, ... ) {}

otherwise i think the preprocessor only replace define by void thus leaving a Threadweaver::; in place of ThreadWeaver::debug( ... );

Not completly sure as i'm only a pure (you would perhaps say simple) "c" guy :))
Comment 8 Pino Toscano 2007-12-23 14:56:24 UTC
*** Bug 154505 has been marked as a duplicate of this bug. ***
Comment 9 Vincent ETIENNE 2007-12-23 16:58:00 UTC
Created attachment 22662 [details]
proposed modification for kdebug.h

Tested OK with kdebase/kdepim compiling in release mode
Comment 10 Vincent ETIENNE 2007-12-23 18:05:22 UTC
Many progress has been made :
  - kdebase now compiled fine (thanks to SVN commit 752030 )
  - kdesdk build fine (thanks to SVN commit 752104 by kkofler )
  - kdepim is in better shape (thanks to SVN commit702562 and 752060 by tmcguire )

 still a little problem in kleopatra/certificatewizardimpl.cpp 
     s = kDebug() style
 The modification is very tiny and made the code more readable ....

That's the last one i saw, think i have compile the entire KDE4 in release mode
Thanks you all for your work ( and also to all participants Rolf Eike Beer, Pino toscano )
Comment 11 Vincent ETIENNE 2007-12-23 18:21:46 UTC
to add a comment on my own comment #9 which is as not informative as it's possible : 

the change i made in kdebug.h should not change anything functionality wise but to my eyes it improve the readability of the file

The first inline function kDebug and kWarning is as far as i can see only use for kd3 support (all others should be catch by final kDebug/kWarning define and remap to KDebug class) . So i have marked them as kCompatDebug/kCompatWarning ...

So this keep the deprecated warning for this function but isolate the reammping to debug function

kDebug, kWarning, kFatal and kError use the same mechanism ( KDebug class ) for all new code. kFatal and kError could not be strapped as before.

Must be verify by someone who has knowledge of this piece of code (i could have broke everything...) but i think that it improve the symmetry of all the functions used, so simplify their understanding for others.

So maybe this  "draft" could be of some help 
Comment 12 George Goldberg 2008-06-16 15:24:10 UTC
Closing since this is an old compile issue. Please feel free to reopen if the issue is still relevant now.