avr-chat
[Top][All Lists]
Advanced

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

[avr-chat] broken compiler/avrlibc build symptom?


From: Britton Kerin
Subject: [avr-chat] broken compiler/avrlibc build symptom?
Date: Mon, 22 Sep 2014 17:28:33 -0800

I just rebuilt binutils/gcc/avrlibc stack using the latest.  Its my
first time trying this.

I now get a weird behavior trying to compile some code that uses _delay_us().
This file:

     #include <util/delay.h>

     // Pause for exactly ticks ticks.
     static void
     delay_wrapper (int ticks)
     {
       _delay_us (ticks);
     }

     void
     wrapper_caller (void);

     void
     wrapper_caller (void)
     {
       delay_wrapper (42);
       delay_wrapper (43);
       delay_wrapper (44);
       //delay_wrapper (45);
     }

Compiles cleanly this way:

     avr-gcc  -DF_CPU=16000000 -I. -std=gnu99 -fshort-enums
-mmcu=atmega328p -Os -Werror -Wall -Wextra -Winline
-Wmissing-prototypes -Wredundant-decls -Winit-self -Wstrict-prototypes
-c test.c -o test.o

But uncommenting that last delay_wrapper() call causes that same compile
command to fail like this:

     In file included from test.c:1:0:
     /home/bkerin/opt/avr/avr/include/util/delay.h: In function ‘delay_wrapper’:
     /home/bkerin/opt/avr/avr/include/util/delay.h:245:28: error:
__builtin_avr_delay_cycles expects a compile time integer constant
       __builtin_avr_delay_cycles(__ticks_dc);
                                 ^

I suspect that the extra call causes the compiler to not inline
delay_wrapper(), which in turn triggers this error.  If I change the
declaration for delay_wrapper to 'static inline void', the compiler complains
that inlineing has failed with that fourth call, otherwise it doesn't,
which seems to support this theory.

Is this likely to be a symptom of a bad binutils/gcc/avrlibc build?  Genuine
bug?



reply via email to

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