Thanks to both Eric and David for their inputs. Indeed, although "-Os -g"
worked for me, it was difficult to set breakpoints at the right places. At
times I had to resort single-stepping in assembly to get what I wanted.
It is nice David pointed out that CCS default optimization is like 0.8 on
mspgcc scale. I attempted "-O1 -g" and the code fits nicely in Flash. I also
figured out that -g option affects only the ELF file size and has no effect on
the program size downloaded to Flash. Option "-O3" explodes the code size. I
assume it is sophisticated performance optimization probably involved lookup
tables. Finally, I tried "-O1 -g3" (maximum debugging) and this is probably
what I will use for debugging. See below for full comparison.
Options Program Size ELF File Size
===============================================
-O1 37048 63836
-O1 -g1 37048 91592
-O1 -g 37048 249184
-O1 -g3 37048 1700844
-----------------------------------------------
-O2 35280 62095
-O2 -g 35280 255343
-----------------------------------------------
-O3 55156 82204
-O3 -g 55156 321648
-----------------------------------------------
-Os 32152 59387
-Os -g 32152 244543
Regards,
Arvind
From: David Brown <da...@westcontrol.com>
To: mspgcc-users@lists.sourceforge.net
Sent: Thursday, 19 February 2015, 13:43
Subject: Re: [Mspgcc-users] Code does not fit in ROM with mspgcc but fits with
CCS compiler
On 19/02/15 06:10, Arvind Padmanabhan wrote:
> Hi Folks,
>
> My friend has Code Composer Studio (CCS) license. He compiled without
> debugging and no optimization. Code size (ROM) is only 35 KB. This is
> good for MSP430G2955 that has 56 KB of Flash.
There is no standard for how much optimisation a compiler does -
settings are only relative to each other in a given compiler. Sometimes
you can compare /types/ of optimisation pass between compilers, but even
then the details vary wildly.
When gcc is used with -O0 (or no optimisation flags), it produces blind
statement-at-a-time interpretation of the code that is very big, very
slow, and very hard to follow. Apart from some tests of the compiler
itself, it is pretty much useless.
With -O1, you get little in the way of code reordering and no inlining
without the "inline" keyword, but variables go in registers and there is
some basic simplification. If you want the easiest single-step
debugging, "-O1 -g" works much better than "-O0 -g" because you have
clearer and more logical assembly code.
With -Os (or -O2), you get a lot more re-arrangement of code, which can
give smaller and faster results but sometimes means that single-stepping
jumps around, and breakpoints don't always appear where you expect them
(a trick here is to make artificial volatile variables, and put
breakpoints on lines that use them).
-O3 and other options are a more specialised, and can sometimes make
code faster, sometimes slower.
With CCS, it's "no optimisation" setting would rate around 0.8 on gcc's
scale, while it's fullest optimisations are around 1.8 (varying by the
actual code in use, of course).
>
> I compiled the same code using mspgcc, I get the following (-g -Oo):
So use "-g -O1" or "-g -Os".
Unless you have something you need to step through carefully (in which
case use "-g -O1", it is best to use exactly the same settings ("-g
-Os") all the time - that way you are debugging what you are going to
release, and releasing what you have debugged.
>
<snip>
> If I remove -g option and optimize for size (-Os), then I can get it
> down to 32 KB. Problem is I can't do debugging in this case. Am I
> missing some trick or is CCS compiler doing something smart?
>
> Regards, Arvind
>
>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users