Closed
Description
Current setup does not remove unused code and constants. Fixing this is a simple change to platforms.txt
; I changed two lines, for compiler.c.flags
and compiler.c.elf.flags
to:
compiler.c.flags=-c -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections
compiler.c.elf.flags=-g -Os -nostdlib -Wl,--gc-sections -Wl,--no-check-sections -u call_user_start -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-T{build.flash_ld}" -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy
Let me know if you'd like a PR, but the changes are very simple: adding -ffunction-sections -fdata-section
to the first and -Wl,--gc-sections
.
I've tested this on a port of olikraus's excellent ucglib to the ESP; see https://github.com/spapadim/ucglib and olikraus/ucglib#61. The code compiles without issues with these simple changes (otherwise fails, since ucglib compiles all font data, several MB, putting each in a separate section, and relying on the linker to pick the ones actually used).
Metadata
Metadata
Assignees
Labels
No labels