From c97721455a17ba2c26ce575f6a711ccb27acf844 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 4 Mar 2021 23:07:06 -0500 Subject: [PATCH 1/2] Shrink the smallest builds with compile options --- ports/atmel-samd/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 48724af0c875d..3da37906233bb 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -150,7 +150,13 @@ else CFLAGS += -flto -flto-partition=none ifeq ($(CIRCUITPY_FULL_BUILD),0) - CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20 + # Increasing max-inline-insns-auto from 20 to 1000 gains about 300 bytes on a small build. + CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=1000 + # These optimizations are normally -O3 only. They improve the way register + # allocation is done, but, to quote the gcc doc, 'can, however, make debugging impossible, + # since variables will no longer stay in a “home register”.' + # On a small build they can gain about 200 bytes. + CFLAGS += -fweb -frename-registers endif ifdef CFLAGS_BOARD From 4cf6579e2201e62988fbb6cf204037ce0d80e3f1 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 5 Mar 2021 10:10:50 -0500 Subject: [PATCH 2/2] remove general changes; not consistent across builds --- ports/atmel-samd/Makefile | 8 +------- ports/atmel-samd/boards/meowmeow/mpconfigboard.mk | 1 + ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk | 8 +------- ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk | 3 +++ 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 3da37906233bb..48724af0c875d 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -150,13 +150,7 @@ else CFLAGS += -flto -flto-partition=none ifeq ($(CIRCUITPY_FULL_BUILD),0) - # Increasing max-inline-insns-auto from 20 to 1000 gains about 300 bytes on a small build. - CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=1000 - # These optimizations are normally -O3 only. They improve the way register - # allocation is done, but, to quote the gcc doc, 'can, however, make debugging impossible, - # since variables will no longer stay in a “home register”.' - # On a small build they can gain about 200 bytes. - CFLAGS += -fweb -frename-registers + CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20 endif ifdef CFLAGS_BOARD diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk index 175501313e04b..8ee9d23fe5bfe 100644 --- a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk +++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk @@ -14,3 +14,4 @@ CIRCUITPY_COUNTIO = 0 CIRCUITPY_RTC = 0 SUPEROPT_GC = 0 +SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index 1614779684113..99dddfa892d3e 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -25,6 +25,7 @@ CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 CIRCUITPY_SAMD = 0 CIRCUITPY_TOUCHIO = 0 +CIRCUIPTY_USB_CDC = 0 CIRCUITPY_USB_HID = 0 CIRCUITPY_USB_MIDI = 0 CIRCUITPY_VECTORIO = 0 @@ -40,12 +41,5 @@ CIRCUITPY_STAGE = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pewpew_m4 CIRCUITPY_DISPLAY_FONT = $(TOP)/ports/atmel-samd/boards/ugame10/brutalist-6.bdf -# Tweak inlining depending on language. -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 45 -else -CFLAGS_INLINE_LIMIT = 70 -endif # Override optimization to keep binary small OPTIMIZATION_FLAGS = -Os diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk index 6595fa164d7d0..fbbb974cdfc7d 100644 --- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk @@ -12,3 +12,6 @@ CIRCUITPY_FULL_BUILD = 0 SUPEROPT_GC = 0 SUPEROPT_VM = 0 + +# On this particular board, these save about 180 bytes. On other boards, they may -increase- space used. +CFLAGS_BOARD = -fweb -frename-registers