aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: How to compile wx with debug and optimize ?  (Read 10430 times)

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
How to compile wx with debug and optimize ?
« on: May 26, 2009, 08:16:20 PM »

Played around a bit with building wxGTK 2.8.10 and noticed:
- aMule doesn't build in debug mode with a non-debug wx because wxOnAssert is missing then (configure doesn't complain, only link fails)
- wx doesn't build in debug mode with optimization. I configure it with --enable-debug --enable-optimize and it silently switches optimization off (and builds with -O0) .  >:(

So you can't build a aMule debug build with an optimized wx, which is ridiculous. I want to debug aMule, not wx, and I want the full wx speed.

Am I doing something wrong?
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

gtoso

  • Official MacOSX Packager
  • Full Member
  • ***
  • Karma: 24
  • Offline Offline
  • Posts: 206
Re: How to compile wx with debug and optimize ?
« Reply #1 on: May 26, 2009, 11:37:16 PM »

Played around a bit with building wxGTK 2.8.10 and noticed:
- aMule doesn't build in debug mode with a non-debug wx because wxOnAssert is missing then (configure doesn't complain, only link fails)

Strange, on Mac I build debug aMule with no debug wxMac without problems.

EDIT: Maybe because I use -with-wxdir: my wxMac is not installed and not shared.

Quote
- wx doesn't build in debug mode with optimization. I configure it with --enable-debug --enable-optimize and it silently switches optimization off (and builds with -O0) .  >:(

I know, try so:
CFLAGS="-O2" CXXFLAGS="-O2" ../configure ...
if you want use the exact flasgs of optimise they should be:
-O2 -fno-strict-aliasing
« Last Edit: May 26, 2009, 11:39:48 PM by gtoso »
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: How to compile wx with debug and optimize ?
« Reply #2 on: May 27, 2009, 02:54:06 AM »

Played around a bit with building wxGTK 2.8.10 and noticed:
- aMule doesn't build in debug mode with a non-debug wx because wxOnAssert is missing then (configure doesn't complain, only link fails)

Check you wx installation. I just built aMule with '--enable-debug --without-wxdebug' without failure. (Yes, I checked that it used the non-debug wx, which was configured as '--enable-optimize --disable-debug'.) (r9623, wx-2.8.10, just for reference)

Am I doing something wrong?

Might be.
Logged
concordia cum veritate

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: How to compile wx with debug and optimize ?
« Reply #3 on: May 27, 2009, 03:01:07 AM »

And, by the way,
Code: [Select]
topi:~/repos/svn/aMule/trunk$ grep -i -r wxOnAssert
./unittests/tests/.svn/text-base/FormatTest.cpp.svn-base:// Needs reentrant wxOnAssert, which is missing in pre-2.8.8.
./unittests/tests/FormatTest.cpp:// Needs reentrant wxOnAssert, which is missing in pre-2.8.8.
topi:~/repos/svn/aMule/trunk$
aMule doesn't ever directly references wxOnAssert.

