diff options
| author | Simon John <git@the-jedi.co.uk> | 2016-09-08 14:49:36 +0100 |
|---|---|---|
| committer | Simon John <git@the-jedi.co.uk> | 2016-09-08 14:49:36 +0100 |
| commit | ab261ddd6ebbaf046afe783e4312d1a9900dc932 (patch) | |
| tree | 2d722bcc981f3fd97cc06505b82cff178b6755ee /Arduino.mk | |
| parent | 7c28446e5e685bc01f8a1bfee87275701ad03c6a (diff) | |
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+
Diffstat (limited to 'Arduino.mk')
| -rw-r--r-- | Arduino.mk | 34 |
1 files changed, 26 insertions, 8 deletions
@@ -392,10 +392,6 @@ ifndef OBJDUMP_NAME OBJDUMP_NAME = avr-objdump endif -ifndef AR_NAME -AR_NAME = avr-ar -endif - ifndef SIZE_NAME SIZE_NAME = avr-size endif @@ -1031,16 +1027,32 @@ ifneq ($(CATERINA),) CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) 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 - CFLAGS_STD = + ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1) + CFLAGS_STD = -std=gnu11 -flto -fno-fat-lto-objects + else + CFLAGS_STD = + endif $(call show_config_variable,CFLAGS_STD,[DEFAULT]) else $(call show_config_variable,CFLAGS_STD,[USER]) endif ifndef CXXFLAGS_STD - ifeq ($(shell expr $(ARDUINO_VERSION) '>' 150), 1) - CXXFLAGS_STD = -std=gnu++11 -fno-threadsafe-statics + ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1) + CXXFLAGS_STD = -std=gnu++11 -fno-threadsafe-statics -flto else CXXFLAGS_STD = endif @@ -1050,9 +1062,15 @@ else endif CFLAGS += $(CFLAGS_STD) -CXXFLAGS += -fno-exceptions $(CXXFLAGS_STD) +CXXFLAGS += -fpermissive -fno-exceptions $(CXXFLAGS_STD) 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) +ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1) + LDFLAGS += -flto -fuse-linker-plugin +endif SIZEFLAGS ?= --mcu=$(MCU) -C # for backwards compatibility, grab ARDUINO_PORT if the user has it set |
