Electronics > Microcontrollers

Idiotic Me? or the Compiler/Linker of the AVR Studio 4?

(1/2) > >>

Mechatrommer:
i have a situation here. this is related to my other thread about mcuApiC lib. this time about the hex compiled size resulted from the compiler (or linker?). now i want to start a new project using that library. i do nothing except declaring the class that i've built... ok here's the stat...

1) no library involved...

--- Code: ---int main() {
return 0;
};

--- End code ---
Program: 288 bytes
Data: 0 bytes...

2) include the library, declare the mac_display class...

--- Code: ---#include "mac_lib_spec.h"

mac_display disp;

int main() {
return 0;
};

--- End code ---
BOOM!
Program: 2884 bytes
Data: 6 bytes...

3) enable the font class in the mac_lib_spec.h (not shown in app code, i.e. same code as above), i dont even declare any font variable...
BOOM! BOOM! BOOM!
Program: 5536 bytes
Data: 6 bytes...

FWIW. this is my project setting (all defaulted except i removed the -gnu88, gave me warning)
-Wall
-gdwarf-2
-Os
-funsigned-char
-funsigned-bitfields
-fpack-struct
-fshort-enums

i can understand the "Data" but i dont understand the compiled 'Program' size. its like 'ALL' the class members and library functions are happily joining together merrymaking in the hex file. Whats going on? i thought the linker will be clever enough to omit any functions that is not called?

ps: i removed all declaration to classes, ie same as code #1, but library enabled (display and font classes)... still at 5000+ bytes mark, shoot!!! (pls note the triple exclamation >:(

firewalker:
Try adding -lm.

Is there floating point operations?

Alexander.

Mechatrommer:

--- Quote from: firewalker on June 18, 2012, 02:39:56 pm ---Try adding -lm.
Is there floating point operations?
Alexander.

--- End quote ---
thanks but it didnt work, still 5490 bytes.. only saving 2 bytes on Data... what did it do? i try searching in the htm based help file i dont know how to setup the compilation option.
no floating... in fact i made a test  on this specifically and macro everywhere to avoid this unnecessarily. which test made me another shock earlier, but understandable for the 'no built-in FPU' processor, they have to do it by software. declaring one float variable adding another 3000++ bytes into the program.

Mechatrommer:
ok i removed the *.cpp files (library implementation files), leaving App.cpp alone. they all gone back to 300+ bytes. but since its not used (no error message since the main program doesnt use them), why the compiler is happy to include them in the hex file??? mystery!

andyg:
Try using both together:

Compiler Optimization: Prepare functions for garbage collection
-ffunction-sections

and

Linker Optimzation: Garbage collect unused sections
-Wl,--gc-sections

There are checkboxes for those in AVR Studio 5, not sure about AVR Studio 4 equivalent description as i don't have it installed to check.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod