large G++ locale overhead in g++ 4.9.2

Joel Sherrill joel.sherrill at
Mon Jun 29 13:38:02 UTC 2015

On June 29, 2015 8:28:16 AM CDT, Sebastian Huber <sebastian.huber at> wrote:
>On 29/06/15 15:20, Peter Dufault wrote:
>>> >On Jun 28, 2015, at 11:53 , Joel
>Sherrill<Joel.Sherrill at>  wrote:
>>> >
>>>> >>There are also a bunch of new shell commands that are pulling in
>>>> >>code, that might be a lot of the rest.
>>> >
>>> >This can be configured down.
>>> >
>>> >But overall, you may want to try per element data and function
>sections on the compile and link. See the SPARC bsps for a reference.
>They had quite a bit of code removed in the tests building with those
>options. But you have to get the linker script right for things to
>still work. Sections need an asterisk to wild card the per method/data
>item sections.
>>> >
>>> >And you may have to mark some sections as KEEP. Or they won't have
>a dependency to get them in.
>> By only including the RTEMS shell commands I use I reduced the size
>to 1839664 (latest RTEMS) vs 1624684 (September RTEMS), about a 13%
>increase, but at least it fits in FLASH.
>> The overhead appears to be mostly all the locale “stuff” in g++ 4.9.2
>vs g++ 4.8.2.  I did some googling but don’t see how to reduce this,
>does anyone know of a way?  I really don’t need currency customization.
>What pulls in this locale stuff? Maybe
>CFLAGS += -ffunction-sections -fdata-sections
>LDFLAGS = -Wl,--gc-sections

It would be good to hear results from a real decent sized application using this. Remember that some of the sections need asterisks to wildcard. Maybe the PowerPC shared linker script is OK on this though.

Also for debugging purposes, the -Map ld argument shows why a file is pulled in. Please turn that on and see what references the locale code. 


More information about the devel mailing list