blob: f98729e85bb0c1f759a382f409e2410d92a28731 [file] [log] [blame]
Patrick Georgi0eab62b2023-11-20 19:49:29 +01001From: Sergey Senozhatsky <senozhatsky@chromium.org>
2To: Masahiro Yamada <masahiroy@kernel.org>
3Cc: Patrick Georgi <pgeorgi@google.com>, linux-kbuild@vger.kernel.org,
4 linux-kernel@vger.kernel.org,
5 Sergey Senozhatsky <senozhatsky@chromium.org>,
6 Stefan Reinauer <reinauer@google.com>
7Subject: [PATCH] kconfig: WERROR unmet symbol dependency
8Date: Wed, 22 Nov 2023 12:47:45 +0900
9Message-ID: <20231122034753.1446513-1-senozhatsky@chromium.org>
10MIME-Version: 1.0
11Content-Transfer-Encoding: 8bit
12List-ID: <linux-kernel.vger.kernel.org>
13X-Mailing-List: linux-kernel@vger.kernel.org
Patrick Georgi53ea1d42019-11-22 16:55:58 +010014
Patrick Georgi0eab62b2023-11-20 19:49:29 +010015When KCONFIG_WERROR env variable is set treat unmet direct
16symbol dependency as a terminal condition (error).
Patrick Georgi53ea1d42019-11-22 16:55:58 +010017
Patrick Georgi0eab62b2023-11-20 19:49:29 +010018Suggested-by: Stefan Reinauer <reinauer@google.com>
19Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Patrick Georgi53ea1d42019-11-22 16:55:58 +010020---
Patrick Georgi0eab62b2023-11-20 19:49:29 +010021 scripts/kconfig/symbol.c | 9 ++++++++-
22 1 file changed, 8 insertions(+), 1 deletion(-)
Patrick Georgi53ea1d42019-11-22 16:55:58 +010023
Patrick Georgi53ea1d42019-11-22 16:55:58 +010024Index: kconfig/symbol.c
25===================================================================
26--- kconfig.orig/symbol.c
27+++ kconfig/symbol.c
Patrick Georgi0eab62b2023-11-20 19:49:29 +010028@@ -37,6 +37,7 @@ static struct symbol symbol_empty = {
29
30 struct symbol *modules_sym;
31 static tristate modules_val;
32+static int sym_warnings;
33
34 enum symbol_type sym_get_type(struct symbol *sym)
35 {
36@@ -319,12 +320,14 @@ static void sym_warn_unmet_dep(struct sy
Patrick Georgi53ea1d42019-11-22 16:55:58 +010037 " Selected by [m]:\n");
Patrick Georgi0eab62b2023-11-20 19:49:29 +010038
Patrick Georgi53ea1d42019-11-22 16:55:58 +010039 fputs(str_get(&gs), stderr);
Patrick Georgi0eab62b2023-11-20 19:49:29 +010040+ sym_warnings++;
Patrick Georgi53ea1d42019-11-22 16:55:58 +010041 }
Patrick Georgi0eab62b2023-11-20 19:49:29 +010042
Patrick Georgi53ea1d42019-11-22 16:55:58 +010043 void sym_calc_value(struct symbol *sym)
Patrick Georgi0eab62b2023-11-20 19:49:29 +010044 {
45 struct symbol_value newval, oldval;
46 struct property *prop;
47+ const char *werror;
48 struct expr *e;
49
50 if (!sym)
51@@ -340,8 +343,9 @@ void sym_calc_value(struct symbol *sym)
52 sym_calc_value(prop_get_symbol(prop));
53 }
54
55+ werror = getenv("KCONFIG_WERROR");
56+ sym_warnings = 0;
57 sym->flags |= SYMBOL_VALID;
58-
59 oldval = sym->curr;
60
61 switch (sym->type) {
62@@ -432,6 +436,9 @@ void sym_calc_value(struct symbol *sym)
63 ;
64 }
65
66+ if (sym_warnings && werror)
67+ exit(1);
68+
69 sym->curr = newval;
70 if (sym_is_choice(sym) && newval.tri == yes)
71 sym->curr.val = sym_calc_choice(sym);