Bug 34299 - [avr] ICE on function attribute syntax for main()
Summary: [avr] ICE on function attribute syntax for main()
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.2.2
: P3 normal
Target Milestone: 4.4.0
Assignee: aesok
URL:
Keywords:
: 38558 38954 39307 (view as bug list)
Depends on: 25448
Blocks:
  Show dependency treegraph
 
Reported: 2007-11-30 09:32 UTC by Marek Jawurek
Modified: 2010-04-15 14:32 UTC (History)
7 users (show)

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-01-10 18:07:45


Attachments
patch for bug 34299 (261 bytes, patch)
2009-02-26 23:24 UTC, Xuejun Yang
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Jawurek 2007-11-30 09:32:51 UTC
+++ This bug was initially created as a clone of Bug #31331 +++

On a Mac(Tiger) compilation of a TinyOS standard example application "Blink" does not compile. Please mail me if important information is missing. As I cannot access the MAC I cannot provide the C file created by the Nesc Compiler.


make micaz
sh: line 1: sha1sum: command not found
sh: line 1: sha1sum: command not found
mkdir -p build/micaz
    compiling BlinkAppC to a micaz binary
ncc -o build/micaz/main.exe -Os -fnesc-separator=\never1096WritE -Wall -Wshadow -Wnesc-all -target=micaz -fnesc-cfile=build/micaz/app.c -board=micasb --param max-inline-insns-single=100000 -I/sw/include/python2.5/ -DIDENT_PROGRAM_NAME=\"BlinkAppC\" -DIDENT_USER_ID=\"admin\" -DIDENT_HOSTNAME=\"macbook-zina.in\" -DIDENT_USER_HASH=0L -DIDENT_UNIX_TIME=0x474aa64cL -DIDENT_UID_HASH=0L -fnesc-dump=wiring -fnesc-dump='interfaces(!abstract())' -fnesc-dump='referenced(interfacedefs, components)' -fnesc-dumpfile=build/micaz/wiring-check.xml BlinkAppC.nc -lm 
/sw/tinyos-2.x/tinyos-2.x/tos/chips/atm128/timer/HplAtm128Timer0AsyncP.nc:178: internal compiler error: in start_function, at c-decl.c:6177
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make: *** [exe0] Error 1


The NesC Compiler involved is:
nescc: 1.2.9
gcc -_fnesc-gcc=gcc -specs=/opt/tinyostools//lib/ncc/tdspecs -_fnesc-include=nesc_nx -I/opt/tinyostools//lib/ncc -v -DNESC=129
Using built-in specs.
Reading specs from /opt/tinyostools//lib/ncc/tdspecs
Target: i386-apple-darwin8.10.1
Configured with: ../gcc-4.2.2/configure --prefix=/opt/local --enable-languages=c,c++,java,objc,obj-c++,fortran --libdir=/opt/local/lib/gcc42 --includedir=/opt/local/include/gcc42 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --with-local-prefix=/opt/local --with-system-zlib --disable-nls --disable-multilib --program-suffix=-mp-4.2 --with-gxx-include-dir=/opt/local/include/gcc42/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local
Thread model: posix
gcc version 4.2.2


avr-gcc -v produces:

