User forums > General (but related to Code::Blocks)
Abnormal difference of exe size using C::B wizard against wxWidgets 2.9 ?!
ptDev:
Thank you for posting your results. Maybe you could also post them in the wxWidgets C++ forum, and link to it in the wx-dev mailing list.
The wxWidgets developers should be aware of the implications of certain choices in the current wxWidgets design. ;)
xunxun:
Except wxDEBUG_LEVEL
If you don't use wx EXCEPTIONS, you can make USE_EXCEPTIONS=0.
If you don't use wx RTTI, you can make USE_RTTI=0. (C::B uses wx RTTI!)
Maybe you can change the compiler option to -Os
If wx shared build, may also add "-fvisibility=hidden -fvisibility-inlines-hidden".
LTO/PGO may reduce exe size, too.
eranon:
Yes, ptDev : even if nothing done towards wx-dev mailing list (I've subscribed to user side, but not dev one yet), I've already opened a thread about this in the wxWidgets forum. It's here : http://forums.wxwidgets.org/viewtopic.php?f=1&t=35103&p=143804
Thanks for these added info, xunxun ; until now, I've pushed a little bit further (see my results below), but wouldn't fall in a too specific optimization ; knowing same wx libs should work for several projects, and it's difficult to remember to not use this or that... Well, here are my results until now (and a problem too) :
--
So, as said above, I've tried to reduce the exe size a little bit more like this :
--- Quote ---- Rebuild wxWidgets 2.9.3 w/ "WXWIN_COMPATIBILITY_2_8 0" & "wxDEBUG_LEVEL 0" in setup.h => my mini_wx29_project's exe becomes 5.65 MB
- Post-build w/ "strip --strip-all XXX.exe" (read it's sometime better than GCC -Os) : negligible, but I keep-it (- 0.01 MB)
- Rebuild wxWidgets 2.9.3 adding theses make options : CFLAGS='-Os -fdata-sections -ffunction-sections' CXXFLAGS='-Os -fdata-sections -ffunction-sections -fno-keep-inline-dllexport' LDFLAGS='-Wl,--gc-sections' => mini_wx29_project is now 3.64 MB, but w/ a lot of warnings about sections.
--- End quote ---
Thus, now my initial minimalist project of 7.07 MB is 3.64 MB, but linker returns a lot of warnings (about 300 lines like the ones below) :
--- Code: ---Linking executable: bin\Release\wx29_cb-mini.exe
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_gdicmn.o): warning: duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_window.o): warning: duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_window.o): warning: duplicate section `.rdata$_ZTV13wxTransform2D[vtable for wxTransform2D]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_mdi.o): warning: duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_mdi.o): warning: duplicate section `.rdata$_ZTV21wxMDIClientWindowBase[vtable for wxMDIClientWindowBase]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_mdi.o): warning: duplicate section `.rdata$_ZTS19wxNavigationEnabledI16wxNonOwnedWindowE[typeinfo name for wxNavigationEnabled<wxNonOwnedWindow>]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_appbase.o): warning: duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
[...]
Output size is 3.64 MB
Running target post-build steps
strip --strip-all wx29_cb-mini.exe
Process terminated with status 0 (0 minutes, 28 seconds)
0 errors, 305 warnings (0 minutes, 28 seconds)
Do you have an idea to avoid these hundreds of warnings ?
--- End code ---
I've asked in the wxWidgets forum too (see URL I indicate at top of this post).
Next step could be to use no-monolithic linking, but, before, I would like to remove theses warnings ::)
--
EDIT : I try to advance. Now, I've got only 6 warnings (rather than hunderds) but two errors too (so, it doesn't build)
Here are the options I've indicated :
--- Quote ---For compiler :
-ffunction-sections
-fdata-sections
-Wl,-allow-multiple-definition
-flto
For linker :
-flto
-Os
-Wl,--gc-sections
-Wl,-allow-multiple-definition
--- End quote ---
And I get this :
--- Code: ---Compiling: resource.rc
Compiling: wx29_cb_miniMain.cpp
Linking executable: bin\Release\wx29_cb-mini.exe
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans0.ltrans.o: warning: duplicate section `.rdata$_ZTS19wxNavigationEnabledI16wxNonOwnedWindowE[typeinfo name for wxNavigationEnabled<wxNonOwnedWindow>]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans0.ltrans.o: warning: duplicate section `.rdata$_ZTV13wxTransform2D[vtable for wxTransform2D]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans0.ltrans.o: warning: duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans1.ltrans.o: warning: duplicate section `.rdata$_ZTS19wxNavigationEnabledI16wxNonOwnedWindowE[typeinfo name for wxNavigationEnabled<wxNonOwnedWindow>]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans1.ltrans.o: warning: duplicate section `.rdata$_ZTS19wxNavigationEnabledI8wxWindowE[typeinfo name for wxNavigationEnabled<wxWindow>]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans1.ltrans.o: warning: duplicate section `.rdata$_ZTS17wxWindowWithItemsI9wxControl15wxItemContainerE[typeinfo name for wxWindowWithItems<wxControl, wxItemContainer>]' has different size
C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans0.ltrans.o:cctYhhpd.ltrans0.o:(.text+0xd22): undefined reference to `wxTheAssertHandler'
C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans0.ltrans.o:cctYhhpd.ltrans0.o:(.text+0xd51): undefined reference to `wxOnAssert(char const*, int, char const*, char const*, wchar_t const*)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 39 seconds)
2 errors, 6 warnings (0 minutes, 39 seconds)
--- End code ---
Knowing I've maybe made obvious mistake with theses options : I'm new in GCC as in C::B and wxWidgets :o Do you have an idea, an advice ?
Alpha:
Some of your warnings look like the lib and the project were built with different flags.
Have you done a full rebuild of both, ensuring that both builds use the exact same set of optimization flags?
eranon:
No, effectively, Alpha, you're right... But, here is progress
About wxWidgets 2.9.3
- I've changed setup.h with "WXWIN_COMPATIBILITY_2_8 0" and "wxDEBUG_LEVEL 0"
- I've cleaned with "mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=release clean"
- Then built with :
--- Quote ---mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=release CFLAGS="-Os -fdata-sections -ffunction-sections" CXXFLAGS="-Os -fdata-sections -ffunction-sections -fno-keep-inline-dllexport" LDFLAGS="-Wl,--gc-sections"
--- End quote ---
About the test project
Initially, default Code::Blocks project settings gave me 305 warnings and 0 error :
--- Code: ---GCC with "-Wall -s -O2 -pipe -mthreads -Wno-attributes -include wx_pch.h -Winvalid-pch", and linker with "-mthreads"
--- End code ---
And the same (305 warnings and 0 error) if I just add the same options as the ones provided during wxWidget building :
--- Code: ---"GCC with default setting above + "-fdata-sections -ffunction-sections -fno-keep-inline-dllexport"
Linker with default setting above + "-Wl,--gc-sections"
--- End code ---
Then, I've tried to remove these warnings using differents options (but, effectivelly, w/o rebuild of wxWidgets itself)... After some hours, I've got this combination which gave me 2 errors and 6 warnings :
--- Code: ---GCC with default setting above + "-Os -ffunction-sections -fdata-sections -Wl,-allow-multiple-definition -flto"
Linker with default setting above + "-flto -Os -Wl,--gc-sections"-Wl,-allow-multiple-definition"
--- End code ---
So, what should I do from this point : remove options in my test project or add ones in a new wxWidgets rebuild ?
PS : also, in parallel, maybe I'l take a try w/ MSVC compiler... But it would be great to obtains something acceptable with GCC.
--
EDIT : knowing, of course, after every change in build options, I do a complete rebuild (with clean ahead)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version