From c975de1534f4b4092ad75f85353eec32a9a31b92 Mon Sep 17 00:00:00 2001 From: Boris Gjenero Date: Mon, 22 Oct 2012 21:30:01 +0200 Subject: [PATCH] SH gcc 4.6.3 with link-time optimization, for Archos targets This is work from FS#12431 synced to current HEAD and slightly tweaked (gcc 4.6.2 -> 4.6.3, binutils 2.21.1 -> 2.22) Change-Id: I76af91e80ac2a9c16a776c7f0a33cc51603bbf9b --- apps/plugin.h | 4 ++-- apps/plugins/lib/gcc-support.c | 8 ++++---- firmware/asm/sh/thread.c | 1 + firmware/target/sh/adc-sh.c | 2 +- firmware/target/sh/archos/audio-archos.c | 8 ++++---- firmware/target/sh/archos/timer-archos.c | 2 +- firmware/target/sh/kernel-sh.c | 2 +- firmware/target/sh/system-sh.c | 11 ++++++++--- tools/configure | 6 ++++++ tools/rockboxdev.sh | 4 ++-- 10 files changed, 30 insertions(+), 18 deletions(-) diff --git a/apps/plugin.h b/apps/plugin.h index bb2778164b..ad726d61bf 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -974,9 +974,9 @@ struct plugin_header { extern unsigned char plugin_start_addr[]; extern unsigned char plugin_end_addr[]; #define PLUGIN_HEADER \ - const struct plugin_api *rb DATA_ATTR; \ + const struct plugin_api *rb DATA_ATTR USED_ATTR; \ const struct plugin_header __header \ - __attribute__ ((section (".header")))= { \ + __attribute__ ((section (".header"))) USED_ATTR = { \ { PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \ plugin_start_addr, plugin_end_addr }, plugin__start, &rb }; #else /* PLATFORM_HOSTED */ diff --git a/apps/plugins/lib/gcc-support.c b/apps/plugins/lib/gcc-support.c index 09a08fa9f5..156dbf93eb 100644 --- a/apps/plugins/lib/gcc-support.c +++ b/apps/plugins/lib/gcc-support.c @@ -29,22 +29,22 @@ void __attribute__((naked)) __div0(void) } #endif -void *memcpy(void *dest, const void *src, size_t n) +void USED_ATTR *memcpy(void *dest, const void *src, size_t n) { return rb->memcpy(dest, src, n); } -void *memset(void *dest, int c, size_t n) +void USED_ATTR *memset(void *dest, int c, size_t n) { return rb->memset(dest, c, n); } -void *memmove(void *dest, const void *src, size_t n) +void USED_ATTR *memmove(void *dest, const void *src, size_t n) { return rb->memmove(dest, src, n); } -int memcmp(const void *s1, const void *s2, size_t n) +int USED_ATTR memcmp(const void *s1, const void *s2, size_t n) { return rb->memcmp(s1, s2, n); } diff --git a/firmware/asm/sh/thread.c b/firmware/asm/sh/thread.c index e63470c4a1..c0e0ceb549 100644 --- a/firmware/asm/sh/thread.c +++ b/firmware/asm/sh/thread.c @@ -30,6 +30,7 @@ static void USED_ATTR __start_thread(void) { /* r8 = context */ asm volatile ( + ".global _start_thread \n" "_start_thread: \n" /* Start here - no naked attribute */ "mov.l @(4, r8), r0 \n" /* Fetch thread function pointer */ "mov.l @(28, r8), r15 \n" /* Set initial sp */ diff --git a/firmware/target/sh/adc-sh.c b/firmware/target/sh/adc-sh.c index 2e6d6407b8..17f829ad97 100644 --- a/firmware/target/sh/adc-sh.c +++ b/firmware/target/sh/adc-sh.c @@ -59,7 +59,7 @@ static void adc_tick(void) ADCSR = ADCSR_ADST | ADCSR_ADIE | ADCSR_SCAN | 3; } -void ADITI(void) __attribute__((interrupt_handler)); +void ADITI(void) __attribute__((interrupt_handler)) USED_ATTR; void ADITI(void) { if(ADCSR & ADCSR_ADF) diff --git a/firmware/target/sh/archos/audio-archos.c b/firmware/target/sh/archos/audio-archos.c index 2c2579bec5..207f26f250 100644 --- a/firmware/target/sh/archos/audio-archos.c +++ b/firmware/target/sh/archos/audio-archos.c @@ -153,7 +153,7 @@ static void play_tick(void) } } -void DEI3(void) __attribute__((interrupt_handler)); +void DEI3(void) __attribute__((interrupt_handler)) USED_ATTR; void DEI3(void) { const void* start; @@ -177,7 +177,7 @@ void DEI3(void) CHCR3 &= ~0x0002; /* Clear DMA interrupt */ } -void IMIA1(void) __attribute__((interrupt_handler)); +void IMIA1(void) __attribute__((interrupt_handler)) USED_ATTR; void IMIA1(void) /* Timer 1 interrupt */ { if(playing) @@ -189,14 +189,14 @@ void IMIA1(void) /* Timer 1 interrupt */ #endif } -void IRQ6(void) __attribute__((interrupt_handler)); +void IRQ6(void) __attribute__((interrupt_handler)) USED_ATTR; void IRQ6(void) /* PB14: MAS stop demand IRQ */ { SCR0 &= ~0x80; } #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) -void IRQ3(void) __attribute__((interrupt_handler)); +void IRQ3(void) __attribute__((interrupt_handler)) USED_ATTR; void IRQ3(void) /* PA15: MAS demand IRQ */ { /* Begin with setting the IRQ to edge sensitive */ diff --git a/firmware/target/sh/archos/timer-archos.c b/firmware/target/sh/archos/timer-archos.c index 98a3afb4b6..251d68638a 100644 --- a/firmware/target/sh/archos/timer-archos.c +++ b/firmware/target/sh/archos/timer-archos.c @@ -23,7 +23,7 @@ #include "system.h" #include "timer.h" -void IMIA4(void) __attribute__((interrupt_handler)); +void IMIA4(void) __attribute__((interrupt_handler)) USED_ATTR; void IMIA4(void) { if (pfn_timer != NULL) diff --git a/firmware/target/sh/kernel-sh.c b/firmware/target/sh/kernel-sh.c index 65b27e47f0..d4cfaaa724 100644 --- a/firmware/target/sh/kernel-sh.c +++ b/firmware/target/sh/kernel-sh.c @@ -55,7 +55,7 @@ void tick_start(unsigned int interval_in_ms) TSTR |= 0x01; /* Start timer 1 */ } -void IMIA0(void) __attribute__ ((interrupt_handler)); +void IMIA0(void) __attribute__ ((interrupt_handler)) USED_ATTR; void IMIA0(void) { /* Run through the list of tick tasks */ diff --git a/firmware/target/sh/system-sh.c b/firmware/target/sh/system-sh.c index e054801b57..921d08f7b4 100644 --- a/firmware/target/sh/system-sh.c +++ b/firmware/target/sh/system-sh.c @@ -180,6 +180,7 @@ asm ( * Must go into the same section as the UIE() handler */ "\t.text\n" + ".global\t_UIE4\n" "_UIE4:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n" "_UIE5:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n" "_UIE6:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n" @@ -286,13 +287,17 @@ asm ( "_UIE107:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n" "_UIE108:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n" "_UIE109:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n" - + "_UIE:\tmov.l\t__UIE_k,r0\n" + "jmp\t@r0\n" + "nop\n" + ".align\t4\n" + "__UIE_k:\t.long\t__UIE\n" ); extern void UIE4(void); /* needed for calculating the UIE number */ -void UIE (unsigned int pc) __attribute__((section(".text"))); -void UIE (unsigned int pc) /* Unexpected Interrupt or Exception */ +void _UIE (unsigned int pc) __attribute__((section(".text"))) USED_ATTR; +void _UIE (unsigned int pc) /* Unexpected Interrupt or Exception */ { unsigned int n; diff --git a/tools/configure b/tools/configure index 08d07b7797..4059a95a68 100755 --- a/tools/configure +++ b/tools/configure @@ -3707,6 +3707,12 @@ if test "$CC" = "sh-elf-gcc"; then echo "WARNING: You use an unpatched gcc compiler: $gccver" echo "WARNING: http://www.rockbox.org/twiki/bin/view/Main/CrossCompiler" fi + + if test "$gccnum" -ge "406"; then + echo "Enabling link-time optimization" + GCCOPTS="$GCCOPTS -flto" + fi + fi fi diff --git a/tools/rockboxdev.sh b/tools/rockboxdev.sh index 996aa86aea..78641b5b23 100755 --- a/tools/rockboxdev.sh +++ b/tools/rockboxdev.sh @@ -361,8 +361,8 @@ do # default rule for Objective C. Disable the builtin make rules. See # http://sourceware.org/ml/binutils/2005-12/msg00259.html export MAKEFLAGS="-r $MAKEFLAGS" - build "binutils" "sh-elf" "2.16.1" "" "--disable-werror" - build "gcc" "sh-elf" "4.0.3" "gcc-4.0.3-rockbox-1.diff" + build "binutils" "sh-elf" "2.22" "" "--disable-werror" + build "gcc" "sh-elf" "4.6.3" "" "" "gmp mpfr mpc" ;; [Ii])