Commit e17c400a authored by Masahiro Yamada's avatar Masahiro Yamada

kbuild: shrink 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's avatarMasahiro Yamada <>
Reviewed-by: default avatarDouglas Anderson <>
parent 433dc2eb
......@@ -105,6 +105,12 @@ endif
$(make-cache): ;
-include $(make-cache)
# If cache exceeds 1000 lines, shrink it down to 500.
ifneq ($(word 1000,$(filter __cached_%, $(.VARIABLES))),)
$(shell tail -n 500 $(make-cache) > $(make-cache).tmp; \
mv $(make-cache).tmp $(make-cache))
# Usage: $(call __sanitize-opt,Hello=Hola$(comma)Goodbye Adios)
# Convert all '$', ')', '(', '\', '=', ' ', ',', ':' to '_'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment