Skip to content

Commit 8b59cd8

Browse files
committed
kbuild: ensure full rebuild when the compiler is updated
Commit 21c54b7 ("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 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 because init/Kconfig contains the reference to the environment variable CC_VERTION_TEXT. 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 will rebuild every files since the timestamp of include/config/cc/version/text.h is newer than that of target. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent e33ae3e commit 8b59cd8

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Kconfig

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#
66
mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration"
77

8-
comment "Compiler: $(CC_VERSION_TEXT)"
9-
108
source "scripts/Kconfig.include"
119

1210
source "init/Kconfig"

include/linux/kconfig.h

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#ifndef __LINUX_KCONFIG_H
33
#define __LINUX_KCONFIG_H
44

5+
/* CONFIG_CC_VERSION_TEXT (Do not delete this comment. See help in Kconfig) */
6+
57
#include <generated/autoconf.h>
68

79
#ifdef CONFIG_CPU_BIG_ENDIAN

init/Kconfig

+17
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ config DEFCONFIG_LIST
88
default "/boot/config-$(shell,uname -r)"
99
default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"
1010

11+
config CC_VERSION_TEXT
12+
string
13+
default "$(CC_VERSION_TEXT)"
14+
help
15+
This is used in unclear ways:
16+
17+
- Re-run Kconfig when the compiler is updated
18+
The 'default' property references the environment variable,
19+
CC_VERSION_TEXT so it is recorded in include/config/auto.conf.cmd.
20+
When the compiler is updated, Kconfig will be invoked.
21+
22+
- Ensure full rebuild when the compier is updated
23+
include/linux/kconfig.h contains this option in the comment line so
24+
fixdep adds include/config/cc/version/text.h into the auto-generated
25+
dependency. When the compiler is updated, syncconfig will touch it
26+
and then every file will be rebuilt.
27+
1128
config CC_IS_GCC
1229
def_bool $(success,echo "$(CC_VERSION_TEXT)" | grep -q gcc)
1330

0 commit comments

Comments
 (0)