Skip to content

Commit fe02038

Browse files
committed
Changed LTO support check to avr-gcc > 4.9.0 as the 4.8.1 bundled with the IDE prior to 1.6.10
doesn't support LTO or plugins. Fixes Issue #456 So essentially LTO support will only be enabled with avr-gcc 4.9.2 which comes with 1.6.10 or later and Debian, Ubuntu etc; not 4.8.1 which comes with IDE 1.6.9 and a few earlier versions. Tested with: * 1.6.8 (avr-gcc 4.8.1 which doesn't support LTO so uses avr-ar and doesn't set LTO flags) * 1.6.12 (avr-gcc 4.9.2 which supports LTO so uses avr-gcc-ar and sets LTO flags) * 1.0.5 with Debian avr-gcc 4.9.2 (supports LTO so uses avr-gcc-ar and sets LTO flags)
1 parent f3f7684 commit fe02038

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Arduino.mk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,15 +1032,15 @@ CC_VERNUM = $(shell $(CC) -dumpversion | sed 's/\.//g')
10321032

10331033
# moved from above so we can find version-dependant ar
10341034
ifndef AR_NAME
1035-
ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1)
1035+
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
10361036
AR_NAME = avr-gcc-ar
10371037
else
10381038
AR_NAME = avr-ar
10391039
endif
10401040
endif
10411041

10421042
ifndef CFLAGS_STD
1043-
ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1)
1043+
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
10441044
CFLAGS_STD = -std=gnu11 -flto -fno-fat-lto-objects
10451045
else
10461046
CFLAGS_STD =
@@ -1051,7 +1051,7 @@ else
10511051
endif
10521052

10531053
ifndef CXXFLAGS_STD
1054-
ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1)
1054+
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
10551055
CXXFLAGS_STD = -std=gnu++11 -fno-threadsafe-statics -flto
10561056
else
10571057
CXXFLAGS_STD =
@@ -1064,11 +1064,11 @@ endif
10641064
CFLAGS += $(CFLAGS_STD)
10651065
CXXFLAGS += -fpermissive -fno-exceptions $(CXXFLAGS_STD)
10661066
ASFLAGS += -x assembler-with-cpp
1067-
ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1)
1067+
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
10681068
ASFLAGS += -flto
10691069
endif
10701070
LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL)
1071-
ifeq ($(shell expr $(CC_VERNUM) '>' 480), 1)
1071+
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
10721072
LDFLAGS += -flto -fuse-linker-plugin
10731073
endif
10741074
SIZEFLAGS ?= --mcu=$(MCU) -C

HISTORY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The following is the rough list of changes that went into different versions.
55
I tried to give credit whenever possible. If I have missed anyone, kindly add it to the list.
66

77
### In Development
8-
- New: Add LTO support for users with avr-gcc > 4.8 (issue #446) (https://github.com/sej7278)
8+
- New: Add LTO support for users with avr-gcc > 4.9 (issue #446 & #456) (https://github.com/sej7278)
99
- Tweak: Updated Linux instructions and sync documentation from the old blog(), README.md and Arduino.mk (https://github.com/az-z)
1010
- Fix: Updated CXXFLAGS_STD to match upstream 1.6 (issue #424) (https://github.com/calvinli)
1111
- Fix: Added support for attiny core's use of chip instead of cpu in submenus (https://github.com/straccio)

arduino-mk-vars.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ OBJDUMP_NAME = pic32-objdump
822822

823823
Archive utility.
824824

825-
Defaults to `avr-ar` unless you're using toolchain > 4.8.0 in which case we use avr-gcc-ar.
825+
Defaults to `avr-ar` unless you're using toolchain > 4.9.0 in which case we use avr-gcc-ar.
826826

827827
**Example:**
828828

@@ -894,7 +894,7 @@ OPTIMIZATION_LEVEL = 3
894894

895895
Controls, *exclusively*, which C standard is to be used for compilation.
896896

897-
Defaults to `undefined` on 1.0.x or `-std=gnu11 -flto -fno-fat-lto-objects` on 1.5+ or if you install AVR toolchain > 4.8.0
897+
Defaults to `undefined` on 1.0.x or `-std=gnu11 -flto -fno-fat-lto-objects` on 1.5+ or if you install AVR toolchain > 4.9.0
898898

899899
Possible values:
900900

@@ -929,7 +929,7 @@ CFLAGS_STD = = -std=gnu89
929929

930930
Controls, *exclusively*, which C++ standard is to be used for compilation.
931931

932-
Defaults to `undefined` on 1.0 or `-std=gnu++11 -fno-threadsafe-statics -flto` on AVR toolchain > 4.8.0 (e.g. IDE 1.5+)
932+
Defaults to `undefined` on 1.0 or `-std=gnu++11 -fno-threadsafe-statics -flto` on AVR toolchain > 4.9.0 (e.g. IDE 1.6.10+)
933933

934934
Possible values:
935935

0 commit comments

Comments
 (0)