Skip to content

Commit

Permalink
Now uses proper optimization and debug levels
Browse files Browse the repository at this point in the history
  • Loading branch information
apaillier-ledger authored and Xavier Chapron committed Jan 20, 2023
1 parent e151f33 commit 03034cf
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Makefile.defines
Original file line number Diff line number Diff line change
Expand Up @@ -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)),,@)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 03034cf

Please sign in to comment.