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