Arduino.mk: make LTO optional, enabled by default

On Fedora 25 with avr-gcc 6.2.0 LTO crashes, e.g., if Serial is used.
This commit is contained in:
Tim Niemueller 2017-03-06 17:02:44 +01:00
parent 08b4f441ff
commit c4f0860660
2 changed files with 16 additions and 4 deletions

View file

@ -1039,9 +1039,17 @@ ifndef AR_NAME
endif
endif
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
USE_LTO ?= 1
endif
ifndef CFLAGS_STD
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
CFLAGS_STD = -std=gnu11 -flto -fno-fat-lto-objects
CFLAGS_STD = -std=gnu11
ifeq ($(USE_LTO),1)
CFLAGS_STD += -flto -fno-fat-lto-objects
endif
else
CFLAGS_STD =
endif
@ -1052,7 +1060,10 @@ endif
ifndef CXXFLAGS_STD
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
CXXFLAGS_STD = -std=gnu++11 -fno-threadsafe-statics -flto
CXXFLAGS_STD = -std=gnu++11 -fno-threadsafe-statics
ifeq ($(USE_LTO),1)
CXXFLAGS_STD += -flto
endif
else
CXXFLAGS_STD =
endif
@ -1064,11 +1075,11 @@ endif
CFLAGS += $(CFLAGS_STD)
CXXFLAGS += -fpermissive -fno-exceptions $(CXXFLAGS_STD)
ASFLAGS += -x assembler-with-cpp
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
ifeq ($(USE_LTO), 1)
ASFLAGS += -flto
endif
LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL)
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
ifeq ($(USE_LTO), 1)
LDFLAGS += -flto -fuse-linker-plugin
endif
SIZEFLAGS ?= --mcu=$(MCU) -C

View file

@ -7,6 +7,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
### In Development
- Fix: Do not include the Arduino header when calling generate_assembly on .cpp files. (https://github.com/Batchyx)
- Fix: Auto-detect F_CPU on Teensy from boards.txt (https://github.com/DaWelter)
- Tweak: Allow to disable LTO (currently crashes on Fedora 25)
### 1.5.2 (2017-01-11)