linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] kbuild: ensure full rebuild when the compiler is updated
@ 2020-04-21 12:48 Masahiro Yamada
  2020-04-21 12:48 ` [PATCH 2/2] kbuild: use -MMD instead of -MD to exclude system headers from dependency Masahiro Yamada
  0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2020-04-21 12:48 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, linux-kernel

Commit 21c54b774744 ("kconfig: show compiler version text in the top
comment") added the environment variable, CC_VERSION_TEXT in the comment
of the top Kconfig file. It can detect the compiler update, and invoke
the syncconfig because all environment variables referenced in Kconfig
files are recorded in include/config/auto.conf.cmd

This commit makes it a CONFIG option in order to ensure the full rebuild
when the compiler is updated.

This works like as follows:

include/config/kconfig.h contains "CONFIG_CC_VERSION_TEXT" in the comment
block.

The top Makefile specifies "-include $(srctree)/include/linux/kconfig.h"
to guarantee it is included from all kernel source files.

fixdep parses every source file and all headers included from it,
searching for words prefixed with "CONFIG_". Then, fixdep finds
CONFIG_CC_VERSION_TEXT in include/config/kconfig.h and adds
include/config/cc/version/text.h into every .*.cmd file.

When the compiler is updated, syncconfig is invoked since the environment
variable is referenced. CONFIG_CC_VERSION_TEXT is updated to the new
version string, and include/config/cc/version/text.h is touched.

In the next rebuild, Make rebuilds every files since the timestamp of
include/config/cc/version/text.h is newer than that of target.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Kconfig                 |  2 --
 include/linux/kconfig.h |  9 +++++++++
 init/Kconfig            | 12 ++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/Kconfig b/Kconfig
index e10b3ee084d4..745bc773f567 100644
--- a/Kconfig
+++ b/Kconfig
@@ -5,8 +5,6 @@
 #
 mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration"
 
-comment "Compiler: $(CC_VERSION_TEXT)"
-
 source "scripts/Kconfig.include"
 
 source "init/Kconfig"
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index cc8fa109cfa3..406b8a2521b5 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -2,6 +2,15 @@
 #ifndef __LINUX_KCONFIG_H
 #define __LINUX_KCONFIG_H
 
+/*
+ * Do not remove this comment block. This contains "CONFIG_CC_VERSION_TEXT"
+ * to ensure the full rebuild when the compiler is updated.
+ *
+ * fixdep parses this header, which is included by every kernel source file,
+ * and adds include/config/cc/version/text.h to the dependency in .*.cmd files.
+ * When the compiler is updated, syncconfig touches it so every file is rebuilt.
+ */
+
 #include <generated/autoconf.h>
 
 #ifdef CONFIG_CPU_BIG_ENDIAN
diff --git a/init/Kconfig b/init/Kconfig
index 9e22ee8fbd75..d3d153815d88 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -8,6 +8,18 @@ config DEFCONFIG_LIST
 	default "/boot/config-$(shell,uname -r)"
 	default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"
 
+config CC_VERSION_TEXT
+	string
+	default "$(CC_VERSION_TEXT)"
+	help
+	  There two purposes for this entry:
+
+	  1. Reference the environment variable, CC_VERSION_TEXT, so Kconfig
+	     is invoked if the compiler is updated.
+
+	  2. Touch include/config/cc/version/text.h to force the full rebuild
+	     if the compiler is updated. See comment in include/linux/kconfig.h
+
 config CC_IS_GCC
 	def_bool $(success,$(CC) --version | head -n 1 | grep -q gcc)
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH 1/2] kbuild: ensure full rebuild when the compiler is updated
@ 2020-04-21 12:32 Masahiro Yamada
  0 siblings, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2020-04-21 12:32 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, linux-kernel

Commit 21c54b774744 ("kconfig: show compiler version text in the top
comment") added the environment variable, CC_VERSION_TEXT in the comment
of the top Kconfig file. It can detect the compiler update, and invoke
the syncconfig because all environment variables referenced in Kconfig
files are recorded in include/config/auto.conf.cmd

This commit makes it a CONFIG option in order to ensure the full rebuild
when the compiler is updated.

This works like as follows:

include/config/kconfig.h contains "CONFIG_CC_VERSION_TEXT" in the comment
block.

The top Makefile specifies "-include $(srctree)/include/linux/kconfig.h"
to guarantee it is included from all kernel source files.

fixdep parses every source file and all headers included from it,
searching for words prefixed with "CONFIG_". Then, fixdep finds
CONFIG_CC_VERSION_TEXT in include/config/kconfig.h and adds
include/config/cc/version/text.h into every .*.cmd file.

When the compiler is updated, syncconfig is invoked since the environment
variable is referenced. CONFIG_CC_VERSION_TEXT is updated to the new
version string, and include/config/cc/version/text.h is touched.

In the next rebuild, Make rebuilds every files since the timestamp of
include/config/cc/version/text.h is newer than that of target.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Kconfig                 |  2 --
 include/linux/kconfig.h |  9 +++++++++
 init/Kconfig            | 12 ++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/Kconfig b/Kconfig
index e10b3ee084d4..745bc773f567 100644
--- a/Kconfig
+++ b/Kconfig
@@ -5,8 +5,6 @@
 #
 mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration"
 
-comment "Compiler: $(CC_VERSION_TEXT)"
-
 source "scripts/Kconfig.include"
 
 source "init/Kconfig"
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index cc8fa109cfa3..406b8a2521b5 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -2,6 +2,15 @@
 #ifndef __LINUX_KCONFIG_H
 #define __LINUX_KCONFIG_H
 
+/*
+ * Do not remove this comment block. This contains "CONFIG_CC_VERSION_TEXT"
+ * to ensure the full rebuild when the compiler is updated.
+ *
+ * fixdep parses this header, which is included by every kernel source file,
+ * and adds include/config/cc/version/text.h to the dependency in .*.cmd files.
+ * When the compiler is updated, syncconfig touches it so every file is rebuilt.
+ */
+
 #include <generated/autoconf.h>
 
 #ifdef CONFIG_CPU_BIG_ENDIAN
diff --git a/init/Kconfig b/init/Kconfig
index 9e22ee8fbd75..d3d153815d88 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -8,6 +8,18 @@ config DEFCONFIG_LIST
 	default "/boot/config-$(shell,uname -r)"
 	default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"
 
+config CC_VERSION_TEXT
+	string
+	default "$(CC_VERSION_TEXT)"
+	help
+	  There two purposes for this entry:
+
+	  1. Reference the environment variable, CC_VERSION_TEXT, so Kconfig
+	     is invoked if the compiler is updated.
+
+	  2. Touch include/config/cc/version/text.h to force the full rebuild
+	     if the compiler is updated. See comment in include/linux/kconfig.h
+
 config CC_IS_GCC
 	def_bool $(success,$(CC) --version | head -n 1 | grep -q gcc)
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-21 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21 12:48 [PATCH 1/2] kbuild: ensure full rebuild when the compiler is updated Masahiro Yamada
2020-04-21 12:48 ` [PATCH 2/2] kbuild: use -MMD instead of -MD to exclude system headers from dependency Masahiro Yamada
  -- strict thread matches above, loose matches on Subject: below --
2020-04-21 12:32 [PATCH 1/2] kbuild: ensure full rebuild when the compiler is updated Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).