Skip to content

Commit

Permalink
Merge #296
Browse files Browse the repository at this point in the history
296: Change `make size` to display family size information, rather than individual size listings r=ppannuto a=bradjc

before:

```
$ make RISCV=1
Application size report for target cortex-m0:
   text	   data	    bss	    dec	    hex	filename
   1664	    196	   2400	   4260	   10a4	build/cortex-m0/cortex-m0.elf
Application size report for target cortex-m3:
   text	   data	    bss	    dec	    hex	filename
   1456	    196	   2400	   4052	    fd4	build/cortex-m3/cortex-m3.elf
Application size report for target cortex-m4:
   text	   data	    bss	    dec	    hex	filename
   1456	    196	   2400	   4052	    fd4	build/cortex-m4/cortex-m4.elf
Application size report for target cortex-m7:
   text	   data	    bss	    dec	    hex	filename
   1456	    196	   2400	   4052	    fd4	build/cortex-m7/cortex-m7.elf
Application size report for target rv32imac.0x20040060.0x80002800:
   text	   data	    bss	    dec	    hex	filename
   1704	    108	   2404	   4216	   1078	build/rv32imac/rv32imac.0x20040060.0x80002800.elf
Application size report for target rv32imac.0x403B0060.0x3FCC0000:
   text	   data	    bss	    dec	    hex	filename
   1704	    108	   2404	   4216	   1078	build/rv32imac/rv32imac.0x403B0060.0x3FCC0000.elf
Application size report for target rv32imc.0x41000060.0x42008000:
   text	   data	    bss	    dec	    hex	filename
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x41000060.0x42008000.elf
Application size report for target rv32imc.0x00080060.0x40008000:
   text	   data	    bss	    dec	    hex	filename
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x00080060.0x40008000.elf
Application size report for target rv32imc.0x20030080.0x10005000:
   text	   data	    bss	    dec	    hex	filename
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x20030080.0x10005000.elf
Application size report for target rv32imc.0x20030880.0x10008000:
   text	   data	    bss	    dec	    hex	filename
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x20030880.0x10008000.elf
Application size report for target rv32imc.0x20032080.0x10008000:
   text	   data	    bss	    dec	    hex	filename
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x20032080.0x10008000.elf
Application size report for target rv32imc.0x20034080.0x10008000:
   text	   data	    bss	    dec	    hex	filename
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x20034080.0x10008000.elf
Application size report for target rv32imac.0x40430060.0x80004000:
   text	   data	    bss	    dec	    hex	filename
   1704	    108	   2404	   4216	   1078	build/rv32imac/rv32imac.0x40430060.0x80004000.elf
Application size report for target rv32imac.0x40440060.0x80007000:
   text	   data	    bss	    dec	    hex	filename
   1704	    108	   2404	   4216	   1078	build/rv32imac/rv32imac.0x40440060.0x80007000.elf
```

after:

```
$make RISCV=1
Application size report for arch family cortex-m:
   text	   data	    bss	    dec	    hex	filename
   1664	    196	   2400	   4260	   10a4	build/cortex-m0/cortex-m0.elf
   1456	    196	   2400	   4052	    fd4	build/cortex-m3/cortex-m3.elf
   1456	    196	   2400	   4052	    fd4	build/cortex-m4/cortex-m4.elf
   1456	    196	   2400	   4052	    fd4	build/cortex-m7/cortex-m7.elf
   6032	    784	   9600	  16416	   4020	(TOTALS)
Application size report for arch family rv32i:
   text	   data	    bss	    dec	    hex	filename
   1704	    108	   2404	   4216	   1078	build/rv32imac/rv32imac.0x20040060.0x80002800.elf
   1704	    108	   2404	   4216	   1078	build/rv32imac/rv32imac.0x403B0060.0x3FCC0000.elf
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x41000060.0x42008000.elf
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x00080060.0x40008000.elf
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x20030080.0x10005000.elf
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x20030880.0x10008000.elf
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x20032080.0x10008000.elf
   1752	    108	   2404	   4264	   10a8	build/rv32imc/rv32imc.0x20034080.0x10008000.elf
   1704	    108	   2404	   4216	   1078	build/rv32imac/rv32imac.0x40430060.0x80004000.elf
   1704	    108	   2404	   4216	   1078	build/rv32imac/rv32imac.0x40440060.0x80007000.elf
  17328	   1080	  24040	  42448	   a5d0	(TOTALS)
```

Co-authored-by: Brad Campbell <bradjc5@gmail.com>
  • Loading branch information
bors[bot] and bradjc committed Sep 2, 2022
2 parents c8c4c5a + 37d9445 commit c7d5dcf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
29 changes: 28 additions & 1 deletion AppMakefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,31 @@ $$(BUILDDIR)/$(1)/$(2).userland_debug.lst: $$(BUILDDIR)/$(1)/$(2).userland_debug
############################################################################################
endef


# Rules that apply to an entire architecture family (e.g. cortex-m).
#
# - Argument $(1) is the architecture family (e.g. cortex-m).
# - Argument $(2) is the list of architectures in that family.
# - Argument $(3) is the list of output names for the .elf of each arch.
#
# Note: all variables, other than $(1), used within this block must be double
# dollar-signed so that their values will be evaluated when run, not when
# generated.
define ARCH_FAMILY_RULES

