Jump to content
Sign in to follow this  
gordon

mspgcc4 gcc vs. g++ code size

Recommended Posts

Any of you guys noticed that (probably only in certain circumstances/on certain code details of which I have not worked out) g++ tends to compile (sometimes substantially) smaller code than gcc (talking about MSPGCC4 that is)?

 

gcc:

$ msp430-gcc -Os -Wall -W -Wextra -Werror -g -mendup-at=main -mmcu=msp430x2211 -c main.c
$ msp430-gcc -mmcu=msp430x2211 -o main.elf main.o
$ msp430-objdump -DS main.elf > main.lst
$ msp430-size main.elf
  text    data     bss     dec     hex filename
   904       0      28     932     3a4 main.elf

 

g++:

$ msp430-g++ -Os -Wall -W -Wextra -Werror -g -mendup-at=main -mmcu=msp430x2211 -c main.c
$ msp430-g++ -mmcu=msp430x2211 -o main.elf main.o
$ msp430-objdump -DS main.elf > main.lst
$ msp430-size main.elf
  text    data     bss     dec     hex filename
   782       0      28     810     32a main.elf

 

That's ~15% off of .text in this particular case, which is like a ~6% memory expansion for free.

 

Nothing scientific about this yet, but if you are squeezing the last bits out of your MCU, this might save you an upgrade.

Share this post


Link to post
Share on other sites

I only have my current project which seems to be affected, but at the moment it's only the bricks, so I can't verify whether it runs the same.

 

I tried several of these simple example programs, but they do not behave like this. I'm trying to get the mortar in between my bricks so I can verify actual results as well, but floated the idea anyway.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...