I have a simple FreeRTOS application that simply switches the LED to the main loop. When I compile it with -Os, the resulting binary is of size 0. Without it, -Oseverything works as expected. What's going on here?
My CFLAGS:
CPUFLAG = -mthumb -mcpu=cortex-m4
FPUFLAG = -mfpu=fpv4-sp-d16 -mfloat-abi=hard
WFLAG = -Wall -Wextra -Werror -Wstrict-prototypes
CFLAGS += -std=gnu99 $(WFLAG) $(CPUFLAG) $(FPUFLAG) -mlittle-endian -mthumb -nostartfiles
CFLAGS += -ffunction-sections -fdata-sections -fno-builtin
LDFLAGS += -nostdlib --gc-sections -static
main - basically TI blinky demo:
int main(void)
{
volatile uint32_t ui32Loop;
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;
ui32Loop = SYSCTL_RCGC2_R;
GPIO_PORTF_DIR_R = 0x08;
GPIO_PORTF_DEN_R = 0x08;
while(1)
{
GPIO_PORTF_DATA_R |= 0x08;
for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)
{
}
GPIO_PORTF_DATA_R &= ~(0x08);
for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)
{
}
}
return 0;
}
With -Osit generates
text data bss dec hex filename
0 0 0 0 0 image.elf
otherwise
text data bss dec hex filename
2012 4 728 2744 ab8 image.elf
edit : differences in .map files
source
share