compiling different modules with different optimizations

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

I have a little sram memory check module written in C. Unfortunately if I set the optimization level to anything but 0 it really doesn't do anything. Is it possible to build that at optimazation 0 and everything else at optimization s? If so, can somebody suggest a makefile that would do this automatically?

Thanks for your help.

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

It's certainly possible, you just need a specific rule
to compile that C file (that supersedes the generic
rule for .c -> .o then).

However, this usually rather smells like a bug in your
application code. Sure, we've seen bugs in the code
generator in the past as well (but they have also been
fixed once they were known), but in 99 % of the cases,
it's a forgotten »volatile« keyword or something like
that.

So unless you've really verified the assembler output
(avr-gcc -S ...) to generate buggy code even though your
C file is OK, better verify the C code again. Not using
optimization is fairly fatal on the AVR (e. g. all IO
access will use MMIO then which is slower than direct
IO instructions).

If it's really a bug, please report it on the avr-gcc-list
then.