EmbeddedRelated.com
Forums
Memfault Beyond the Launch

CrossWorks verser IAR Compiler Output Size Question

Started by dmlcoder October 5, 2006
Hi,

New to this board and ARM development. I'm in the process of
selecting a tool set. I have the IAR 32k limited evaluation and the
CrossWorks 30-day evaluation.

With my limited experimentation (about 1 week), both tools seem to
be working okay. However, the issue I'm trying to resolve is why the
CrossWorks/GCC compiler output is so much larger.

In a file-by-file comparison the CrossWorks code size is %15 to %30
larger. Each tool set to optimize for size.

On a overall project comparison, the CrossWorks final code size was
18,808 bytes and the IAR 3,456 bytes. No printf statements and stdio
library linked in was full (on IAR).

Data size (RAM) on the CrossWorks was 10k and on the IAR about 1k
(I'm still trying to investigate were the extra 9k is going. Maybe
the tool is reporting stack and heap sizes, where the IAR is not
including that in the 1k number).

I think the size disparity is not so much the result of the compiler
generating inefficient code, but its mainly the linker not having
dead code optimization.

With some simple tests on each compiler, I inserted various
functions *without* calling them. On CrossWorks the code size
immediately increased, meaning the code was inserted into the
resulting flash image even though it was never called. The IAR code
size stayed the same and only increased when the function was
actually called and used by the application.

Now to the question. Can someone tell me if there is a dead code
removal option on the CrossWorks linker? If so, how do I enable it?
The Rowley web site touts how good their AVR linker is with removing
dead code, but no mention on the ARM version.

I'd like to spend less money on the CrossWorks tool, but my code
size will be too large if I can't find a way around this limitation.

Thanks for any insight.

Dave

An Engineer's Guide to the LPC2100 Series

> dmlcoder Wrote
>In a file-by-file comparison the CrossWorks code size is %15 to %30
>larger. Each tool set to optimize for size.
>
>On a overall project comparison, the CrossWorks final code size was
>18,808 bytes and the IAR 3,456 bytes. No printf statements and stdio
>library linked in was full (on IAR).
>
>Data size (RAM) on the CrossWorks was 10k and on the IAR about 1k
>(I'm still trying to investigate were the extra 9k is going. Maybe
>the tool is reporting stack and heap sizes, where the IAR is not
>including that in the 1k number).

Have you done the obvious and checked the map file? That should tell you
pretty quickly what's getting linked in (and maybe even why).

Robert
--------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .
Yes, I've checked the linker map file, and this is where I'm getting
my figures from.

I guess the question boils down to whether the GCC ARM toolchain has
dead code removal or not. If not, then CrossWorks wont work (I need
to conserve flash as much as possible).

Thanks,

Dave

--- In l..., "subscriptions@..."
wrote:
>
> > dmlcoder Wrote
> >In a file-by-file comparison the CrossWorks code size is %15 to %
30
> >larger. Each tool set to optimize for size.
> >
> >On a overall project comparison, the CrossWorks final code size
was
> >18,808 bytes and the IAR 3,456 bytes. No printf statements and
stdio
> >library linked in was full (on IAR).
> >
> >Data size (RAM) on the CrossWorks was 10k and on the IAR about 1k
> >(I'm still trying to investigate were the extra 9k is going.
Maybe
> >the tool is reporting stack and heap sizes, where the IAR is not
> >including that in the 1k number).
>
> Have you done the obvious and checked the map file? That should
tell you
> pretty quickly what's getting linked in (and maybe even why).
>
> Robert
> -------------------------------
-
> mail2web - Check your email from the web at
> http://mail2web.com/ .
>
>I guess the question boils down to whether the GCC ARM toolchain has
>dead code removal or not. If not, then CrossWorks wont work (I need
>to conserve flash as much as possible).

Somebody with more knowledge than me once sent me back a copy of the SAM7S
FreeRTOS.org GCC demo with which they had tinkered to reduce the code size.
The results were very impressive. The kernel plus their demo task was 3.3K,
which is comparable to IAR.

I have not studied exactly what it was they did, but a quick scan of the
makefile shows the following options had been added:

CFLAGS += -ffreestanding
CFLAGS += -ffunction-sections
CFLAGS += -fdata-sections
LINKER_FLAGS += -Wl,--gc-sections

I thinks that is but it would take a little longer to be sure. Maybe its
worth looking these options up in the GCC manual to see if they could
improve your results.

Regards,
Richard.

+ http://www.FreeRTOS.org
+ http://www.SafeRTOS.com
for Cortex-M3, ARM7, ARM9, HCS12, H8S, MSP430
Microblaze, Coldfire, AVR, x86, 8051, PIC24 & PIC18
Hi,

> New to this board and ARM development. I'm in the process of
> selecting a tool set. I have the IAR 32k limited evaluation
> and the CrossWorks 30-day evaluation.

[ snip ]

> Data size (RAM) on the CrossWorks was 10k and on the IAR
> about 1k (I'm still trying to investigate were the extra 9k
> is going. Maybe the tool is reporting stack and heap sizes,
> where the IAR is not including that in the 1k number).
>
> I think the size disparity is not so much the result of the
> compiler generating inefficient code, but its mainly the
> linker not having dead code optimization.

Probably true.

> With some simple tests on each compiler, I inserted various
> functions *without* calling them. On CrossWorks the code size
> immediately increased, meaning the code was inserted into the
> resulting flash image even though it was never called. The
> IAR code size stayed the same and only increased when the
> function was actually called and used by the application.

You can use -ffunction-sections I believe then dead code removal will
work.

> Now to the question. Can someone tell me if there is a dead
> code removal option on the CrossWorks linker? If so, how do I
> enable it?
> The Rowley web site touts how good their AVR linker is with
> removing dead code, but no mention on the ARM version.

The AVR compiler isn't based on GCC and does dead code elimination for
free. The ARM one needs more coaxing.

> I'd like to spend less money on the CrossWorks tool, but my
> code size will be too large if I can't find a way around this
> limitation.

You can manually factor your program or be brave and use
-ffunction-sections.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors

Memfault Beyond the Launch