User forums > General (but related to Code::Blocks)
Abnormal difference of exe size using C::B wizard against wxWidgets 2.9 ?!
xunxun:
Note: You can't use -ffunction-sections -fdata-sections and -Wl,--gc-sections on Windows GCC.
Because binutils lacks --gc-sections implement at present, though it has a experimental patch.
Before the bug is fixed, if you use -ffunction-sections -fdata-sections, it will make larger.
It only works on Linux.
xunxun:
And if you use -flto above gcc4.6 (including 4.6), you should use the linker option : -flto -fuse-linker-plugin.
eranon:
Wahou, impressed ! In fact, on my side, I didn't used GCC before to go to wxWidgets (ie. some weeks ago). So, I just try and see... Well, I'll apply you advice and will be back to tell you the result. Just now, I have to advance in my project (and playiong with compiler take a lot of time). Thanks and soon, xunxun ;)
--
EDIT : OK, I try a new wxWidgets 2.9.3 building today. Could you tell me if this cmdline like make sense and is a good idea in the goal to reduce size of final project ?
--- Quote ---mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=release clean
mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=release CFLAGS="-fwhole -flto -O2 -Os -s -fno-keep-inline-dllexport" CXXFLAGS="-fwhole -flto -O2 -Os -s -fno-keep-inline-dllexport" LDFLAGS="-flto -fuse-linker-plugin"
--- End quote ---
Knowing setup.h has "wxDEBUG_LEVEL 0" (but I've restored "WXWIN_COMPATIBILITY_2_8 1" that I disabled yesterday).
Also, I will use these build options for my mini test project (Code::Blocks's default + added ones to be on the same line as the prepared wxWidgets 2.9) :
--- Quote ---Compiler : "-Wall -fwhole -flto -O2 -Os -s -pipe -mthreads -Wno-attributes -include wx_pch.h -Winvalid-pch"
Linker : "-mthreads -flto -fuse-linker-plugin"
--- End quote ---
Do you think all of this is OK ?
eranon:
Since I think it's a good advancement, I create a new post rather than do an EDIT of previous one.
Well, tried as said just above (with and without -fwhole) and got errors at project building time. So, I've tried to return to a basic compil using :
--- Quote ---mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=release CFLAGS="-O2 -Os -fno-keep-inline-dllexport" CXXFLAGS="-O2 -Os -fno-keep-inline-dllexport"
--- End quote ---
Then, I've tried to rebuild my mini-test-project with default Code::Blocks's options + "-Os" to, simply, try to optimize for size. And, here again, a ton of warnings (exactly 307) which complains about things like :
--- Quote ---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
--- End quote ---
Nevertheless, this mini-test-project (which does quite nothing except an empty frame with two item menus : one to quit, one about) is built and has a size of 3.46 Mo, which is acceptable hoping it will dedcrease when I'll go no-monolithic and using packer in post-building.
So, my only one question now is : how to remove these f@*$#!§g 307 warnings about "duplicate section with different sizes" ?
--
EDIT : if I remove all optimization in speed (ie. without -O, -O1, -O2, -O3) in my mini-test project's options, all warnings disappear. Knowing I've used -O2 during wx29 compil. So, I've only kept the optimization in size (-Os) and symbols removing (-s), and it builds without warning. Size of mini-test exe is now 3.45MB :) Does this inspire you something (I mean the impossibility to use speed optimization) ?
Navigation
[0] Message Index
[*] Previous page
Go to full version