infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 5 of 5

Thread: Codesize arm gcc4.9 to arm gcc7 increased drastic

  1. #1
    New Member New Member MKFein is on a distinguished road
    Join Date
    Jun 2014
    Location
    Germany
    Posts
    12
    Points
    126.25

    Codesize arm gcc4.9 to arm gcc7 increased drastic

    Hi.

    I've downloaded the latest toolchain from arm (gcc7) and compiled a project with the same settings as with older gcc4.9 (standard from DAVE distribution).

    The code size increased about 10%.

    I had a closer look to the listing and espacially to XMC_GPIO_Init().
    With gcc4.9 it tooks 180Bytes, with gcc7 it tooks 524Bytes.

    Does anyone know the root cause of this?

    Greetings

  2. #2

    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    377
    Hi,

    I just tried using the GPIO example for XMC47 in the XMCLib.

    Code:
    GCC 49
       text	   data	    bss	    dec	    hex	filename
       1896	      0	   2072	   3968	    f80	XMCLIB_GPIO.elf
    
    GCC7
       text	   data	    bss	    dec	    hex	filename
       1900	      0	   2072	   3972	    f84	XMCLIB_GPIO.elf
    Regards,
    Jesus
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  3. #3
    New Member New Member MKFein is on a distinguished road
    Join Date
    Jun 2014
    Location
    Germany
    Posts
    12
    Points
    126.25
    Thanks for testing.

    I extracted the section from the listing from my compilation.

    XMC_GPIO_Init_gcc7.txt
    XMC_GPIO_Init_gcc4.9.txt

    Can you please post your listing and if possible your compiler / linker log?

    In addition here are my compiler options for gcc7:
    -DXMC1302_T038x0200 -DAKTIV=1 -DINAKTIV=0 -DTRUE=1 -DFALSE=0 -DNC=0xFF -DGND=0 -I"D:\Software Infineon\Demo" -I"D:\Software Infineon\Demo\DevDrivers\XMCLib\inc" -I"D:\Software Infineon\Demo\DevDrivers\CMSIS\Include" -I"D:\Software Infineon\Demo\DevDrivers\CMSIS\Infineon\XMC1300_se ries\Include" -I"D:\Software Infineon\Demo\RTOS\include" -I"D:\Software Infineon\Demo\RTOS\portable\GCC\ARM_CM0" -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -Wall -std=gnu99 -Wa,-adhlns="$@.lst" -pipe -c -fmessage-length=0 -mcpu=cortex-m0 -mthumb -g3 -gdwarf-2

    They are the same as for gcc4.9.
    Last edited by MKFein; Jul 17th, 2018 at 03:28 AM.

  4. #4

    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    377
    Hi,

    I have tested using your settings. The difference in size you see is due to the usage of fpack-struct.
    In my case
    Code:
    GCC49(-Os)   
    		text	   data	    bss	    dec	    hex	filename
            1016	      0	   1048	   2064	    810	XMCLIB_GPIO_XMC13.elf
    
    GCC49(-Os -fpack-struct -fshort-enums)   	   
    		text	   data	    bss	    dec	    hex	filename
       		1068	      0	   1048	   2116	    844	XMCLIB_GPIO_XMC13.elf
    
    GCC7(-Os)    
    		text	   data	    bss	    dec	    hex	filename
            1000	      0	   1040	   2040	    7f8	XMCLIB_GPIO_XMC13.elf
    
    GCC7(-Os -fpack-struct -fshort-enums)   	
    		text	   data	    bss	    dec	    hex	filename
       		1384	      0	   1040	   2424	    978	XMCLIB_GPIO_XMC13.elf
    Bear in mind the warning in the description of the -fpack-struct switch in the manual of GCC
    -fpack-struct[=n]
    Without a value specified, pack all structure members together without holes.
    When a value is specified (which must be a small power of two), pack structure
    members according to this value, representing the maximum alignment (that
    is, objects with default alignment requirements larger than this are output
    potentially unaligned at the next fitting location.
    Warning: the ‘-fpack-struct’ switch causes GCC to generate code that is
    not binary compatible with code generated without that switch. Additionally,
    it makes the code suboptimal
    . Use it to conform to a non-default application
    binary interface.
    You can find also other reports about using -fpack-struct, http://digitalvampire.org/blog/index...ibute__packed/

    Regards,
    Jesus
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  5. #5
    New Member New Member MKFein is on a distinguished road
    Join Date
    Jun 2014
    Location
    Germany
    Posts
    12
    Points
    126.25
    Thank a lot.
    This solved my problem.

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.