Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 1 | From: Sergey Senozhatsky <senozhatsky@chromium.org> |
| 2 | To: Masahiro Yamada <masahiroy@kernel.org> |
| 3 | Cc: 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> |
| 7 | Subject: [PATCH] kconfig: WERROR unmet symbol dependency |
| 8 | Date: Wed, 22 Nov 2023 12:47:45 +0900 |
| 9 | Message-ID: <20231122034753.1446513-1-senozhatsky@chromium.org> |
| 10 | MIME-Version: 1.0 |
| 11 | Content-Transfer-Encoding: 8bit |
| 12 | List-ID: <linux-kernel.vger.kernel.org> |
| 13 | X-Mailing-List: linux-kernel@vger.kernel.org |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 14 | |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 15 | When KCONFIG_WERROR env variable is set treat unmet direct |
| 16 | symbol dependency as a terminal condition (error). |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 17 | |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 18 | Suggested-by: Stefan Reinauer <reinauer@google.com> |
| 19 | Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 20 | --- |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 21 | scripts/kconfig/symbol.c | 9 ++++++++- |
| 22 | 1 file changed, 8 insertions(+), 1 deletion(-) |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 23 | |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 24 | Index: kconfig/symbol.c |
| 25 | =================================================================== |
| 26 | --- kconfig.orig/symbol.c |
| 27 | +++ kconfig/symbol.c |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 28 | @@ -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 Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 37 | " Selected by [m]:\n"); |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 38 | |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 39 | fputs(str_get(&gs), stderr); |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 40 | + sym_warnings++; |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 41 | } |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 42 | |
Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 43 | void sym_calc_value(struct symbol *sym) |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 44 | { |
| 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); |