diff options
author | Craig Hesling <hesling@chromium.org> | 2020-12-15 21:10:58 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-29 23:08:02 +0000 |
commit | be8c81f46a50a6fef9a933c94a0df143ce4168b8 (patch) | |
tree | cb735e0a9a33dfabb9232f68a0a6e82e0c9a4229 /third_party | |
parent | 9da76bf112b451ca3e294100f5c24d188c7860e9 (diff) | |
download | chrome-ec-be8c81f46a50a6fef9a933c94a0df143ce4168b8.tar.gz |
make: Fix ec+cryptoc's no-change remake behavior
Currently, the cryptoc (specifically libcryptoc.a) target is marked as
always PHONY. That means that any project that depends on cryptoc
will always rebuild ec.bin on make invocations.
For example, running make for bloonchipper will show the following
build step repeatedly, even though nothing in libcryptoc changed:
$ make BOARD=bloonchipper
MAKE cryptoc/libcryptoc.a
LD RW/ec.RW.elf
NM RW/ec.RW.smap
OBJCOPY RW/ec.RW.flat
LD RO/ec.RO.elf
NM RO/ec.RO.smap
OBJCOPY RO/ec.RO.flat
SIGN RW/ec.RW.flat.sig
CAT ec.obj
OBJCOPY ec.bin
SIGN ec.bin
EXTR_RW ec.bin
MV ec.bin
*** 80068 bytes in flash ... on bloonchipper RO ****
*** 477576 bytes in flash ... on bloonchipper RW ****
This fix brings the dirty/clean state of cryptoc into the main EC make
process, so that it can assess if libcryptoc.a (and later ec.bin)
actually need to be remade.
We do something similar for the ec version header file that is generated
by the build system itself.
https://github.com/coreboot/chrome-ec/blob/ef6a915de0a2b65c18c03074b66717d597675162/Makefile.rules#L593,L595
This change was only possible with the fix to cryptoc's
Makefile crrev.com/c/2091999 .
With this change, projects that depend on cryptoc will not always force
an unnecessary recompilation, so the above bloonchipper example look
like the following after the initial build:
$ make BOARD=bloonchipper
*** 80068 bytes in flash ... on bloonchipper RO ****
*** 477576 bytes in flash ... on bloonchipper RW ****
BRANCH=none
BUG=none
TEST=rm -rf build
make BOARD=bloonchipper
make BOARD=bloonchipper
# Check that nothing needed to be made
TEST=rm -rf build
make buildall -j7
make BOARD=bloonchipper
# Check that nothing needed to be made
Cq-Depend: chromium:2091999
Change-Id: I3f4d88c9d673f2dc7e29122699521f0f52f7572d
Signed-off-by: Craig Hesling <hesling@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2593881
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/rules.mk | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/third_party/rules.mk b/third_party/rules.mk index 018f7cb432..16fd1e52e3 100644 --- a/third_party/rules.mk +++ b/third_party/rules.mk @@ -17,10 +17,10 @@ CRYPTOC_DIR ?= $(realpath ../../third_party/cryptoc) # SUPPORT_UNALIGNED indicates to libcryptoc that provided data buffers # may be unaligned and please handle them safely. -cmd_libcryptoc_make = $(MAKE) -C $(CRYPTOC_DIR) \ +cmd_libcryptoc = $(MAKE) -C $(CRYPTOC_DIR) \ obj=$(realpath $(out))/cryptoc \ SUPPORT_UNALIGNED=1 -cmd_libcryptoc = $(cmd_libcryptoc_make) -q || $(cmd_libcryptoc_make) +cmd_libcryptoc_clean = $(cmd_libcryptoc) -q && echo clean ifneq ($(BOARD),host) CPPFLAGS += -I$(abspath ./builtin) @@ -28,8 +28,14 @@ endif CPPFLAGS += -I$(CRYPTOC_DIR)/include CRYPTOC_LDFLAGS := -L$(out)/cryptoc -lcryptoc -# Force the external build each time, so it can look for changed sources. +# Conditionally force the rebuilding of libcryptoc.a only if it would be +# changed. +# Note, we use ifndef to ensure the likelyhood of rebuilding is much higher. +# For example, if variable cmd_libcryptoc_clean is modified or blank, +# we will rebuild. +ifneq ($(shell $(cmd_libcryptoc_clean)),clean) .PHONY: $(out)/cryptoc/libcryptoc.a +endif $(out)/cryptoc/libcryptoc.a: +$(call quiet,libcryptoc,MAKE ) |