Target memory usage with different compiler versions

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I am compiling a program with both avrStudio7 and avr-gcc v 5.4.0.

 

The code size is quite different - 38k v 46k. This surprised me at first but both builds seem to run the same in the target. I concluded that the later versions of the compiler had been optimised to a greater extent. There are no (that I can see) obvious compiler/linker option differences.

 

BUT... RAM usage also changes quite a bit - 1962 / 2117 bytes. This was more of a surprise. I use unsigned char, signed char, uint_16, int_16 and a few float.

 

Does anyone have any experience with this sort of issue?

 

The RAM says to me that here are some different default type sizes or some different memory alignment approaches. I have not yet found any good leads.

 

As I say.... both builds run perfectly well.

 

Thanks in advance for any suggestions.

 

Regards

Greg

regards
Greg

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrlibc?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrlibc could/would change code size and stack usage.

 

Statics and globals - potentially - if there are some changes to type defs. However, my types are explicit as to size (e.g. uint16_t) with a very few exceptions. floats are all local, so on the stack.

regards
Greg

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok.... I have embarrassed myself and not looked hard enough in the first place.

 

The issue was garbage collection. With a few adjustments to my makefile (and some obscure errors) both code (almost) and ram (exactly) sizes now align blush

 

https://www.avrfreaks.net/forum/unused-functions-and-variables

regards
Greg

Last Edited: Sun. Sep 27, 2020 - 07:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can only ever make an apples-apples comparison when you use EXACTLY the same build switches. As AS7 autogenerates a Makefile when it builds it's probably best to simply re-use that.