-ffunction-sections and -fdata-sections documentation

Jim Wilson wilson@tuliptree.org
Sat Oct 14 15:43:00 GMT 2017


On 10/13/2017 12:06 AM, Sebastian Huber wrote:
> The end-of-life of Solaris 2.6 was 2006. Is it worth to mention this here?

The reference to Solaris 2.6 is no longer useful.  Just mention ELF here.

> This "AIX may have these optimizations in the future." is there since at 
> least 1996. What is the current AIX status?

David answered this.

> Is the "Only use these options when there are significant benefits from 
> doing so. When you specify these options, the assembler and linker 
> create larger object and executable files and are also slower. You 
> cannot use |gprof| on all systems if you specify this option, and you 
> may have problems with debugging if you specify both this option and 
> -g." still correct on the systems of today?

You can get larger objects, because as Jeff mentioned, some 
compile-time/assembly-time optimizations get disabled.  That should 
probably be clarified.

The assembler/linker will be slower because they will have more work to 
do, more relocations, more sections, larger object files.

Some old systems could not support both -ffunction-sections and -pg 
together, this used to give a warning, which was removed in 2012.  I 
believe this is obsolete.  The likely explanation for this doc is
   https://gcc.gnu.org/ml/gcc-help/2008-11/msg00139.html
which mentions that it was already long ago fixed at that time.

Using -g should not be a problem on an ELF/DWARF system, which is what 
most systems use nowadays.  There could be issues with other object 
files/debug info formats, but this is unclear.  I suspect this comment 
is obsolete and can be removed.

The doc should probably refer to the linker --gc-sections option, as 
this is what makes -ffunction-sections useful for most people, by 
reducing the code size by eliminating unused functions.

> Do these options affect the code generation?

Jeff answered this.

Jim




More information about the Gcc mailing list