[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] -fwhole-program ate my ISR!

From: Ned Konz
Subject: [avr-gcc-list] -fwhole-program ate my ISR!
Date: Sat, 22 Apr 2006 00:04:47 -0700

[also posted to avr-libc-dev list]

On Apr 21, 2006, at 10:23 AM, Bernd Trog wrote:

For the more recent versions of gcc you might try the -fwhole- program and -funit-at-once options. I have read reports that this is good for some
percent of code size, but I have no experience with it.

I think thats "avr-gcc -combine -fwhole-program *.c -Os ..".

Does this work for you?

Interesting. I just built avr-libc 1.4.4 (thanks Joerg!) and tried a little test program. Unfortunately, the optimization is a bit too aggressive: it removed my ISR completely!

I found that adding

__attribute__ ((used))

before the ISR() definition kept this from happening.

I think we need to add the "used" attribute to the definitions of ISR () etc. to allow for -fwhole-program...

Try compiling this program with and without ADD_USED defined, like this, and you'll see the difference.

// avr-gcc -g -mmcu=attiny45 -fwhole-program -Os -o xx1a.elf xx1.c
// avr-objdump -S xx1a.elf > xx1a.lst
// avr-gcc -g -mmcu=attiny45 -DADD_USED -fwhole-program -Os -o xx1b.elf xx1.c
// avr-objdump -S xx1b.elf > xx1b.lst
#include <avr/io.h>
#include <avr/iotnx5.h>
#include <avr/interrupt.h>

volatile unsigned char uc;

#ifdef ADD_USED
__attribute__ ((used))

int main(void)
    for (;;)


Ned Konz
MetaMagix embedded consulting

reply via email to

[Prev in Thread] Current Thread [Next in Thread]