Go Down

Topic: Arduino library build size (Read 1 time) previous topic - next topic

MikkyB

I have setup the avr build tool-chain so that I can work from vim and xterm comfortably. I have noticed that however the builds are pretty big, even if setup() and loop() are NOP. What size should I be expecting for a standard build of the Arduino core library?

avr-size reports the following:
Code: [Select]

$ avr-size
   text    data     bss     dec     hex filename
  14276     314     208   14798    39ce a.out

Coding Badly

Quote
What size should I be expecting for a standard build of the Arduino core library?


Code: [Select]
avr-size core.a

   text    data     bss     dec     hex filename
    288       0       4     292     124 WInterrupts.c.o (ex core.a)
    462       0       9     471     1d7 wiring.c.o (ex core.a)
    266       1       0     267     10b wiring_analog.c.o (ex core.a)
    454       0       0     454     1c6 wiring_digital.c.o (ex core.a)
    314       0       0     314     13a wiring_pulse.c.o (ex core.a)
    260       0       0     260     104 wiring_shift.c.o (ex core.a)
      0       0       0       0       0 CDC.cpp.o (ex core.a)
   1510       0     167    1677     68d HardwareSerial.cpp.o (ex core.a)
      0       0       0       0       0 HID.cpp.o (ex core.a)
    512       0       6     518     206 IPAddress.cpp.o (ex core.a)
     30       0       0      30      1e main.cpp.o (ex core.a)
     44       0       0      44      2c new.cpp.o (ex core.a)
   1710       2       0    1712     6b0 Print.cpp.o (ex core.a)
   1244       0       0    1244     4dc Stream.cpp.o (ex core.a)
   1365       1      21    1387     56b Tone.cpp.o (ex core.a)
      0       0       0       0       0 USBCore.cpp.o (ex core.a)
    306       0       0     306     132 WMath.cpp.o (ex core.a)
   4796       1       1    4798    12be WString.cpp.o (ex core.a)

MikkyB

#2
Mar 17, 2012, 08:43 am Last Edit: Mar 17, 2012, 09:02 am by MikkyB Reason: 1
Excellent, cheers mate!

[edit]

I decided to rewrite my build configuration as it had become a bit messy as I hacked it together blindly. Now it comes in more closely to yours, so I guess whatever it was can be attributed to some silly error.

Code: [Select]
$ avr-size libarduino-core.a
   text    data     bss     dec     hex filename
    276       0       4     280     118 WInterrupts.c.obj (ex libarduino-core.a)
    264       1       0     265     109 wiring_analog.c.obj (ex libarduino-core.a)
    488       0       9     497     1f1 wiring.c.obj (ex libarduino-core.a)
    438       0       0     438     1b6 wiring_digital.c.obj (ex libarduino-core.a)
    320       0       0     320     140 wiring_pulse.c.obj (ex libarduino-core.a)
    262       0       0     262     106 wiring_shift.c.obj (ex libarduino-core.a)
      0       0       0       0       0 CDC.cpp.obj (ex libarduino-core.a)
   1282      32     167    1481     5c9 HardwareSerial.cpp.obj (ex libarduino-core.a)
      0       0       0       0       0 HID.cpp.obj (ex libarduino-core.a)
    318      12       6     336     150 IPAddress.cpp.obj (ex libarduino-core.a)
     26       0       0      26      1a main.cpp.obj (ex libarduino-core.a)
     44       0       0      44      2c new.cpp.obj (ex libarduino-core.a)
   1638      10       0    1648     670 Print.cpp.obj (ex libarduino-core.a)
   1292       0       0    1292     50c Stream.cpp.obj (ex libarduino-core.a)
   1343       1      21    1365     555 Tone.cpp.obj (ex libarduino-core.a)
      0       0       0       0       0 USBCore.cpp.obj (ex libarduino-core.a)
    336       0       0     336     150 WMath.cpp.obj (ex libarduino-core.a)
   4084       1       1    4086     ff6 WString.cpp.obj (ex libarduino-core.a)

$ avr-size libarduino-core.a | tail - -n+2 | awk '{x+=$1}END{print x}'
12411

westfw

The arduino environment is heavily dependent on link-time garbage collection of unreferenced functions, accomplished by switches during compile:
Code: [Select]
-ffunction-sections -fdata-sections
and more during link:
Code: [Select]
-Wl,--gc-sections

MikkyB

Yes, I think the issue was that the linker flags weren't actually being set during the link process - something to double check for anyone writing their own make.

Go Up