From 2b04e387dfac7e4a377682070b7fb582cfe10e8a Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Fri, 7 Aug 2026 19:51:34 +0200 Subject: [PATCH] cache.mk: Avoid recaching stale variable values If $(CACHE_PROJECT_MK) AKA .cache-project.mk already exists but needs to be remade because of dependencies, it is included, its content read, then the content cached again to the same file. That way stale variables can leak into the refreshed cache. This commit fixes the situation by removing it, then invoking make again to remake it, thereby clearing the variable database and forcing make to fill the variables afresh. Signed-off-by: Jan Lindemann --- make/cache.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/make/cache.mk b/make/cache.mk index ad46fb5d..c1bde904 100644 --- a/make/cache.mk +++ b/make/cache.mk @@ -32,6 +32,10 @@ clean.cache: cache: $(CACHE_PROJECT_MK) $(CACHE_PROJECT_MK): $(CACHED_FILES) $(JWBDIR)/make/cache.mk +ifneq ($(wildcard $(CACHE_PROJECT_MK)),) + rm -f $@ + make $@ +else @echo 'ifneq ($$(JW_PKG_NO_CACHE),true)' | tee $@.tmp @echo $(foreach v,$(CACHED_VARS),$v = $(value $(v)) EOL) | \ $(SED) 's/\s\+EOL/\n/g;' | \ @@ -42,3 +46,4 @@ $(CACHE_PROJECT_MK): $(CACHED_FILES) $(JWBDIR)/make/cache.mk tee -a $@.tmp @echo 'endif # ifneq ($$(JW_PKG_NO_CACHE),true)' | tee -a $@.tmp mv $@.tmp $@ +endif