@zach - yes size optimizations are turned on (-Os) as this was present in the original makefile.
Its reasonable to expect the same code built for ARM-Thumb2 is a little larger than the code built for AVR8, but not 40-some percent.
Its true that there are a bunch of wiring and spark_wiring classes which, even if never used by application.cpp are still instantiated statically. TwoWire, Serial, Serial1 come to mind, though I’m sure there are others. It would be nice in the future to be able to exclude this by compile time option (or not force the static instance all the time) to reduce the size of the binary.
One thing you can do to get an idea of where your code space utilization is coming from is to use arm-none-eabi-size to give the size of each built .o file. Edit the makefile on line 178 from:
$(SIZE) --format=berkeley $<
$(SIZE) --format=berkeley $(ALLOBJ) $<
and rebuild. You’ll get a listing of the .text and .data utilization of each built .o file in the project. This of course doesn’t help you if you’ve #include’d .cpp files into application.cpp. Instead put your cpp files in core-firmware/src and edit core-firmware/src/build.mk to add the source files to the makefile.The format is pretty self explanatory.
-fdata-sections is not included in CFLAGS. I didn’t include this when I rewrote the makefiles since I was trying to copy the existing options as much as possible. This option is included in the Arduino makefile. I did a quick check and by adding -fdata-sections, the code size of my build went down by about 4%. There may be even more savings to be had if -fdata-sections is added to the makefile for core-communications-lib and core-common-lib. I did not test on hardware that the newly built binaries with this option actually run.
For the curious, change core-firmware/build/makefile:58
CFLAGS += -ffunction-sections -Wall -fmessage-length=0
CFLAGS += -ffunction-sections -fdata-sections -Wall -fmessage-length=0
There’s still plenty of incremental improvements to the build system out there for anyone interested in remainder of the makefile bounty.