From 03034cf13b836ac6ec6d78d70d845d6297e3ed43 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Tue, 18 Jan 2022 09:41:52 +0100 Subject: [PATCH] Now uses proper optimization and debug levels --- Makefile.defines | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile.defines b/Makefile.defines index 784aa1791..4f95ff970 100644 --- a/Makefile.defines +++ b/Makefile.defines @@ -50,6 +50,9 @@ DEFINES += gcc __IO=volatile # no assert by default DEFINES += NDEBUG +# Debug mode disabled by default +DEBUG:=0 + # default is not to display make commands log = $(if $(strip $(VERBOSE)),$1,@$1) # kept for retrocompat L = $(if $(strip $(VERBOSE)),,@) @@ -65,8 +68,17 @@ else CFLAGS += --sysroot="$(SYSROOT)" endif +# optimization and debug levels +ifneq ($(DEBUG),0) +OPTI_LVL = -O0 +DBG_LVL = -g3 +else +OPTI_LVL = -Oz +DBG_LVL = -g0 +endif + CFLAGS += -gdwarf-2 -gstrict-dwarf -CFLAGS += -O3 -Os +CFLAGS += $(OPTI_LVL) $(DBG_LVL) CFLAGS += -fomit-frame-pointer -momit-leaf-frame-pointer CFLAGS += -fno-common -mlittle-endian @@ -77,10 +89,11 @@ CFLAGS += -fropi CFLAGS += -fno-jump-tables # avoid jump tables for switch to avoid problems with invalid PIC access CFLAGS += -nostdlib -nodefaultlibs -AFLAGS += -ggdb2 -O3 -Os -fno-common +# this does not handle -Oz, force -Os instead +AFLAGS += -Os $(DBG_LVL) -fno-common LDFLAGS += -gdwarf-2 -gstrict-dwarf -LDFLAGS += -O3 -Os +LDFLAGS += $(OPTI_LVL) $(DBG_LVL) LDFLAGS += -fomit-frame-pointer LDFLAGS += -Wall LDFLAGS += -fno-common -ffunction-sections -fdata-sections -fwhole-program