]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.34/kbuild-invoke-syncconfig-if-include-config-auto.conf.patch
Linux 4.19.34
[thirdparty/kernel/stable-queue.git] / releases / 4.19.34 / kbuild-invoke-syncconfig-if-include-config-auto.conf.patch
1 From c3d2bf390f739423a7022f93b3b30c3d3e9f6308 Mon Sep 17 00:00:00 2001
2 From: Masahiro Yamada <yamada.masahiro@socionext.com>
3 Date: Fri, 22 Feb 2019 16:40:10 +0900
4 Subject: kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing
5
6 [ Upstream commit 9390dff66a52d1a60c6e517d8fa6cdbdffc83cb1 ]
7
8 If include/config/auto.conf.cmd is lost for some reasons, it is not
9 self-healing, so the top Makefile misses to run syncconfig.
10 Move include/config/auto.conf.cmd to the target side.
11
12 I used a pattern rule instead of a normal rule here although it is
13 a bit gross.
14
15 If the rule were written with a normal rule like this,
16
17 include/config/auto.conf \
18 include/config/auto.conf.cmd \
19 include/config/tristate.conf: $(KCONFIG_CONFIG)
20 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
21
22 ... syncconfig would be executed per target.
23
24 Using a pattern rule makes sure that syncconfig is executed just once
25 because Make assumes the recipe will create all of the targets.
26
27 Here is a quote from the GNU Make manual [1]:
28
29 "Pattern rules may have more than one target. Unlike normal rules,
30 this does not act as many different rules with the same prerequisites
31 and recipe. If a pattern rule has multiple targets, make knows that
32 the rule's recipe is responsible for making all of the targets. The
33 recipe is executed only once to make all the targets. When searching
34 for a pattern rule to match a target, the target patterns of a rule
35 other than the one that matches the target in need of a rule are
36 incidental: make worries only about giving a recipe and prerequisites
37 to the file presently in question. However, when this file's recipe is
38 run, the other targets are marked as having been updated themselves."
39
40 [1]: https://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html
41
42 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
43 Signed-off-by: Sasha Levin <sashal@kernel.org>
44 ---
45 Makefile | 7 +++++--
46 1 file changed, 5 insertions(+), 2 deletions(-)
47
48 diff --git a/Makefile b/Makefile
49 index 8de5fab711d8..f1a5d7deaf5f 100644
50 --- a/Makefile
51 +++ b/Makefile
52 @@ -626,12 +626,15 @@ ifeq ($(may-sync-config),1)
53 -include include/config/auto.conf.cmd
54
55 # To avoid any implicit rule to kick in, define an empty command
56 -$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
57 +$(KCONFIG_CONFIG): ;
58
59 # The actual configuration files used during the build are stored in
60 # include/generated/ and include/config/. Update them if .config is newer than
61 # include/config/auto.conf (which mirrors .config).
62 -include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
63 +#
64 +# This exploits the 'multi-target pattern rule' trick.
65 +# The syncconfig should be executed only once to make all the targets.
66 +%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
67 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
68 else
69 # External modules and some install targets need include/generated/autoconf.h
70 --
71 2.19.1
72