From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756734AbdLVWoi (ORCPT ); Fri, 22 Dec 2017 17:44:38 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:45300 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755934AbdLVWog (ORCPT ); Fri, 22 Dec 2017 17:44:36 -0500 X-Google-Smtp-Source: ACJfBospfaKAa/huOMVfcYU8dNcSXgbyVUE+mOrNnCcUV9apIA78l3mDUWn4Whqa7jq/e0C2X4+ttQ== Date: Fri, 22 Dec 2017 14:44:32 -0800 From: Guenter Roeck To: Douglas Anderson Cc: Masahiro Yamada , malat@debian.org, dave.hansen@intel.com, yang.s@alibaba-inc.com, Matthias Kaehlcke , Cao jin , Arnd Bergmann , Marcin Nowakowski , Mark Charlebois , linux-kernel@vger.kernel.org, Ingo Molnar , Nick Desaulniers Subject: Re: [PATCH v2 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us Message-ID: <20171222224432.GA25522@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 22, 2017 at 02:14:53PM -0800, Douglas Anderson wrote: > 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 > > 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 > Reported-by: Dave Hansen > Reported-by: Mathieu Malaterre > Signed-off-by: Douglas Anderson No idea if it is correct, but this version works for me. Tested-by: Guenter Roeck > --- > > 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 >