Skip to content

Commit

Permalink
Now uses same optimization level for compiling and assembling with clang
Browse files Browse the repository at this point in the history
  • Loading branch information
apaillier-ledger committed Oct 10, 2024
1 parent 64e52fb commit 6fc02aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
15 changes: 1 addition & 14 deletions Makefile.defines
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6fc02aa

Please sign in to comment.