Merge pull request #452 from sej7278/master

Added LTO flags etc. to provide smaller/faster AVR code.
This commit is contained in:
Sudar Muthu 2016-09-08 21:39:53 +05:30 committed by GitHub
commit fd76029b9a
2 changed files with 38 additions and 20 deletions

View file

@ -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

View file

@ -822,7 +822,7 @@ OBJDUMP_NAME = pic32-objdump
Archive utility.
Defaults to `avr-ar`
Defaults to `avr-ar` unless you're using toolchain > 4.8.0 in which case we use avr-gcc-ar.
**Example:**
@ -894,22 +894,22 @@ OPTIMIZATION_LEVEL = 3
Controls, *exclusively*, which C standard is to be used for compilation.
Defaults to `undefined`
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
Possible values:
* With `avr-gcc 4.3`, shipped with the Arduino IDE:
* With `avr-gcc 4.3`, shipped with the 1.0 Arduino IDE:
* `undefined`
* `-std=c99`
* `-std=gnu89` - This is the default for C code
* `-std=gnu99`
* With `avr-gcc 4.7, 4.8 or 4.9`, installed by you
* With `avr-gcc 4.7, 4.8 or 4.9`, installed by you or 1.5+ IDE:
* `undefined`
* `-std=c99`
* `-std=c11`
* `-std=gnu89` - This is the default for C code
* `-std=gnu89`
* `-std=gnu99`
* `-std=gnu11`
* `-std=gnu11 -flto -fno-fat-lto-objects` - This is the default for C code
For more information, please refer to the [Options Controlling C Dialect](https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html)
@ -929,24 +929,24 @@ CFLAGS_STD = = -std=gnu89
Controls, *exclusively*, which C++ standard is to be used for compilation.
Defaults to `undefined` on 1.0 or `-std=gnu++11 -fno-threadsafe-statics` on 1.5+
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+)
Possible values:
* With `avr-gcc 4.3`, shipped with the Arduino IDE:
* With `avr-gcc 4.3`, shipped with the 1.0 Arduino IDE:
* `undefined`
* `-std=c++98`
* `-std=c++0x`
* `-std=gnu++98` - This is the default for C code
* `-std=gnu++0x`
* With `avr-gcc 4.7, 4.8 or 4.9`, installed by you
* With `avr-gcc 4.7, 4.8 or 4.9`, installed by you or 1.5+ IDE:
* `undefined`
* `-std=c++98`
* `-std=c++11`
* `-std=c++1y`
* `-std=c++14`
* `-std=gnu++98` - This is the default for C++ code
* `-std=gnu++11`
* `-std=gnu++98`
* `-std=gnu++11 -fno-threadsafe-statics -flto` - This is the default for C++ code
* `-std=gnu++1y`
* `-std=gnu++14`
@ -988,7 +988,7 @@ CFLAGS += -my-c-only-flag
Flags passed to the compiler for files compiled as C++. Add more flags to this
variable using `+=`.
Defaults to all flags required for a typical build.
Defaults to `-fpermissive -fno-exceptions`
**Example:**