Idiotic Me? or the Compiler/Linker of the AVR Studio 4? - Page 1
Forum section: electronics / general

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 18, 2012, 02:06:15 pm
content: i have a situation here. this is related to my other thread aboutmcuApiC 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;};Program:288bytesData: 0 bytes...2) include the library, declare the mac_display class...Code:#include "mac_lib_spec.h"mac_display disp;int main() {return 0;};BOOM!Program:2884bytesData: 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:5536bytesData: 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-enumsi 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

author: firewalker
author_rank: Super Contributor
timestamp: June 18, 2012, 02:39:56 pm
content: Try adding-lm.Is there floating point operations?Alexander.

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 18, 2012, 03:09:27 pm
content: Quote from: firewalker on June 18, 2012, 02:39:56 pmthanks 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.

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 18, 2012, 03:23:26 pm
content: 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!

author: andyg
author_rank: Regular Contributor
timestamp: June 18, 2012, 03:29:28 pm
content: Try using both together:Compiler Optimization: Prepare functions for garbage collection-ffunction-sectionsandLinker Optimzation: Garbage collect unused sections-Wl,--gc-sectionsThere 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.

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 18, 2012, 03:56:14 pm
content: Quote from: andyg on June 18, 2012, 03:29:28 pmgolden! quick test... it really works! thanks alot pal!ps: i cant see it anywhere in AVR Studio 4, not even in AVR-GCC plugin help. you are a saviour!