Added LTO flags etc. to provide smaller/faster AVR code.
Works with 1.6.10 or later; or 1.0.x with avr-gcc toolchain 4.8+
This commit is contained in:
parent
7c28446e5e
commit
ab261ddd6e
1 changed files with 26 additions and 8 deletions
32
Arduino.mk
32
Arduino.mk
|
@ -392,10 +392,6 @@ ifndef OBJDUMP_NAME
|
||||||
OBJDUMP_NAME = avr-objdump
|
OBJDUMP_NAME = avr-objdump
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef AR_NAME
|
|
||||||
AR_NAME = avr-ar
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef SIZE_NAME
|
ifndef SIZE_NAME
|
||||||
SIZE_NAME = avr-size
|
SIZE_NAME = avr-size
|
||||||
endif
|
endif
|
||||||
|
@ -1031,16 +1027,32 @@ ifneq ($(CATERINA),)
|
||||||
CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID)
|
CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# avr-gcc version that we can do maths on
|
||||||
|
CC_VERNUM = $(shell $(CC) -dumpversion | sed 's/\.//g')
|
||||||
|
|
||||||
|
# moved from above so we can find version-dependant ar
|
||||||
|
ifndef AR_NAME
|
||||||
|
ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1)
|
||||||
|
AR_NAME = avr-gcc-ar
|
||||||
|
else
|
||||||
|
AR_NAME = avr-ar
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifndef CFLAGS_STD
|
ifndef CFLAGS_STD
|
||||||
|
ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1)
|
||||||
|
CFLAGS_STD = -std=gnu11 -flto -fno-fat-lto-objects
|
||||||
|
else
|
||||||
CFLAGS_STD =
|
CFLAGS_STD =
|
||||||
|
endif
|
||||||
$(call show_config_variable,CFLAGS_STD,[DEFAULT])
|
$(call show_config_variable,CFLAGS_STD,[DEFAULT])
|
||||||
else
|
else
|
||||||
$(call show_config_variable,CFLAGS_STD,[USER])
|
$(call show_config_variable,CFLAGS_STD,[USER])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef CXXFLAGS_STD
|
ifndef CXXFLAGS_STD
|
||||||
ifeq ($(shell expr $(ARDUINO_VERSION) '>' 150), 1)
|
ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1)
|
||||||
CXXFLAGS_STD = -std=gnu++11 -fno-threadsafe-statics
|
CXXFLAGS_STD = -std=gnu++11 -fno-threadsafe-statics -flto
|
||||||
else
|
else
|
||||||
CXXFLAGS_STD =
|
CXXFLAGS_STD =
|
||||||
endif
|
endif
|
||||||
|
@ -1050,9 +1062,15 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += $(CFLAGS_STD)
|
CFLAGS += $(CFLAGS_STD)
|
||||||
CXXFLAGS += -fno-exceptions $(CXXFLAGS_STD)
|
CXXFLAGS += -fpermissive -fno-exceptions $(CXXFLAGS_STD)
|
||||||
ASFLAGS += -x assembler-with-cpp
|
ASFLAGS += -x assembler-with-cpp
|
||||||
|
ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1)
|
||||||
|
ASFLAGS += -flto
|
||||||
|
endif
|
||||||
LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL)
|
LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL)
|
||||||
|
ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1)
|
||||||
|
LDFLAGS += -flto -fuse-linker-plugin
|
||||||
|
endif
|
||||||
SIZEFLAGS ?= --mcu=$(MCU) -C
|
SIZEFLAGS ?= --mcu=$(MCU) -C
|
||||||
|
|
||||||
# for backwards compatibility, grab ARDUINO_PORT if the user has it set
|
# for backwards compatibility, grab ARDUINO_PORT if the user has it set
|
||||||
|
|
Loading…
Reference in a new issue