diff --git a/Makefile.defines b/Makefile.defines index 9b83c46c..e86c6703 100644 --- a/Makefile.defines +++ b/Makefile.defines @@ -55,18 +55,6 @@ else CFLAGS += --sysroot="$(SYSROOT)" endif -# optimization and debug levels -ifneq ($(DEBUG),0) -OPTI_LVL = -Og -OPTI_ALVL = $(OPTI_LVL) -DBG_LVL = -g3 -else -OPTI_LVL = -Oz -OPTI_ALVL = -Os # assembler does not handle -Oz, use -Os instead -DBG_LVL = -g0 -endif - -CFLAGS += $(OPTI_LVL) $(DBG_LVL) CFLAGS += -fomit-frame-pointer -momit-leaf-frame-pointer CFLAGS += -fno-common -mlittle-endian @@ -91,9 +79,8 @@ CFLAGS += -fropi CFLAGS += -fno-jump-tables # avoid jump tables for switch to avoid problems with invalid PIC access CFLAGS += -nostdlib -nodefaultlibs -AFLAGS += $(OPTI_ALVL) $(DBG_LVL) -fno-common +AFLAGS += -fno-common -LDFLAGS += $(OPTI_LVL) $(DBG_LVL) LDFLAGS += -fomit-frame-pointer LDFLAGS += -Wall LDFLAGS += -fno-common -ffunction-sections -fdata-sections -fwhole-program diff --git a/Makefile.rules b/Makefile.rules index b45f41c5..af19b53b 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -89,4 +89,25 @@ OBJECTS_DIR += $(sort $(dir $(OBJECT_FILES))) DEPEND_FILES = $(subst $(OBJ_DIR), $(DEP_DIR), $(addsuffix .d, $(basename $(OBJECT_FILES)))) DEPEND_DIR += $(sort $(dir $(DEPEND_FILES))) +# optimization and debug levels +# this should be in Makefile.defines, but $(AS) is not yet defined at that point +ifneq ($(DEBUG),0) + OPTI_LVL = -Og + OPTI_ALVL = $(OPTI_LVL) + DBG_LVL = -g3 +else + OPTI_LVL = -Oz + ifeq ($(AS),$(CLANGPATH)clang) + OPTI_ALVL = $(OPTI_LVL) + else + # GCC assembler does not handle -Oz + OPTI_ALVL = -Os + endif + DBG_LVL = -g0 +endif +# at the beginning so they can be overridden by apps +CFLAGS := $(OPTI_LVL) $(DBG_LVL) $(CFLAGS) +AFLAGS := $(OPTI_ALVL) $(DBG_LVL) $(AFLAGS) +LDFLAGS := $(OPTI_LVL) $(DBG_LVL) $(LDFLAGS) + include $(BOLOS_SDK)/Makefile.rules_generic