GCC "naked" attribute on GCC...

spacewrench wrote on Thursday, October 14, 2010:

I’m getting back to some ARM programming after a while using AVR.  I’d upgraded GCC a few times along the way, so I’m using 4.4.0 (and tried 4.5.1).  I can’t compile examples because of an internal compiler error associated with the naked attribute used on various ISRs and low-level functions.  Looking through the GCC mailing lists and wikis, it appears that “naked” functions can no longer have arguments, local variables, or anything really except asm() statements.

Has anybody in the FreeRTOS community encountered this?  Solved it?  Perhaps I should just downgrade to 4.3.2 or something?


davedoors wrote on Thursday, October 14, 2010:

I don’t think any naked functions in FreeRTOS have any attributes as they are all ISRs. Where exactly in the FreeRTOS code is the problem occurring?

Some naked functions contain C code, but these can be converted to asm easily if it is causing you a problem.

The compiler should not crash no matter what you feed it so it sounds like a compiler bug. I am using V4.4.2 ok.

spacewrench wrote on Thursday, October 14, 2010:

My compilation of JC Wren’s LPC2148 sample code was crashing on some of his ISR code, not on the “naked” functions in the FreeRTOS-5.1.0 code that he uses.  I posted here because I thought the FreeRTOS people might have encountered this and solved it.  The people talking about it elsewhere appear to be Linux-ARM people and/or GCC people, and discussion tends to peter out after somebody points out that the GCC docs say “nothing but asm() allowed in naked functions.”

(There is agreement that the compiler shouldn’t crash in any case, but apparently it’s harder to fix the crash than one might like, plus it could be that not many people outside the embedded community are encountering the problem.)

Anyway, my problem is not that I don’t know how to fix it / convert to non-naked, but that I’d rather do it without hacking up other people’s code, so for example I can drop in a new version of FreeRTOS when it comes out.

I’ve had success by just reverting to GCC-4.3.2, so I’ll use that until the compiler guys figure out the Right Way to deal with this.


ben_fnr wrote on Thursday, October 14, 2010:

Am using GCC 4.4.3 and naked ISR functions without any problems. I have never used local variables though as there is no stack setup for them when declaring the function as naked. If I need variables I just call another C function declared normally.