$(1)_DIRECTORY_NAMES := $$(addsuffix /,$(2))
$(1)_DIRECTORY_FILES := $$(join $$($(1)_DIRECTORY_NAMES),$(3))
$(1)_DIRECTORY_FILES_EXT := $$(addsuffix .elf,$$($(1)_DIRECTORY_FILES))
$(1)_ELF_FILES := $$(addprefix $$(BUILDDIR)/,$$($(1)_DIRECTORY_FILES_EXT))

# Rule to print the size of the built binaries from an architecture family.
.PHONY: size-$(1)
size-$(1): $$($(1)_ELF_FILES)
@echo Application size report for arch family $(1):
$$(Q)$$(TOOLCHAIN_$(1))$$(SIZE) -t $$^

endef

# Functions to parse the `TOCK_TARGETS` array. Entries 3 and 4 default to the
# PIC addresses if they are not specified.
ARCH_FN = $(firstword $(subst |, ,$1))
Expand All @@ -279,6 +304,7 @@ RAM_ADDRESS_FN = $(if $(word 4,$(subst |, ,$1)),$(word 4,$(subst |, ,$1)),0x0000
# Actually generate the rules for each architecture
$(foreach platform, $(TOCK_ARCHS), $(eval $(call BUILD_RULES_PER_ARCH,$(platform))))
$(foreach platform, $(TOCK_TARGETS), $(eval $(call BUILD_RULES,$(call ARCH_FN,$(platform)),$(call OUTPUT_NAME_FN,$(platform)),$(call FLASH_ADDRESS_FN,$(platform)),$(call RAM_ADDRESS_FN,$(platform)))))
$(foreach family, $(TOCK_ARCH_FAMILIES), $(eval $(call ARCH_FAMILY_RULES,$(family),$(foreach target, $(filter $(family)%,$(TOCK_TARGETS)), $(call ARCH_FN, $(target))),$(foreach target, $(filter $(family)%,$(TOCK_TARGETS)), $(call OUTPUT_NAME_FN, $(target))))))



Expand All @@ -290,8 +316,9 @@ $(BUILDDIR)/$(PACKAGE_NAME).tab: $(foreach platform, $(TOCK_TARGETS), $(BUILDDIR


# Rules for building apps
SIZE_RULES = $(addprefix size-,$(TOCK_ARCH_FAMILIES))
.PHONY: all
all: $(BUILDDIR)/$(PACKAGE_NAME).tab size
all: $(BUILDDIR)/$(PACKAGE_NAME).tab $(SIZE_RULES)

# The size target accumulates dependencies in the platform build rule creation
.PHONY: size
Expand Down
11 changes: 7 additions & 4 deletions Configuration.mk
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ PACKAGE_NAME ?= $(shell basename "$(shell pwd)")
# targets build by default as well.
ifeq ($(RISCV),)
TOCK_TARGETS ?= cortex-m0 cortex-m3 cortex-m4 cortex-m7
TOCK_ARCH_FAMILIES ?= cortex-m
else
# Specific addresses useful for the OpenTitan hardware memory map.
OPENTITAN_TOCK_TARGETS := rv32imc|rv32imc.0x20030080.0x10005000|0x20030080|0x10005000\
Expand All @@ -92,6 +93,7 @@ TOCK_TARGETS ?= cortex-m0\
rv32imc|rv32imc.0x00080060.0x40008000|0x00080060|0x40008000\
$(OPENTITAN_TOCK_TARGETS) \
$(ARTY_E21_TOCK_TARGETS)
TOCK_ARCH_FAMILIES ?= cortex-m rv32i
endif

# Generate `TOCK_ARCHS`, the set of architectures listed in `TOCK_TARGETS`.
Expand Down Expand Up @@ -314,10 +316,11 @@ override LEGACY_LIBS_rv32imac += \

# Setup the correct toolchain for each architecture. ARM has a standard
# toolchain we can use for every variant.
TOOLCHAIN_cortex-m0 := arm-none-eabi
TOOLCHAIN_cortex-m3 := arm-none-eabi
TOOLCHAIN_cortex-m4 := arm-none-eabi
TOOLCHAIN_cortex-m7 := arm-none-eabi
TOOLCHAIN_cortex-m := arm-none-eabi
TOOLCHAIN_cortex-m0 := $(TOOLCHAIN_cortex-m)
TOOLCHAIN_cortex-m3 := $(TOOLCHAIN_cortex-m)
TOOLCHAIN_cortex-m4 := $(TOOLCHAIN_cortex-m)
TOOLCHAIN_cortex-m7 := $(TOOLCHAIN_cortex-m)

# Setup the correct compiler. For cortex-m we only support GCC as it is the only
# toolchain with the PIC support we need for Tock userspace apps.
Expand Down
1 change: 1 addition & 0 deletions examples/lua-hello/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TOCK_USERLAND_BASE_DIR = ../..
# We only compile this for Cortex-M platforms because of compiler
# errors when building lua on risc-v.
TOCK_TARGETS := cortex-m0 cortex-m3 cortex-m4 cortex-m7
TOCK_ARCH_FAMILIES := cortex-m

# Which files to compile.
C_SRCS := $(wildcard *.c)
Expand Down

0 comments on commit c7d5dcf

Please sign in to comment.