I'm using ChibiStudio with included GCC 9.2.1. I noticed that when I compile my code with -O0 I get a binary size of around 70 kB. But when I wanted to add more debugging information with -Og -ggdb, the compiled binary size dropped to 47kB and the debugging experience is like with -O2 or -O3 (stepping through the code line by line jumps around like it was optimized on some level). Optimizing for GDB should leave even more information in the binary so I'd expect the size of it to be bigger, and linear code execution just like -O0.
Has anybody come across this?
Here are all my compiler flags:
Code: Select all
-specs=nano.specs -mcpu=cortex-m4 -Og -ggdb3 -fomit-frame-pointer -falign-functions=16 -Wall -ffunction-sections -fdata-sections -fno-common -nostartfiles -Wl,-Map=build/Debug/ch.map,--cref,--no-warn-mismatch,--library-path=/home/szabi/chibios/os/common/startup/ARMCMx/compilers/GCC/ld,--script=board/STM32F427xG.ld,--gc-sections,-print-memory-usage,--defsym=__process_stack_size__=0x1000,--defsym=__main_stack_size__=0x400 -mno-thumb-interwork