From 09c61efcff64937234b268b8a9d58f9ae15ffcb6 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 1 Jun 2022 11:12:14 -0700 Subject: [PATCH] Split partition from LTO enable --- .../boards/feather_m4_can/mpconfigboard.mk | 2 +- ports/atmel-samd/mpconfigport.mk | 15 ++++++--------- ports/nrf/mpconfigport.mk | 6 ++++-- py/circuitpy_defns.mk | 13 ++++--------- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk index 452acd15af..1c337d6256 100644 --- a/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk @@ -13,4 +13,4 @@ LONGINT_IMPL = MPZ CIRCUITPY__EVE = 1 CIRCUITPY_CANIO = 1 -CIRCUITPY_LTO = one +CIRCUITPY_LTO_PARTITION = one diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 1b0ad7ed67..66ebb54a6b 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -9,6 +9,7 @@ USB_NUM_ENDPOINT_PAIRS = 8 CIRCUITPY_ROTARYIO_SOFTENCODER = 1 CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE ?= 1 +CIRCUITPY_LTO = 1 ###################################################################### # Put samd21-only choices here. @@ -78,7 +79,7 @@ endif SUPEROPT_GC = 0 SUPEROPT_VM = 0 -CIRCUITPY_LTO = one +CIRCUITPY_LTO_PARTITION = one ifeq ($(CIRCUITPY_FULL_BUILD),0) # On the smallest boards, this saves about 180 bytes. On other boards, it may -increase- space used. @@ -96,10 +97,8 @@ ifeq ($(CHIP_FAMILY),samd51) # No native touchio on SAMD51. CIRCUITPY_TOUCHIO_USE_NATIVE = 0 -ifeq ($(CIRCUITPY_FULL_BUILD),1) -CIRCUITPY_LTO ?= balanced -else -CIRCUITPY_LTO ?= one +ifeq ($(CIRCUITPY_FULL_BUILD),0) +CIRCUITPY_LTO_PARTITION ?= one endif # The ?='s allow overriding in mpconfigboard.mk. @@ -124,10 +123,8 @@ ifeq ($(CHIP_FAMILY),same51) # No native touchio on SAME51. CIRCUITPY_TOUCHIO_USE_NATIVE = 0 -ifeq ($(CIRCUITPY_FULL_BUILD),1) -CIRCUITPY_LTO ?= balanced -else -CIRCUITPY_LTO ?= one +ifeq ($(CIRCUITPY_FULL_BUILD),0) +CIRCUITPY_LTO_PARTITION ?= one endif # The ?='s allow overriding in mpconfigboard.mk. diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 4bb4f3dfb4..f265ac1940 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -73,7 +73,8 @@ CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS ifeq ($(INTERNAL_FLASH_FILESYSTEM),1) OPTIMIZATION_FLAGS ?= -Os - CIRCUITPY_LTO=balanced + CIRCUITPY_LTO = 1 + CIRCUITPY_LTO_PARTITION = balanced endif else @@ -94,6 +95,7 @@ NRF_DEFINES += -DNRF52833_XXAA -DNRF52833 OPTIMIZATION_FLAGS ?= -Os -CIRCUITPY_LTO=one +CIRCUITPY_LTO = 1 +CIRCUITPY_LTO_PARTITION = one endif endif diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index a93dce17ca..1918938255 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -68,20 +68,15 @@ CFLAGS += -DCIRCUITPY_DEBUG=0 endif CIRCUITPY_LTO ?= 0 -ifneq ($(CIRCUITPY_LTO),0) -CFLAGS += -DCIRCUITPY_LTO=1 -flto=$(shell $(NPROC)) -flto-partition=$(CIRCUITPY_LTO) -else -CFLAGS += -DCIRCUITPY_LTO=0 +CIRCUITPY_LTO_PARTITION ?= balanced +ifeq ($(CIRCUITPY_LTO),1) +CFLAGS += -flto -flto-partition=$(CIRCUITPY_LTO_PARTITION) endif # Produce an object file for translate.c instead of including it in a header. # The header version can be optimized on non-LTO builds *if* inlining is allowed # otherwise, it blows up the binary sizes with tons of translate copies. -ifeq ($(CIRCUITPY_LTO), 0) -CIRCUITPY_TRANSLATE_OBJECT ?= 0 -else -CIRCUITPY_TRANSLATE_OBJECT ?= 1 -endif +CIRCUITPY_TRANSLATE_OBJECT ?= $(CIRCUITPY_LTO) CFLAGS += -DCIRCUITPY_TRANSLATE_OBJECT=$(CIRCUITPY_TRANSLATE_OBJECT) ###