Other cause may be that a leftover object from a previous compilation messed up your linkage - run 'make clean' (or equivalent if you're using MSVC) before retrying.
Logged
concordia cum veritate

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: How to compile wx with debug and optimize ?
« Reply #4 on: May 28, 2009, 03:24:28 PM »

Tried it again:
Code: [Select]
Linking amuleweb
../../libs/ec/cpp/libec.a(ECMuleSocket.o): In function `CECMuleSocketHandler::SocketHandler(wxSocketEvent&)':
/home/martin/aMule/mytrunk/src/libs/ec/cpp/ECMuleSocket.cpp:51: undefined reference to `wxOnAssert(wchar_t const*, int, char const*, wchar_t const*, wchar_t const*)'
/home/martin/aMule/mytrunk/src/libs/ec/cpp/ECMuleSocket.cpp:69: undefined reference to `wxOnAssert(wchar_t const*, int, char const*, wchar_t const*, wchar_t const*)'

Offending line is
Code: [Select]
        wxCHECK_RET(socket, wxT("Socket event with a NULL socket!"));

I've built wx static - maybe that's related to the problem?
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: How to compile wx with debug and optimize ?
« Reply #5 on: May 28, 2009, 07:22:14 PM »

OK - this does the trick:
Code: [Select]
../source/configure --enable-unicode --without-subdirs --disable-debug_info --enable-debug_flag --with-gtk --enable-optimize --prefix=/home/stu/aMule/wxGTK-2.8.10/release --disable-shared
So it compiles with -O2, generates no wx debug info but still supports all the wx assert macros.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

gtoso

  • Official MacOSX Packager
  • Full Member
  • ***
  • Karma: 24
  • Offline Offline
  • Posts: 206
Re: How to compile wx with debug and optimize ?
« Reply #6 on: May 28, 2009, 07:35:40 PM »

Good, but strange:
maybe wxMac thinks different ...lol :o

Before what configure flags you used?
I use:
Code: [Select]
       --disable-shared \
        --enable-unicode \
        --with-opengl \
        --disable-debug --enable-optimise \
        --disable-compat26 \
        --with-libjpeg=builtin \
        --with-libpng=builtin \
        --with-regex=builtin \
        --with-libtiff=builtin \
        --with-zlib=builtin \
        --with-expat=builtin \
        --with-libiconv-prefix=$MACPORTS \
        --enable-universal_binary \
        --with-macosx-sdk="$SYSROOT" \
        --with-macosx-version-min=$OSMIN \

and the only debug that remain enabled is:
  --enable-debugreport    use wxDebugReport class
maybe?

Code: [Select]
enterprise:mulo sadmin$ grep debug wxMac-2.8.10_osx-build-10.4-configure.log
checking for --enable-debug... no
checking for --enable-debug_flag... no
checking for --enable-debug_info... no
checking for --enable-debug_gdb... no
checking for --enable-debug_cntxt... no
checking for --enable-debugreport... yes
config.status: creating samples/debugrpt/Makefile
configure: running /bin/sh '../../../src/expat/configure' --prefix=/usr/local  '--disable-shared' '--enable-unicode' '--with-opengl' '--disable-debug' '--enable-optimise' '--disable-compat26' '--with-libjpeg=builtin' '--with-libpng=builtin' '--with-regex=builtin' '--with-libtiff=builtin' '--with-zlib=builtin' '--with-expat=builtin' '--with-libiconv-prefix=/opt/local' '--enable-universal_binary' '--with-macosx-sdk=/Developer/SDKs/MacOSX10.4u.sdk' '--with-macosx-version-min=10.4' 'CC=gcc' 'CFLAGS=' 'CXXFLAGS=' 'CXX=g++' --cache-file=/dev/null --srcdir=../../../src/expat
  Should wxWidgets be compiled in debug mode?             no
enterprise:mulo sadmin$
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: How to compile wx with debug and optimize ?
« Reply #7 on: May 28, 2009, 07:43:29 PM »

Stu, are you sure that when compiling ECMuleSocket.cpp __WXDEBUG__ wasn't defined? Also that libec.a and ECMuleSocket.o were rebuilt?
Logged
concordia cum veritate

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: How to compile wx with debug and optimize ?
« Reply #8 on: May 29, 2009, 12:18:20 AM »

Stu, are you sure that when compiling ECMuleSocket.cpp __WXDEBUG__ wasn't defined?
I'm sure __WXDEBUG__ was defined:
Code: (wx/debug.h) [Select]
/*  if _DEBUG is defined (MS VC++ and others use it in debug builds), define */
/*  __WXDEBUG__ too */
#ifdef _DEBUG
    #ifndef __WXDEBUG__
        #define __WXDEBUG__
    #endif /*  !__WXDEBUG__ */
#endif /*  _DEBUG */
and we define _DEBUG in our debug build. That's the problem.

Gtoso, before I used only --disable-debug . Yeah, strange how these flags influence each other, especially how optimize is silently turned off.  >:(
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: How to compile wx with debug and optimize ?
« Reply #9 on: May 29, 2009, 07:13:41 PM »

and we define _DEBUG in our debug build. That's the problem.

Not we, but MSVC does. Configure defines __DEBUG__ and the code uses that everywhere. If you can make MSVC not define _DEBUG, it should work.
Logged
concordia cum veritate

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: How to compile wx with debug and optimize ?
« Reply #10 on: May 29, 2009, 08:27:39 PM »

Ah - ok. Well, I'm talking about a Linux build all the time. So that's not the reason. Hmm.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: How to compile wx with debug and optimize ?
« Reply #11 on: May 30, 2009, 08:57:15 PM »

Ah - ok. Well, I'm talking about a Linux build all the time. So that's not the reason. Hmm.

Hmm. I did that on Linux, too. You should find out where does that _DEBUG define come from.
Logged
concordia cum veritate