Skip to content

Commit

Permalink
kbuild: shrink .cache.mk when it exceeds 1000 lines
Browse files Browse the repository at this point in the history
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 <yamada.masahiro@socionext.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
  • Loading branch information
masahir0y committed Nov 13, 2017
1 parent 433dc2e commit e17c400
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/Kbuild.include
Expand Up @@ -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))
endif

# Usage: $(call __sanitize-opt,Hello=Hola$(comma)Goodbye Adios)
#
# Convert all '$', ')', '(', '\', '=', ' ', ',', ':' to '_'
Expand Down

0 comments on commit e17c400

Please sign in to comment.