Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » GCC compilation options
GCC compilation options [message #24148] Tue, 29 December 2009 11:46 Go to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Hi,

I've noticed that u++ doesn't force gcc to remove unused functions nor data, so binaries are usually bigger (comparing to MS compiler). So, my proposition is to add:
1. -ffunction-sections and -fdata-sections to compilation options for gcc
2. -Wl,--gc-sections to linker options

I know that "-ffunction-sections" is already used, but without --gc-sections it is useless.


Re: GCC compilation options [message #24153 is a reply to message #24148] Tue, 29 December 2009 17:36 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Zbych wrote on Tue, 29 December 2009 05:46

Hi,

I've noticed that u++ doesn't force gcc to remove unused functions nor data, so binaries are usually bigger (comparing to MS compiler). So, my proposition is to add:
1. -ffunction-sections and -fdata-sections to compilation options for gcc
2. -Wl,--gc-sections to linker options

I know that "-ffunction-sections" is already used, but without --gc-sections it is useless.





We have experimented with it way back (5 years ago). At least in Linux and BSD, it did not seem to result in any difference in binary size.

Maybe things evolved since then. Could you try please? Ideal test candidate is theide in release mode.

You can pass linker options via package organizer for the purpose of the experiment...

Mirek

Re: GCC compilation options [message #24156 is a reply to message #24153] Tue, 29 December 2009 21:50 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
luzr wrote on Tue, 29 December 2009 17:36

At least in Linux and BSD, it did not seem to result in any difference in binary size.


You will not see huge size reduction of big applications, because such applications use a lot of functions from u++, so there is almost nothing to remove.
The biggest difference is in small applications.
I've made simple MT tcp/ip server. Without --gc-sections size of application was ~1,5MB. After I added --gc-sections size decreased to 0,4MB. For me it is a huge difference.

Compilation results for some applications from u++ package:
Application	| size [B] without dead code removal	| size [B] with dead code removal	|	Size reduction
------------------------------------------------------------------------------------------------|----------------------
ide		|	5809896				|	5148244				|	11,4%
Gui01		|	1760072				|	1090132				|	38%
HomeBudget	|	3641508				|	2037696				|	44%


gcc version 4.4.1, all applications optimized for size.


Re: GCC compilation options [message #24167 is a reply to message #24156] Wed, 30 December 2009 18:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Zbych wrote on Tue, 29 December 2009 15:50

luzr wrote on Tue, 29 December 2009 17:36

At least in Linux and BSD, it did not seem to result in any difference in binary size.


You will not see huge size reduction of big applications, because such applications use a lot of functions from u++, so there is almost nothing to remove.
The biggest difference is in small applications.
I've made simple MT tcp/ip server. Without --gc-sections size of application was ~1,5MB. After I added --gc-sections size decreased to 0,4MB. For me it is a huge difference.

Compilation results for some applications from u++ package:
Application	| size [B] without dead code removal	| size [B] with dead code removal	|	Size reduction
------------------------------------------------------------------------------------------------|----------------------
ide		|	5809896				|	5148244				|	11,4%
Gui01		|	1760072				|	1090132				|	38%
HomeBudget	|	3641508				|	2037696				|	44%


gcc version 4.4.1, all applications optimized for size.





Well, things definitely improved! This is good news.

Now I only have to decide whether to hardcode it or rather put another "Link options" field into Build methods and set it as default... Smile
Re: GCC compilation options [message #24168 is a reply to message #24167] Wed, 30 December 2009 21:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Implemented via adding "Link options" to build methods and making necessarry flags default (and part of linux installation as well).

Thanks a lot, it rocks.

Mirek
Re: GCC compilation options [message #24178 is a reply to message #24168] Fri, 01 January 2010 07:00 Go to previous messageGo to next message
gxl117 is currently offline  gxl117
Messages: 71
Registered: March 2009
Location: China
Member
In the UPP1861, I test this link options, but to no avail.I use TDM-MINGW GCC4.4.1-2
Re: GCC compilation options [message #24179 is a reply to message #24178] Fri, 01 January 2010 09:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
gxl117 wrote on Fri, 01 January 2010 01:00

In the UPP1861, I test this link options, but to no avail.I use TDM-MINGW GCC4.4.1-2


Can you be more specific?

Are Debug/Release link options edit fields missing from build methods, are they ignored while linking (use verbose mode to see the commandline) or are they ignored by mingw (which would not be our bug...)?

Mirek
Re: GCC compilation options [message #24180 is a reply to message #24179] Fri, 01 January 2010 09:51 Go to previous messageGo to next message
gxl117 is currently offline  gxl117
Messages: 71
Registered: March 2009
Location: China
Member
Theide is normal.
Link option -gc-sections is no effect,compiled file size has not changed.I compile Gui01,with -gc-sections,file size is 1807360(B).without -gc-sections filesize is same.I can't get Zbych's 1090132(B) compiled file size. Are that option only effect for Linux???
If add -fdata-sections compilation options,compiled file size is increase to 1985024 B.
Re: GCC compilation options [message #24184 is a reply to message #24180] Fri, 01 January 2010 20:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
gxl117 wrote on Fri, 01 January 2010 03:51

Theide is normal.
Link option -gc-sections is no effect,compiled file size has not changed.I compile Gui01,with -gc-sections,file size is 1807360(B).without -gc-sections filesize is same.I can't get Zbych's 1090132(B) compiled file size. Are that option only effect for Linux???



Very likely. Actually, if you read this from the start, the were no effective in the past in Linux as well...

You might also try our linker for mingw, I believe Tom had gc-sections support there.

Mirek

Re: GCC compilation options [message #24205 is a reply to message #24180] Tue, 05 January 2010 11:26 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
gxl117 wrote on Fri, 01 January 2010 09:51

I can't get Zbych's 1090132(B) compiled file size. Are that option only effect for Linux???


I've made my test on linux. For some reason MINGW/TDM doesn't remove dead code.
Re: GCC compilation options [message #24242 is a reply to message #24148] Thu, 07 January 2010 03:01 Go to previous message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
I checked numbers on Linux x86_64 GCC 4.4.1

TheIDE: 6358272B 5495408B reduction: 14%
My own simple CGI app: 2198160B 798944B reduction: 64%

I definitely like these new options!
Thanks a lot for pointing out!

Some time ago I read about symbol visibility options, which also helped significantly reduce size of resulting executable (which was using boost libraries). Has somebody tried visibility options with UPP?



Regards,
Novo
Previous Topic: Compilation Under win 32 with MSC9 error
Next Topic: Helper for internazionalize arrays of literals
Goto Forum:
  


Current Time: Fri Mar 29 15:21:03 CET 2024

Total time taken to generate the page: 0.01283 seconds