From 5b6e2cecf59a6629279c7629ed50479c6fa9ab45 Mon Sep 17 00:00:00 2001 From: Markus Towara Date: Tue, 15 Nov 2016 21:54:12 +0100 Subject: [PATCH 1/2] bump c/c++ standard to gnu11 needed for constexpr --- Marlin/Makefile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index a5d68a2319..03d93845b8 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -380,12 +380,9 @@ endif CINCS = ${addprefix -I ,${VPATH}} CXXINCS = ${addprefix -I ,${VPATH}} -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -#CSTANDARD = -std=gnu99 +# Compiler flag to set the C/CPP Standard level. +CSTANDARD = -std=gnu99 +CXXSTANDARD = -std=gnu++11 CDEBUG = -g$(DEBUG) CWARN = -Wall -Wstrict-prototypes CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \ @@ -397,8 +394,8 @@ endif #CEXTRA = -Wa,-adhlns=$(<:.c=.lst) CEXTRA = -fno-use-cxa-atexit -CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) -CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) +CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) $(CSTANDARD) +CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) $(CXXSTANDARD) #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs LDFLAGS = -lm From 23a675f6212fc50730f45d49d9ae484fc2727335 Mon Sep 17 00:00:00 2001 From: Markus Towara Date: Tue, 15 Nov 2016 21:57:15 +0100 Subject: [PATCH 2/2] reduce binary size of .hex still a few bytes bigger than with arduino but nothing major --- Marlin/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index 03d93845b8..81eeceada9 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -387,6 +387,7 @@ CDEBUG = -g$(DEBUG) CWARN = -Wall -Wstrict-prototypes CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \ -fshort-enums -w -ffunction-sections -fdata-sections \ + -flto \ -DARDUINO=$(ARDUINO_VERSION) ifneq ($(HARDWARE_MOTHERBOARD),) CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD} @@ -510,7 +511,7 @@ extcoff: $(TARGET).elf # Link: create ELF output file from library. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h $(Pecho) " CXX $@" - $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $(OBJ) $(LDFLAGS) + $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections,--relax -o $@ -L. $(OBJ) $(LDFLAGS) $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE) $(Pecho) " CC $<"