Skip to content

LTO: Use -flto and -flto-partition only as needed #6436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ports/atmel-samd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ $(echo PERIPHERALS_CHIP_FAMILY=$(PERIPHERALS_CHIP_FAMILY))
ifeq ($(DEBUG), 1)
CFLAGS += -ggdb3 -Og -Os
# You may want to disable -flto if it interferes with debugging.
CFLAGS += -flto -flto-partition=none
CFLAGS += -flto -flto-partition=one
# You may want to enable these flags to make setting breakpoints easier.
# CFLAGS += -fno-inline -fno-ipa-sra
ifeq ($(CHIP_FAMILY), samd21)
Expand All @@ -147,10 +147,11 @@ else
CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT)
endif

CFLAGS += -flto -flto-partition=none
CFLAGS += -flto

ifeq ($(CIRCUITPY_FULL_BUILD),0)
CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20
CFLAGS += -flto-partition=one
endif

ifdef CFLAGS_BOARD
Expand All @@ -167,7 +168,8 @@ CFLAGS += \
-mcpu=cortex-m0plus \
-msoft-float \
-mfloat-abi=soft \
-DSAMD21
-DSAMD21 \
-flto-partition=one
endif
ifeq ($(CHIP_FAMILY), samd51)
CFLAGS += \
Expand Down
9 changes: 8 additions & 1 deletion ports/nrf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,21 @@ INC += -I../../lib/mp-readline
INC += -I../../lib/tinyusb/src
INC += -I../../supervisor/shared/usb

ifeq ($(MCU_CHIP),nrf52833)
OPTIMIZATION_FLAGS ?= -Os -flto -flto-partition=one
else
ifeq ($(INTERNAL_FLASH_FILESYSTEM),1)
OPTIMIZATION_FLAGS ?= -Os -flto
endif
endif

#Debugging/Optimization
ifeq ($(DEBUG), 1)
CFLAGS += -ggdb3
OPTIMIZATION_FLAGS = -Og
else
OPTIMIZATION_FLAGS ?= -O2 -fno-inline-functions
CFLAGS += -DNDEBUG -ggdb3
CFLAGS += -flto -flto-partition=none
endif

ifeq ($(NRF_DEBUG_PRINT), 1)
Expand Down
6 changes: 0 additions & 6 deletions ports/nrf/boards/bluemicro833/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,3 @@ CIRCUITPY_VECTORIO = 0
CIRCUITPY_ZLIB = 0

MICROPY_PY_ASYNC_AWAIT = 0

SUPEROPT_GC = 0
SUPEROPT_VM = 0

# Override optimization to keep binary small
OPTIMIZATION_FLAGS = -Os
5 changes: 0 additions & 5 deletions ports/nrf/boards/microbit_v2/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,3 @@ CIRCUITPY_ULAB = 0
CIRCUITPY_USB = 0

MICROPY_PY_ASYNC_AWAIT = 0

# Override optimization to keep binary small
OPTIMIZATION_FLAGS = -Os
SUPEROPT_VM = 0
SUPEROPT_GC = 0
6 changes: 0 additions & 6 deletions ports/nrf/boards/pca10100/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,3 @@ CIRCUITPY_VECTORIO = 0
CIRCUITPY_ZLIB = 0

MICROPY_PY_ASYNC_AWAIT = 0

SUPEROPT_GC = 0
SUPEROPT_VM = 0

# Override optimization to keep binary small
OPTIMIZATION_FLAGS = -Os
5 changes: 0 additions & 5 deletions ports/nrf/boards/simmel/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,3 @@ CIRCUITPY_ZLIB = 0

# Enable micropython.native
#CIRCUITPY_ENABLE_MPY_NATIVE = 1

# Override optimization to keep binary small
OPTIMIZATION_FLAGS = -Os
SUPEROPT_VM = 0
SUPEROPT_GC = 0
4 changes: 4 additions & 0 deletions ports/nrf/mpconfigport.mk
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52833

# Need the space
SUPEROPT_GC ?= 0
SUPEROPT_VM ?= 0

SD ?= s140
SOFTDEV_VERSION ?= 7.0.1

Expand Down
3 changes: 1 addition & 2 deletions py/circuitpy_mpconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ CFLAGS += -DMICROPY_PY_USELECT_SELECT=$(MICROPY_PY_USELECT_SELECT)
CIRCUITPY_AESIO ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO)

# TODO: CIRCUITPY_ALARM will gradually be added to
# as many ports as possible
# TODO: CIRCUITPY_ALARM will gradually be added to as many ports as possible
# so make this 1 or CIRCUITPY_FULL_BUILD eventually
CIRCUITPY_ALARM ?= 0
CFLAGS += -DCIRCUITPY_ALARM=$(CIRCUITPY_ALARM)
Expand Down