Compiler fixes for Link Time Optimization #286

Closed
wants to merge 6 commits into
from
@@ -40,10 +40,12 @@
* Devices
*/
+
+voidFuncPtr adc1_handlers[] = {[0 ... 2]=0}; //added by bubulindo. EOC, JEOC, AWD
adc_dev adc1 = {
.regs = ADC1_BASE,
.clk_id = RCC_ADC1,
- .handlers = {[3]=0}, //added by bubulindo. EOC, JEOC, AWD
+ .handlers = adc1_handlers,
.irq_num = NVIC_ADC_1_2,
};
/** ADC1 device. */
@@ -57,10 +59,11 @@ adc_dev adc2 = {
adc_dev *ADC2 = &adc2;
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
+voidFuncPtr adc3_handlers[] = {[0 ... 2]=0}; //added by bubulindo. EOC, JEOC, AWD
adc_dev adc3 = {
.regs = ADC3_BASE,
.clk_id = RCC_ADC3,
- .handlers = {[3]=0}, //added by bubulindo. EOC, JEOC, AWD
+ .handlers = adc3_handlers,
.irq_num = NVIC_ADC3,//added by bubulindo.
};
/** ADC3 device. */
@@ -50,72 +50,72 @@ static inline void enable_irq(timer_dev *dev, timer_interrupt_id iid);
*/
#if STM32_HAVE_TIMER(1)
-timer_dev timer1 = ADVANCED_TIMER(1);
+DEFINE_ADVANCED_TIMER(timer1, 1);
/** Timer 1 device (advanced) */
timer_dev *const TIMER1 = &timer1;
#endif
#if STM32_HAVE_TIMER(2)
-timer_dev timer2 = GENERAL_TIMER(2);
+DEFINE_GENERAL_TIMER(timer2, 2);
/** Timer 2 device (general-purpose) */
timer_dev *const TIMER2 = &timer2;
#endif
#if STM32_HAVE_TIMER(3)
-timer_dev timer3 = GENERAL_TIMER(3);
+DEFINE_GENERAL_TIMER(timer3, 3);
/** Timer 3 device (general-purpose) */
timer_dev *const TIMER3 = &timer3;
#endif
#if STM32_HAVE_TIMER(4)
-timer_dev timer4 = GENERAL_TIMER(4);
+DEFINE_GENERAL_TIMER(timer4, 4);
/** Timer 4 device (general-purpose) */
timer_dev *const TIMER4 = &timer4;
#endif
#if STM32_HAVE_TIMER(5)
-timer_dev timer5 = GENERAL_TIMER(5);
+DEFINE_GENERAL_TIMER(timer5, 5);
/** Timer 5 device (general-purpose) */
timer_dev *const TIMER5 = &timer5;
#endif
#if STM32_HAVE_TIMER(6)
-timer_dev timer6 = BASIC_TIMER(6);
+DEFINE_BASIC_TIMER(timer6, 6);
/** Timer 6 device (basic) */
timer_dev *const TIMER6 = &timer6;
#endif
#if STM32_HAVE_TIMER(7)
-timer_dev timer7 = BASIC_TIMER(7);
+DEFINE_BASIC_TIMER(timer7, 7);
/** Timer 7 device (basic) */
timer_dev *const TIMER7 = &timer7;
#endif
#if STM32_HAVE_TIMER(8)
-timer_dev timer8 = ADVANCED_TIMER(8);
+DEFINE_ADVANCED_TIMER(timer8, 8);
/** Timer 8 device (advanced) */
timer_dev *const TIMER8 = &timer8;
#endif
#if STM32_HAVE_TIMER(9)
-timer_dev timer9 = RESTRICTED_GENERAL_TIMER(9, TIMER_DIER_TIE_BIT);
+DEFINE_RESTRICTED_GENERAL_TIMER(timer9, 9, TIMER_DIER_TIE_BIT);
/** Timer 9 device (general-purpose) */
timer_dev *const TIMER9 = &timer9;
#endif
#if STM32_HAVE_TIMER(10)
-timer_dev timer10 = RESTRICTED_GENERAL_TIMER(10, TIMER_DIER_CC1IE_BIT);
+DEFINE_RESTRICTED_GENERAL_TIMER(timer10, 10, TIMER_DIER_CC1IE_BIT);
/** Timer 10 device (general-purpose) */
timer_dev *const TIMER10 = &timer10;
#endif
#if STM32_HAVE_TIMER(11)
-timer_dev timer11 = RESTRICTED_GENERAL_TIMER(11, TIMER_DIER_CC1IE_BIT);
+DEFINE_RESTRICTED_GENERAL_TIMER(timer11, 11, TIMER_DIER_CC1IE_BIT);
/** Timer 11 device (general-purpose) */
timer_dev *const TIMER11 = &timer11;
#endif
#if STM32_HAVE_TIMER(12)
-timer_dev timer12 = RESTRICTED_GENERAL_TIMER(12, TIMER_DIER_TIE_BIT);
+DEFINE_RESTRICTED_GENERAL_TIMER(timer12, 12, TIMER_DIER_TIE_BIT);
/** Timer 12 device (general-purpose) */
timer_dev *const TIMER12 = &timer12;
#endif
#if STM32_HAVE_TIMER(13)
-timer_dev timer13 = RESTRICTED_GENERAL_TIMER(13, TIMER_DIER_CC1IE_BIT);
+DEFINE_RESTRICTED_GENERAL_TIMER(timer13, 13, TIMER_DIER_CC1IE_BIT);
/** Timer 13 device (general-purpose) */
timer_dev *const TIMER13 = &timer13;
#endif
#if STM32_HAVE_TIMER(14)
-timer_dev timer14 = RESTRICTED_GENERAL_TIMER(14, TIMER_DIER_CC1IE_BIT);
+DEFINE_RESTRICTED_GENERAL_TIMER(timer14, 14, TIMER_DIER_CC1IE_BIT);
/** Timer 14 device (general-purpose) */
timer_dev *const TIMER14 = &timer14;
#endif
@@ -1250,7 +1250,7 @@ void vTaskCleanUpResources( void ) PRIVILEGED_FUNCTION;
* Sets the pointer to the current TCB to the TCB of the highest priority task
* that is ready to run.
*/
-void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
+void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION __attribute__((used));
/*
* Return the handle of the calling task.
@@ -1913,7 +1913,7 @@ BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, cons
* Sets the pointer to the current TCB to the TCB of the highest priority task
* that is ready to run.
*/
-void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
+void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION __attribute__((used));
/*
* THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
View
@@ -16,20 +16,20 @@ compiler.warning_flags.all=-Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL
# ----------------------
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
-compiler.c.flags=-c -g -Os {compiler.warning_flags} -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
+compiler.c.flags=-c -g -Os {compiler.warning_flags} -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin} -flto
compiler.c.elf.cmd=arm-none-eabi-g++
-compiler.c.elf.flags=-Os -Wl,--gc-sections
+compiler.c.elf.flags=-Os -Wl,--gc-sections -flto
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
compiler.cpp.cmd=arm-none-eabi-g++
-compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
+compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin} -flto
compiler.ar.cmd=arm-none-eabi-ar
-compiler.ar.flags=rcs
+compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.flags=-O binary
compiler.elf2hex.cmd=arm-none-eabi-objcopy
-compiler.ldflags=
+compiler.ldflags=-flto
compiler.size.cmd=arm-none-eabi-size
compiler.define=-DARDUINO=
@@ -80,7 +80,7 @@ typedef struct adc_dev {
adc_reg_map *regs; /**< Register map */
rcc_clk_id clk_id; /**< RCC clock information */
nvic_irq_num irq_num; /* Added by bubulindo */
- voidFuncPtr handlers[]; /* Added by bubulindo EOC, JEOC, AWD Interrupts*/
+ voidFuncPtr * handlers; /* Added by bubulindo EOC, JEOC, AWD Interrupts*/
} adc_dev;
@@ -127,7 +127,7 @@ typedef struct timer_dev {
timer_reg_map regs; /**< Register map */
rcc_clk_id clk_id; /**< RCC clock information */
timer_type type; /**< Timer's type */
- voidFuncPtr handlers[]; /**<
+ voidFuncPtr * handlers; /**<
* Don't touch these. Use these instead:
* @see timer_attach_interrupt()
* @see timer_detach_interrupt() */
@@ -57,43 +57,30 @@
* [0] = update. */
#define NR_BAS_HANDLERS 1
-/* For declaring advanced timers. */
-#define ADVANCED_TIMER(num) \
- { \
- .regs = { .adv = TIMER##num##_BASE }, \
- .clk_id = RCC_TIMER##num, \
- .type = TIMER_ADVANCED, \
- .handlers = { [NR_ADV_HANDLERS - 1] = 0 }, \
+#define DEFINE_TIMER_INT(var, num, reg_map, timer_type, num_handlers) \
+ voidFuncPtr var##_handlers[] = { [0 ... num_handlers - 1] = 0 }; \
+ timer_dev var = \
+ { \
+ .regs = { .reg_map = TIMER##num##_BASE }, \
+ .clk_id = RCC_TIMER##num, \
+ .type = timer_type, \
+ .handlers = var##_handlers, \
}
+
+/* For declaring advanced timers. */
+#define DEFINE_ADVANCED_TIMER(var, num) DEFINE_TIMER_INT(var, num, adv, TIMER_ADVANCED, NR_ADV_HANDLERS)
+
/* For declaring full-featured general purpose timers. */
-#define GENERAL_TIMER(num) \
- { \
- .regs = { .gen = TIMER##num##_BASE }, \
- .clk_id = RCC_TIMER##num, \
- .type = TIMER_GENERAL, \
- .handlers = { [NR_GEN_HANDLERS - 1] = 0 }, \
- }
+#define DEFINE_GENERAL_TIMER(var, num) DEFINE_TIMER_INT(var, num , gen, TIMER_GENERAL, NR_GEN_HANDLERS)
/* For declaring general purpose timers with limited interrupt
* capability (e.g. timers 9 through 14 on STM32F2 and XL-density
* STM32F1). */
-#define RESTRICTED_GENERAL_TIMER(num, max_dier_bit) \
- { \
- .regs = { .gen = TIMER##num##_BASE }, \
- .clk_id = RCC_TIMER##num, \
- .type = TIMER_GENERAL, \
- .handlers = { [max_dier_bit] = 0 }, \
- }
+#define DEFINE_RESTRICTED_GENERAL_TIMER(var, num, max_dier_bit) DEFINE_TIMER_INT(var, num, gen, TIMER_GENERAL, max_dier_bit + 1)
/* For declaring basic timers (e.g. TIM6 and TIM7). */
-#define BASIC_TIMER(num) \
- { \
- .regs = { .bas = TIMER##num##_BASE }, \
- .clk_id = RCC_TIMER##num, \
- .type = TIMER_BASIC, \
- .handlers = { [NR_BAS_HANDLERS - 1] = 0 }, \
- }
+#define DEFINE_BASIC_TIMER(var, num) DEFINE_TIMER_INT(var, num, bas, TIMER_BASIC, NR_BAS_HANDLERS)
/*
* IRQ handlers