Skip to content

Commit

Permalink
Merge pull request #793 from LedgerHQ/feat/apa/only_clang_std_app
Browse files Browse the repository at this point in the history
Full clang build for standard apps
  • Loading branch information
apaillier-ledger authored Oct 14, 2024
2 parents 0bac17f + 6fc02aa commit 81fad31
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 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
7 changes: 5 additions & 2 deletions Makefile.standard_app
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,11 @@ APP_FLAGS_APP_LOAD_PARAMS = $(shell printf '0x%x' $$(( $(STANDARD_APP_FLAGS) + $
# COMPILER SETTINGS #
#####################################################################
CC := $(CLANGPATH)clang
AS := $(GCCPATH)arm-none-eabi-gcc
LD := $(GCCPATH)arm-none-eabi-gcc
AS := $(CLANGPATH)clang
LD := $(CLANGPATH)clang
ifeq ($(AS),$(CLANGPATH)clang)
AFLAGS += --target=arm-arm-none-eabi -Wno-unused-command-line-argument
endif
LDLIBS += -lm -lgcc -lc

#####################################################################
Expand Down

0 comments on commit 81fad31

Please sign in to comment.