Rockbox

Tasklist

FS#7183 - ARM-GCC 4.11 compiler error in thread.c

Attached to Project: Rockbox
Opened by Alex Gerchanovsky (shoora) - Thursday, 17 May 2007, 20:30 GMT
Last edited by Magnus Holmgren (learman) - Tuesday, 05 June 2007, 19:28 GMT
Task Type Bugs
Category Operating System/Drivers
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I use ARM-GCC 4.1.1 from http://www.gnuarm.org/.
By the way, it generates slightly smaller code.
It only have problem with start_thread declaration. To fix this error we have to remove static declaration of this function.
This task depends upon

Closed by  Magnus Holmgren (learman)
Tuesday, 05 June 2007, 19:28 GMT
Reason for closing:  Accepted
Comment by Dave Chapman (linuxstb) - Friday, 18 May 2007, 06:54 GMT
What problem does gcc 4.1.1 have with declaring start_thread as static? Do you know if this is a deliberate change in behaviour by gcc or a bug?
Comment by Alex Gerchanovsky (shoora) - Friday, 18 May 2007, 07:13 GMT
Error message is:
/cygdrive/c/rockbox/build-device/librockbox.a(thread.o): In function `create_thread':
thread.c:(.text+0x95c): undefined reference to `start_thread'

I guess this may be caused by call from inline assembler in function 'load_context'?
static inline void load_context(const void* addr)
{
asm volatile(
"ldmia %0, { r4-r11, sp, lr } \\n" /* load regs r4 to r14 from context */
"ldr r0, [%0, #40] \\n" /* load start pointer */
"cmp r0, #0 \\n" /* check for NULL */
"movne r1, %0 \\n" /* if not already running, jump to start */
"ldrne pc, =start_thread \\n"
: : "r" (addr) : "r0", "r1"
);
}
Comment by Michael Sevakis (MikeS) - Friday, 18 May 2007, 09:30 GMT
Probably discards the "unreferenced" (by C code) static function as an "optimization" then tries to link it. Sounds buggy to me and obviously doesn't trip up arm-elf-gcc 4.0.3. :\\
Comment by Magnus Holmgren (learman) - Monday, 28 May 2007, 16:35 GMT
Not sure if it is a bug; similar things can be seen in other places with newer versions of GCC. A better fix would be to add "__attribute__ ((used))" to start_thread. (While at it, one could also add "__attribute__ ((noinline))" to stuff that shouldn't be inlined.)
Comment by Alex Gerchanovsky (shoora) - Tuesday, 29 May 2007, 19:15 GMT
Here is patch with __attribute__ ((used)).

Loading...