Using built-in specs.
Target: avr
Configured with: ../configure --target=avr --prefix=/opt/tinyostools/ --disable-nls --enable-languages=c --disable-libsp : (reconfigured) ../configure --target=avr --prefix=/opt/tinyostools/ --disable-nls --enable-languages=c --disable-libssp
Thread model: single
gcc version 4.2.2
Comment 1 Andrew Pinski 2007-12-02 23:34:41 UTC
Can you attach the preprocessed source?
Comment 2 Eric Weddington 2007-12-03 05:39:22 UTC
The subject line of this bug is the same subject as bug #31331, which is fixed. Without having the preprocessed source it is difficult to determine if this bug is a duplicate.
Comment 3 Joerg Wunsch 2008-01-10 15:56:23 UTC
Some bugs appear to re-appear. :-(

While I get

__attribute__((naked))
int main(void)
{
  // ...
   return 42;
}

to compile with the current compiler, the following piece of code:

__attribute__((signal, naked))
void __vector_42(void)
{
   static unsigned char x;

   x++;
}

still triggers the ICE:

% avr-gcc -mmcu=attiny2313 -S foo.c
foo.c:3: internal compiler error: in start_function, at c-decl.c:6177
Comment 4 Eric Weddington 2008-01-10 17:56:46 UTC
(In reply to comment #3)

> __attribute__((signal, naked))
> void __vector_42(void)
> {
>    static unsigned char x;
> 
>    x++;
> }
> 
> still triggers the ICE:


However, if there is a function prototype, and the attributes are placed on the prototype, there is no bug:

__attribute__((signal, naked))
void __vector_42(void);

void __vector_42(void)
{
   static unsigned char x;

   x++;
}

Is it really a bug?
Comment 5 Steven Bosscher 2008-01-10 18:05:09 UTC
If there is an ICE, there is a bug.
Comment 6 Eric Weddington 2009-01-24 23:35:03 UTC
*** Bug 38954 has been marked as a duplicate of this bug. ***
Comment 7 Andrew Pinski 2009-02-25 18:50:00 UTC
*** Bug 39307 has been marked as a duplicate of this bug. ***
Comment 8 John Regehr 2009-02-25 20:01:21 UTC
Sorry for the dup.

This bug prevents compilation of almost all TinyOS apps using 4.3.3!  Is there a workaround?
Comment 9 Eric Weddington 2009-02-26 01:00:43 UTC
(In reply to comment #8)
> Sorry for the dup.
> 
> This bug prevents compilation of almost all TinyOS apps using 4.3.3!  Is there
> a workaround?
> 

See comment #4 of this bug.
Comment 10 Xuejun Yang 2009-02-26 23:24:03 UTC
Created attachment 17370 [details]
patch for bug 34299

DECL_ASSEMBLER_NAME has a side effect of setting assembler_name for functions if that attribute is missing, which causes the assertion failure in c-decl.c.

Change it to less harmful DECL_NAME.
Comment 11 John Regehr 2009-02-26 23:29:41 UTC
Subject: Re:  [avr] ICE on function attribute syntax for
 main()

Great!

John


jxyang at cs dot utah dot edu wrote:
> ------- Comment #10 from jxyang at cs dot utah dot edu  2009-02-26 23:24 -------
> Created an attachment (id=17370)
>  --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17370&action=view)
> patch for bug 34299
> 
> DECL_ASSEMBLER_NAME has a side effect of setting assembler_name for functions
> if that attribute is missing, which causes the assertion failure in c-decl.c.
> 
> Change it to less harmful DECL_NAME.
> 
> 
Comment 12 aesok 2009-02-27 16:25:13 UTC
2007-04-05  Anatoly Sokolov <aesok@post.ru>

	PR target/25448
	* config/avr/avr.c (avr_handle_fndecl_attribute): Use the
	DECL_ASSEMBLER_NAME, not the DECL_NAME.
Comment 13 aesok 2009-03-02 21:54:40 UTC
*** Bug 38558 has been marked as a duplicate of this bug. ***
Comment 14 aesok 2009-03-15 13:09:58 UTC
Subject: Bug 34299

Author: aesok
Date: Sun Mar 15 13:09:44 2009
New Revision: 144870

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144870
Log:
	PR target/34299
	* config/avr/avr.c (avr_handle_fndecl_attribute): Move code for
	generate a warning if the function name does not begin with
	"__vector" and the function has either the 'signal' or 'interrupt'
	attribute, from here to ...
	(avr_declare_function_name): ...here. New function.
	* config/avr/avr.h (ASM_DECLARE_FUNCTION_NAME): Redefine.
	* config/avr/avr-protos.h (avr_declare_function_name): Declare.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr-protos.h
    trunk/gcc/config/avr/avr.c
    trunk/gcc/config/avr/avr.h

Comment 15 aesok 2009-03-15 13:14:23 UTC
Fixed.