atmel-samd: parallelize lto linking

This decreases the link time, especially on desktop machines with many CPU
cores.  However, it does come at a slight cost in binary size, making the flash
section about 200 bytes bigger for circuitplayground_express.

Before, linking build-circuitplayground_express/firmware.elf takes
8.8s elapsed time, leaving 3128 bytes free in flash.

After, linking build-circuitplayground_express/firmware.elf takes 2.8s elapsed
time, leaving 2924 bytes free in flash. (-6 seconds, -204 bytes free)

If necessary, we can make this per-board or even per-translation to squeeze full
builds.
This commit is contained in:
Jeff Epler 2020-10-11 21:01:12 -05:00
parent 539e6c6bf6
commit 396979a67e

View File

@ -121,7 +121,7 @@ $(echo PERIPHERALS_CHIP_FAMILY=$(PERIPHERALS_CHIP_FAMILY))
ifeq ($(DEBUG), 1) ifeq ($(DEBUG), 1)
CFLAGS += -ggdb3 -Og CFLAGS += -ggdb3 -Og
# You may want to disable -flto if it interferes with debugging. # You may want to disable -flto if it interferes with debugging.
CFLAGS += -flto -flto-partition=none CFLAGS += -flto
# You may want to enable these flags to make setting breakpoints easier. # You may want to enable these flags to make setting breakpoints easier.
# CFLAGS += -fno-inline -fno-ipa-sra # CFLAGS += -fno-inline -fno-ipa-sra
ifeq ($(CHIP_FAMILY), samd21) ifeq ($(CHIP_FAMILY), samd21)
@ -144,7 +144,7 @@ else
CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT) CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT)
endif endif
CFLAGS += -flto -flto-partition=none CFLAGS += -flto
ifeq ($(CIRCUITPY_FULL_BUILD),0) ifeq ($(CIRCUITPY_FULL_BUILD),0)
CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20 CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20
@ -197,6 +197,7 @@ endif
LDFLAGS = $(CFLAGS) -nostartfiles -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs LDFLAGS = $(CFLAGS) -nostartfiles -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
LDFLAGS += -flto=$(shell nproc)
LIBS := -lgcc -lc LIBS := -lgcc -lc
# Use toolchain libm if we're not using our own. # Use toolchain libm if we're not using our own.