Eclipse large HEX file size

I installed and configured Eclipse according to this cook book: Arduino Playground - Eclipse. All works fine, however, if I am comparing the size of the generated HEX file between Arduino IDE and Eclipse I was shocked:
Arduino: 2664 byte
Eclipse: 13348 bytes !!!!

Can anybody advise which compiler/linker settings could bring the file size towards Arduino.

BTW, I used the following code:

byte state = HIGH;
long time = 0;

void setup()
{
      Serial.begin(115200);
      pinMode(13, OUTPUT);
}

void loop()
{
      if (millis() - time > 1000)
      {
            state = HIGH ^ state;
            digitalWrite(13, state);
            time = millis();
            Serial.println(time, DEC);
      }
}

Isn't Eclipse reporting the free space left, as it looks like it.

That is the msg from Eclipse:
AVR Memory Usage

Device: atmega328p

Program: 13348 bytes (40.7% Full)
(.text + .data + .bootloader)

Data: 487 bytes (23.8% Full)
(.data + .bss + .noinit)

and if I un-comment both Serial lines I get:

AVR Memory Usage

Device: atmega328p

Program: 1228 bytes (3.7% Full)
(.text + .data + .bootloader)

Data: 15 bytes (0.7% Full)
(.data + .bss + .noinit)

Can you tell us what the compiler command is from Eclipse? Perhaps it doesn't turn optimization on? And what GCC version is installed with it?

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

Cannot figure out the avr-gcc version, but the the avr-gcc.exe has a date modified 01/19/2010.

Here my compiler properties:

AVR Compiler

  • Debugging: Generate Debugging Info: No debugging info
  • Optimization: Optimization Level: to Size Optimizations
  • All options: -Wall -Os -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega328p -DF_CPU=16000000UL

AVR C++ Compiler

  • Debugging: 'Generate Debugging Info': No debugging info.
  • Optimization: 'Optimization Level': Size Optimizations
  • All options: -Wall -Os -fpack-struct -fshort-enums -funsigned-char -funsigned-bitfields -fno-exceptions -mmcu=atmega328p -DF_CPU=16000000UL

AVR C++ Linker

  • Command: avr-gcc
  • Command line pattern: ${COMMAND} --cref -s -Os ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} -lm ${FLAGS}
  • All options: -Wl,-Map,Test.map,--cref -L"H:\Users\rxklein\Development\Eclipse\libraries" -mmcu=atmega328p

Try adding -ffunction-sections and -fdata-sections to the compile flags.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

now down to:

AVR Memory Usage

Device: atmega328p

Program: 10468 bytes (31.9% Full)

but still around 7000 bytes too large.

How about -fno-rtti

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

no, did not work, re-compiled "clean" the ArduinoCore lib and project, entered your proposed settings. I hope I am not doing anything wrong, I enter the settings under
AVR C++ Linker -> General -> Other Arguments

Can we see the Test.map file? It might be pretty big so maybe post it somewhere like pastebin.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

sure you can see it, it's 120kB or 9kB-zipped, but how can I attach or paste it ?

You can post it at pastebin.com

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

it is here: http://pastebin.com/zetFw5EM

Looks like a large part of the code is due to floating-point support being linked in though your code doesn't do any floating point math. That's a bit of a mystery to me.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

for completeness the source and header: http://pastebin.com/NFL1iLZg

I followed the cook book according to first post to compile the ArduinoCore lib
copied the lib file into my Eclipse/libraries folder
linked the lib into my project.

While compiling the ArduinoCore I got 20 warning messages but nothing to worry about: something like comparison between signed and un-signed int.

Hmm, I don't know exactly what Eclipse is doing but it looks like it is precompiling the entire Arduino library. If so, it's likely compiling in all the floating-point support routines just in case they're needed, whereas the Arduino IDE only compiles in what a particular sketch needs.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

That could make sense I'll do some testing around it and will include all files direct into a project w/o using a lib.
Keep you posted about the outcome (after my beauty sleep)
I am still wondering if I am the only guy using Eclipse and sees that something is wrong.

Its really touching a lot of files.

I'm seeing the same problem with my shiny new Eclipse/WinAVR installation. I was going to start a similar thread, and then I saw this one. I'm anxious to find a solution since I like using the Eclipse environment.

Jim

Results of the test:
Included the Arduino lib files into an Eclipse project. Added main.h and main.cpp as above.
Project properties according to the cook book (see post 1)
And voila: the HEX file size increased to 17kB.

I opened a thread in SourceForge to see if they have an idea which switches to set: AVR Plugin for Eclipse / Discussion / General Discussion: HEX file size with Arduino Core lib

In between I tested a good concept idea (but far way to call it beta release) from this gentleman: http://code.google.com/p/avr-project-ide/wiki/Help. Same code, same compilers generate the expected 2.6kB like Arduino IDE.

Keep you posted and still happy for receiving any advice.