Compiler Flags For Reducing Binary Size

Hello All,

So I’ve finally hit the wall of running out of APP_FLASH. I was looking into custom compiler flags to reduce the app binary size(e.g. Just wondering if anyone has any experience in doing this for particle.

I’ve read a view form posts about this and I do know that I need to build this locally.

With Device OS 2.0.0 you’ll need to modify the Workbench Makefile to add the COMPILE_LTO=y option to the options for building the user firmware binary. For example, for the compile and flash target:

# Compile and flash the user part
flash-user: dfu preprocess
	$(call print_stage,FLASHING APPLICATION)
	cd "$(value DEVICE_OS_PATH)/main" && make all program-dfu COMPILE_LTO=y
	$(call print_success,FLASHED SUCCESSFULLY)

This only works with 2.0.0-rc and later. Make sure you Clean application after changing the value. This will also increase the time spent in the link phase, but it will make the binary smaller.

1 Like

@rickkas7 thanks for the reply.

Good to know there is an option. I see that v2.0.0-rc.4 just got release today. I’ll try this out.

Do we have an approximate/tentative ETA on when v2.0.0+ will move out of the RC phase?