From: Douglas Anderson <dianders@chromium.org>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: malat@debian.org, dave.hansen@intel.com, yang.s@alibaba-inc.com,
linux@roeck-us.net, Douglas Anderson <dianders@chromium.org>,
Matthias Kaehlcke <mka@chromium.org>,
Cao jin <caoj.fnst@cn.fujitsu.com>, Arnd Bergmann <arnd@arndb.de>,
Marcin Nowakowski <marcin.nowakowski@mips.com>,
Mark Charlebois <charlebm@gmail.com>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>
Subject: [PATCH v2 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us
Date: Fri, 22 Dec 2017 14:14:53 -0800 [thread overview]
Message-ID: <20171222221454.137767-2-dianders@chromium.org> (raw)
In-Reply-To: <20171222221454.137767-1-dianders@chromium.org>
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)
-print-file-name=include)
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 <yang.s@alibaba-inc.com>
Reported-by: Dave Hansen <dave.hansen@intel.com>
Reported-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
Changes in v2:
- Don't error if MAKECMDGOALS is blank.
scripts/Kbuild.include | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 065324a8046f..f7efb59d85d1 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -222,6 +222,10 @@ cc-version = $(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-version.
cc-fullversion = $(call shell-cached,$(CONFIG_SHELL) \
$(srctree)/scripts/gcc-version.sh -p $(CC))
+# cc-fullversion-uncached
+cc-fullversion-uncached := $(shell $(CONFIG_SHELL) \
+ $(srctree)/scripts/gcc-version.sh -p $(CC))
+
# cc-ifversion
# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4))
@@ -475,3 +479,16 @@ endif
endef
#
###############################################################################
+
+# Require a 'make clean' if the compiler changed; not only does the .cache.mk
+# need to be thrown out but we should also start with fresh object files.
+#
+# NOTE: it's important that we don't error out when the goal is actually to
+# try to make clean, distclean or mrproper.
+ifeq ($(filter %clean,$(MAKECMDGOALS))$(filter mrproper,$(MAKECMDGOALS)),)
+ ifneq ($(MAKECMDGOALS),)
+ ifneq ($(cc-fullversion-uncached),$(cc-fullversion))
+ $(error Detected new CC version ($(cc-fullversion-uncached) vs $(cc-fullversion)). Please 'make clean')
+ endif
+ endif
+endif
--
2.15.1.620.gb9897f4670-goog
next prev parent reply other threads:[~2017-12-22 22:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-22 22:14 [PATCH v2 0/2] kbuild: Fix corner caches with .cache.mk Douglas Anderson
2017-12-22 22:14 ` Douglas Anderson [this message]
2017-12-31 7:46 ` [PATCH v2 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us Masahiro Yamada
2017-12-22 22:14 ` [PATCH v2 2/2] kbuild: Don't mess with the .cache.mk when installing Douglas Anderson
2017-12-31 8:26 ` Masahiro Yamada
-- strict thread matches above, loose matches on Subject: below --
2017-12-22 22:44 [PATCH v2 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171222221454.137767-2-dianders@chromium.org \
--to=dianders@chromium.org \
--cc=arnd@arndb.de \
--cc=caoj.fnst@cn.fujitsu.com \
--cc=charlebm@gmail.com \
--cc=dave.hansen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=malat@debian.org \
--cc=marcin.nowakowski@mips.com \
--cc=mingo@kernel.org \
--cc=mka@chromium.org \
--cc=ndesaulniers@google.com \
--cc=yamada.masahiro@socionext.com \
--cc=yang.s@alibaba-inc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox