Author Topic: Idiotic Me? or the Compiler/Linker of the AVR Studio 4?  (Read 3367 times)

0 Members and 1 Guest are viewing this topic.

Online MechatrommerTopic starter

  • Super Contributor
  • ***
  • Posts: 11622
  • Country: my
  • reassessing directives...
Idiotic Me? or the Compiler/Linker of the AVR Studio 4?
« on: June 18, 2012, 02:06:15 pm »
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: [Select]
int main() {
return 0;
};
Program: 288 bytes
Data: 0 bytes...

2) include the library, declare the mac_display class...
Code: [Select]
#include "mac_lib_spec.h"

mac_display disp;

int main() {
return 0;
};
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 >:(
« Last Edit: June 18, 2012, 02:28:58 pm by Mechatrommer »
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline firewalker

  • Super Contributor
  • ***
  • Posts: 2450
  • Country: gr
Re: Idiotic Me? or the Compiler/Linker of the AVR Studio 4?
« Reply #1 on: June 18, 2012, 02:39:56 pm »
Try adding -lm.

Is there floating point operations?

Alexander.
« Last Edit: June 18, 2012, 02:43:09 pm by firewalker »
Become a realist, stay a dreamer.

 

Online MechatrommerTopic starter

  • Super Contributor
  • ***
  • Posts: 11622
  • Country: my
  • reassessing directives...
Re: Idiotic Me? or the Compiler/Linker of the AVR Studio 4?
« Reply #2 on: June 18, 2012, 03:09:27 pm »
Try adding -lm.
Is there floating point operations?
Alexander.
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.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Online MechatrommerTopic starter

  • Super Contributor
  • ***
  • Posts: 11622
  • Country: my
  • reassessing directives...
Re: Idiotic Me? or the Compiler/Linker of the AVR Studio 4?
« Reply #3 on: June 18, 2012, 03:23:26 pm »
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!
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline andyg

  • Regular Contributor
  • *
  • Posts: 59
  • Country: au
    • gock.net
Re: Idiotic Me? or the Compiler/Linker of the AVR Studio 4?
« Reply #4 on: June 18, 2012, 03:29:28 pm »
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.
« Last Edit: June 18, 2012, 03:32:22 pm by andyg »
 

Online MechatrommerTopic starter

  • Super Contributor
  • ***
  • Posts: 11622
  • Country: my
  • reassessing directives...
Re: Idiotic Me? or the Compiler/Linker of the AVR Studio 4?
« Reply #5 on: June 18, 2012, 03:56:14 pm »
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.
golden! 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! ;)
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf