diff --git a/Makefile b/Makefile index 6177c136c..05f73a54d 100644 --- a/Makefile +++ b/Makefile @@ -131,11 +131,14 @@ endif # Figure out optimize level. ifneq ($(DEBUG_LEVEL), 2) ifeq ($(LITE), 0) - OPT += -O2 + OPTIMIZE_LEVEL ?= -O2 else - OPT += -Os + OPTIMIZE_LEVEL ?= -Os endif endif +# `OPTIMIZE_LEVEL` is empty when the user does not set it and `DEBUG_LEVEL=2`. +# In that case, the compiler default (`-O0` for gcc and clang) will be used. +OPT += $(OPTIMIZE_LEVEL) # compile with -O2 if debug level is not 2 ifneq ($(DEBUG_LEVEL), 2)