diff options
| author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2024-06-05 12:01:12 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-07-26 11:13:11 +1000 |
| commit | 62e0fa04a7a6f9044db1bb0f20ea7a2e00599921 (patch) | |
| tree | f118bdf1c758f7be847a0911bcf658971fb1c58d | |
| parent | 56c161738496c03f0d651264861ff0c334b04e5d (diff) | |
nrf/Makefile: Enable LTO by default only on newer gcc.
Older gcc/binutils linker does not support lto with wrap.
Signed-off-by: Andrew Leech <andrew@alelec.net>
| -rw-r--r-- | ports/nrf/Makefile | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index d955d183a..621f7d33c 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -129,7 +129,15 @@ CFLAGS_MCU_m4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-s CFLAGS_MCU_m0 = $(CFLAGS_CORTEX_M) -fshort-enums -mtune=cortex-m0 -mcpu=cortex-m0 -mfloat-abi=soft +# linker wrap does not work with lto on older gcc/binutils: https://sourceware.org/bugzilla/show_bug.cgi?id=24406 +GCC_VERSION = $(shell arm-none-eabi-gcc --version | sed -n -E 's:^arm.*([0-9]+\.[0-9]+\.[0-9]+).*$$:\1:p') +GCC_MAJOR_VERS = $(word 1,$(subst ., ,$(GCC_VERSION))) +ifeq ($(shell test $(GCC_MAJOR_VERS) -ge 10; echo $$?),0) LTO ?= 1 +else +LTO ?= 0 +endif + ifeq ($(LTO),1) CFLAGS += -flto else |
