* Re: [PATCH 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us
@ 2017-12-22 21:58 Guenter Roeck
2017-12-22 22:15 ` Doug Anderson
0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2017-12-22 21:58 UTC (permalink / raw)
To: Douglas Anderson
Cc: Masahiro Yamada, malat, dave.hansen, yang.s, Matthias Kaehlcke,
Cao jin, Arnd Bergmann, Mark Charlebois, linux-kernel,
Josh Poimboeuf, Ingo Molnar
On Thu, Dec 21, 2017 at 05:53:02PM -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 <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>
Unfortunately, it doesn't work as-is. Trying to build for mips with two
different compilers, and trying to run "make clean" with the 2nd compiler
version, results in:
scripts/Kbuild.include:490: *** Detected new CC version (050400 vs 040803).
Please 'make clean'. Stop.
Makefile:1297: recipe for target '_clean_.' failed
make: *** [_clean_.] Error 2
make: *** Waiting for unfinished jobs....
scripts/Kbuild.include:490: *** Detected new CC version (050400 vs 040803).
Please 'make clean'. Stop.
Makefile:1297: recipe for target '_clean_arch/mips' failed
make: *** [_clean_arch/mips] Error 2
scripts/Kbuild.include:490: *** Detected new CC version (050400 vs 040803).
Please 'make clean'. Stop.
Makefile:1297: recipe for target '_clean_arch/mips/boot/dts' failed
make: *** [_clean_arch/mips/boot/dts] Error 2
make: *** wait: No child processes. Stop.
Guenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us
2017-12-22 21:58 [PATCH 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us Guenter Roeck
@ 2017-12-22 22:15 ` Doug Anderson
0 siblings, 0 replies; 3+ messages in thread
From: Doug Anderson @ 2017-12-22 22:15 UTC (permalink / raw)
To: Guenter Roeck
Cc: Masahiro Yamada, Mathieu Malaterre, Dave Hansen, Yang Shi,
Matthias Kaehlcke, Cao jin, Arnd Bergmann, Mark Charlebois, LKML,
Josh Poimboeuf, Ingo Molnar
Hi,
On Fri, Dec 22, 2017 at 1:58 PM, Guenter Roeck <linux@roeck-us.net> wrote:
> On Thu, Dec 21, 2017 at 05:53:02PM -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 <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>
>
> Unfortunately, it doesn't work as-is. Trying to build for mips with two
> different compilers, and trying to run "make clean" with the 2nd compiler
> version, results in:
>
> scripts/Kbuild.include:490: *** Detected new CC version (050400 vs 040803).
> Please 'make clean'. Stop.
> Makefile:1297: recipe for target '_clean_.' failed
> make: *** [_clean_.] Error 2
> make: *** Waiting for unfinished jobs....
> scripts/Kbuild.include:490: *** Detected new CC version (050400 vs 040803).
> Please 'make clean'. Stop.
> Makefile:1297: recipe for target '_clean_arch/mips' failed
> make: *** [_clean_arch/mips] Error 2
> scripts/Kbuild.include:490: *** Detected new CC version (050400 vs 040803).
> Please 'make clean'. Stop.
> Makefile:1297: recipe for target '_clean_arch/mips/boot/dts' failed
> make: *** [_clean_arch/mips/boot/dts] Error 2
> make: *** wait: No child processes. Stop.
Indeed. I tried poking around myself today and I clearly saw this
too. I believe I was just doing very simple test cases of "make help"
/ "make clean" yesterday and I thought that would be fine as a
testcase, but clearly not. When I did a more normal make it was easy
to reproduce this.
Poking around it looks like MAKECMDGOALS is somehow blank sometimes as
part of a "make clean". I'll post a v2 that prevents showing the
error in that case too. I'll repeat the caveat that's in my cover
letter that I'm a little lost when it comes to MAKECMDGOALS and how
they get set in all cases, so hopefully this is the right fix.
Sorry for the noise.
I'm going to go ahead and post v2 today even though perhaps not
everyone is done looking at v1. This is because I'll soon disappear
on vacation and I'd rather have a possible fix out there. Hopefully
that's OK w/ everyone.
-Doug
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us
2017-12-22 1:53 [PATCH 0/2] kbuild: Fix corner caches with .cache.mk Douglas Anderson
@ 2017-12-22 1:53 ` Douglas Anderson
0 siblings, 0 replies; 3+ messages in thread
From: Douglas Anderson @ 2017-12-22 1:53 UTC (permalink / raw)
To: Masahiro Yamada
Cc: malat, dave.hansen, yang.s, linux, Douglas Anderson,
Matthias Kaehlcke, Cao jin, Arnd Bergmann, Mark Charlebois,
linux-kernel, Josh Poimboeuf, Ingo Molnar
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>
---
scripts/Kbuild.include | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 065324a8046f..56dee20fb2b8 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,14 @@ 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 ($(cc-fullversion-uncached),$(cc-fullversion))
+ $(error Detected new CC version ($(cc-fullversion-uncached) vs $(cc-fullversion)). Please 'make clean')
+ endif
+endif
--
2.15.1.620.gb9897f4670-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-22 22:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-22 21:58 [PATCH 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us Guenter Roeck
2017-12-22 22:15 ` Doug Anderson
-- strict thread matches above, loose matches on Subject: below --
2017-12-22 1:53 [PATCH 0/2] kbuild: Fix corner caches with .cache.mk Douglas Anderson
2017-12-22 1:53 ` [PATCH 1/2] kbuild: Require a 'make clean' if we detect gcc changed underneath us Douglas Anderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®