Skip to content

Commit e17c400

Browse files
committed
kbuild: shrink .cache.mk when it exceeds 1000 lines
The cache files are only cleaned away by "make clean". If you continue incremental builds, the cache files will grow up little by little. It is not a big deal in general use cases because compiler flags do not change quite often. However, if you do build-test for various architectures, compilers, and kernel configurations, you will end up with huge cache files soon. When the cache file exceeds 1000 lines, shrink it down to 500 by "tail". The Least Recently Added lines are cut. (not Least Recently Used) I hope it will work well enough. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Douglas Anderson <[email protected]>
1 parent 433dc2e commit e17c400

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

scripts/Kbuild.include

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ endif
105105
$(make-cache): ;
106106
-include $(make-cache)
107107

108+
# If cache exceeds 1000 lines, shrink it down to 500.
109+
ifneq ($(word 1000,$(filter __cached_%, $(.VARIABLES))),)
110+
$(shell tail -n 500 $(make-cache) > $(make-cache).tmp; \
111+
mv $(make-cache).tmp $(make-cache))
112+
endif
113+
108114
# Usage: $(call __sanitize-opt,Hello=Hola$(comma)Goodbye Adios)
109115
#
110116
# Convert all '$', ')', '(', '\', '=', ' ', ',', ':' to '_'

0 commit comments

Comments
 (0)