[lkml]   [2018]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v3 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us
Several people reported that the commit 3298b690b21c ("kbuild: Add a
cache for generated variables") caused them problems when they updated
gcc versions. Specifically the reports all looked something similar
to this:

> In file included from ./include/uapi/linux/uuid.h:21:0,
> from ./include/linux/uuid.h:19,
> from ./include/linux/mod_devicetable.h:12,
> from scripts/mod/devicetable-offsets.c:2:
> ./include/linux/string.h:8:20: fatal error: stdarg.h: No such file or
> directory
> #include <stdarg.h>

Masahiro Yamada determined that the problem was with:

NOSTDINC_FLAGS += -nostdinc -isystem $(call shell-cached,$(CC)

Specifically that the stale result of -print-file-name is stored in
the cache file. It was determined that a "make clean" fixed the
problems in all cases.

In this particular case we could certainly try to clean just the cache
when we detect a gcc update, but it seems like overall it's a bad idea
to do an incremental build when gcc changes. We should warn the user
and tell them that they need a 'make clean'.

Fixes: 3298b690b21c ("kbuild: Add a cache for generated variables")
Reported-by: Yang Shi <>
Reported-by: Dave Hansen <>
Reported-by: Mathieu Malaterre <>
Signed-off-by: Douglas Anderson <>

Changes in v3:
- Fix as per Masahiro Yamada (move change to main Makefile)

Changes in v2:
- Don't error if MAKECMDGOALS is blank.

Makefile | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/Makefile b/Makefile
index c4322dea3ca2..f1e61470640b 100644
--- a/Makefile
+++ b/Makefile
@@ -573,6 +573,15 @@ virt-y := virt/

ifeq ($(dot-config),1)
+# Require a 'make clean' if the compiler changed; not only does the
+# need to be thrown out but we should also start with fresh object files.
+cc-fullversion-uncached := \
+ $(shell $(CONFIG_SHELL) $(srctree)/scripts/ -p $(CC))
+ifneq ($(cc-fullversion-uncached),$(cc-fullversion))
+ $(error Detected new CC version ($(cc-fullversion-uncached) vs $(cc-fullversion)). Please 'make clean')
# Read in config
-include include/config/auto.conf

 \ /
  Last update: 2018-03-13 07:13    [W:0.049 / U:5.416 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site