util/kconfig: Uprev to Linux 6.1's kconfig

This also cleans up our patch queue.

TEST=`util/abuild/abuild -C` output (config.h and config.build) remains
the same

Change-Id: I79159130ba3515ede59e9fb9fbf087e2ed76257a
Signed-off-by: Patrick Georgi <patrick@coreboot.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/79203
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
This commit is contained in:
Patrick Georgi 2023-11-20 17:58:40 +01:00
parent f47e85fc72
commit 7f93aa4919
12 changed files with 94 additions and 70 deletions

View File

@ -553,7 +553,7 @@ static int conf_choice(struct menu *menu)
print_help(child);
continue;
}
sym_set_choice_value(sym, child->sym);
sym_set_tristate_value(child->sym, yes);
for (child = child->list; child; child = child->next) {
indent += 2;
conf(child);

View File

@ -230,6 +230,13 @@ static const char *conf_get_autoheader_name(void)
return name ? name : "include/generated/autoconf.h";
}
static const char *conf_get_rustccfg_name(void)
{
char *name = getenv("KCONFIG_RUSTCCFG");
return name ? name : "include/generated/rustc_cfg";
}
static const char *conf_get_autobase_name(void)
{
char *name = getenv("KCONFIG_SPLITCONFIG");
@ -632,6 +639,9 @@ static const struct comment_style comment_style_c = {
static void conf_write_heading(FILE *fp, const struct comment_style *cs)
{
if (!cs)
return;
fprintf(fp, "%s\n", cs->prefix);
fprintf(fp, "%s Automatically generated file; DO NOT EDIT.\n",
@ -787,6 +797,65 @@ static void print_symbol_for_c(FILE *fp, struct symbol *sym)
free(escaped);
}
static void print_symbol_for_rustccfg(FILE *fp, struct symbol *sym)
{
const char *val;
const char *val_prefix = "";
char *val_prefixed = NULL;
size_t val_prefixed_len;
char *escaped = NULL;
if (sym->type == S_UNKNOWN)
return;
val = sym_get_string_value(sym);
switch (sym->type) {
case S_BOOLEAN:
case S_TRISTATE:
/*
* We do not care about disabled ones, i.e. no need for
* what otherwise are "comments" in other printers.
*/
if (*val == 'n')
return;
/*
* To have similar functionality to the C macro `IS_ENABLED()`
* we provide an empty `--cfg CONFIG_X` here in both `y`
* and `m` cases.
*
* Then, the common `fprintf()` below will also give us
* a `--cfg CONFIG_X="y"` or `--cfg CONFIG_X="m"`, which can
* be used as the equivalent of `IS_BUILTIN()`/`IS_MODULE()`.
*/
fprintf(fp, "--cfg=%s%s\n", CONFIG_, sym->name);
break;
case S_HEX:
if (val[0] != '0' || (val[1] != 'x' && val[1] != 'X'))
val_prefix = "0x";
break;
default:
break;
}
if (strlen(val_prefix) > 0) {
val_prefixed_len = strlen(val) + strlen(val_prefix) + 1;
val_prefixed = xmalloc(val_prefixed_len);
snprintf(val_prefixed, val_prefixed_len, "%s%s", val_prefix, val);
val = val_prefixed;
}
/* All values get escaped: the `--cfg` option only takes strings */
escaped = escape_string_value(val);
val = escaped;
fprintf(fp, "--cfg=%s%s=%s\n", CONFIG_, sym->name, val);
free(escaped);
free(val_prefixed);
}
/*
* Write out a minimal config.
* All values that has default values are skipped as this is redundant.
@ -1175,6 +1244,12 @@ int conf_write_autoconf(int overwrite)
if (ret)
return ret;
ret = __conf_write_autoconf(conf_get_rustccfg_name(),
print_symbol_for_rustccfg,
NULL);
if (ret)
return ret;
/*
* Create include/config/auto.conf. This must be the last step because
* Kbuild has a dependency on auto.conf and this marks the successful

View File

@ -127,11 +127,6 @@ static inline struct symbol *sym_get_choice_value(struct symbol *sym)
return (struct symbol *)sym->curr.val;
}
static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
{
return sym_set_tristate_value(chval, yes);
}
static inline bool sym_is_choice(struct symbol *sym)
{
return sym->flags & SYMBOL_CHOICE ? true : false;

View File

@ -722,8 +722,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
if (!expr_eq(prop->menu->dep, prop->visible.expr))
get_dep_str(r, prop->visible.expr, " Visible if: ");
menu = prop->menu->parent;
for (i = 0; menu && i < 8; menu = menu->parent) {
menu = prop->menu;
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
bool accessible = menu_is_visible(menu);
submenu[i++] = menu;
@ -733,16 +733,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
if (head && location) {
jump = xmalloc(sizeof(struct jump_key));
if (menu_is_visible(prop->menu)) {
/*
* There is not enough room to put the hint at the
* beginning of the "Prompt" line. Put the hint on the
* last "Location" line even when it would belong on
* the former.
*/
jump->target = prop->menu;
} else
jump->target = location;
jump->target = location;
if (list_empty(head))
jump->index = 0;
@ -758,13 +749,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
menu = submenu[i];
if (jump && menu == location)
jump->offset = strlen(r->s);
if (menu == &rootmenu)
/* The real rootmenu prompt is ugly */
str_printf(r, "%*cMain menu", j, ' ');
else
str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
if (menu->sym) {
str_printf(r, " (%s [=%s])", menu->sym->name ?
menu->sym->name : "<choice>",

View File

@ -19,7 +19,7 @@ Index: kconfig/confdata.c
===================================================================
--- kconfig.orig/confdata.c
+++ kconfig/confdata.c
@@ -430,6 +430,7 @@ load:
@@ -437,6 +437,7 @@ load:
if (def == S_DEF_USER) {
sym = sym_find(line + 2 + strlen(CONFIG_));
if (!sym) {
@ -27,7 +27,7 @@ Index: kconfig/confdata.c
conf_set_changed(true);
continue;
}
@@ -512,6 +513,13 @@ load:
@@ -519,6 +520,13 @@ load:
}
free(line);
fclose(in);

View File

@ -40,7 +40,7 @@ Index: kconfig/confdata.c
static void conf_default_message_callback(const char *s)
{
printf("#\n# ");
@@ -440,7 +450,7 @@ load:
@@ -447,7 +457,7 @@ load:
sym->type = S_BOOLEAN;
}
if (sym->flags & def_flags) {
@ -49,7 +49,7 @@ Index: kconfig/confdata.c
}
switch (sym->type) {
case S_BOOLEAN:
@@ -479,7 +489,7 @@ load:
@@ -486,7 +496,7 @@ load:
}
if (sym->flags & def_flags) {
@ -58,7 +58,7 @@ Index: kconfig/confdata.c
}
if (conf_set_sym_val(sym, def, def_flags, p))
continue;
@@ -504,7 +514,7 @@ load:
@@ -511,7 +521,7 @@ load:
break;
case yes:
if (cs->def[def].tri != no)

View File

@ -24,7 +24,7 @@ Index: kconfig/confdata.c
===================================================================
--- kconfig.orig/confdata.c
+++ kconfig/confdata.c
@@ -440,7 +440,9 @@ load:
@@ -447,7 +447,9 @@ load:
if (def == S_DEF_USER) {
sym = sym_find(line + 2 + strlen(CONFIG_));
if (!sym) {

View File

@ -62,7 +62,7 @@ Index: kconfig/confdata.c
===================================================================
--- kconfig.orig/confdata.c
+++ kconfig/confdata.c
@@ -530,11 +530,7 @@ load:
@@ -537,11 +537,7 @@ load:
free(line);
fclose(in);

View File

@ -14,7 +14,7 @@ Index: kconfig/confdata.c
===================================================================
--- kconfig.orig/confdata.c
+++ kconfig/confdata.c
@@ -715,7 +715,12 @@ static void print_symbol_for_dotconfig(F
@@ -725,7 +725,12 @@ static void print_symbol_for_dotconfig(F
static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym)
{
@ -28,7 +28,7 @@ Index: kconfig/confdata.c
}
void print_symbol_for_listconfig(struct symbol *sym)
@@ -740,6 +745,10 @@ static void print_symbol_for_c(FILE *fp,
@@ -750,6 +755,10 @@ static void print_symbol_for_c(FILE *fp,
case S_TRISTATE:
switch (*val) {
case 'n':
@ -39,7 +39,7 @@ Index: kconfig/confdata.c
return;
case 'm':
sym_suffix = "_MODULE";
@@ -751,6 +760,12 @@ static void print_symbol_for_c(FILE *fp,
@@ -761,6 +770,12 @@ static void print_symbol_for_c(FILE *fp,
case S_HEX:
if (val[0] != '0' || (val[1] != 'x' && val[1] != 'X'))
val_prefix = "0x";
@ -52,7 +52,7 @@ Index: kconfig/confdata.c
break;
case S_STRING:
escaped = escape_string_value(val);
@@ -1108,8 +1123,9 @@ static int __conf_write_autoconf(const c
@@ -1177,8 +1192,9 @@ static int __conf_write_autoconf(const c
conf_write_heading(file, comment_style);

View File

@ -21,8 +21,8 @@ Index: kconfig/confdata.c
===================================================================
--- kconfig.orig/confdata.c
+++ kconfig/confdata.c
@@ -230,6 +230,13 @@ static const char *conf_get_autoheader_n
return name ? name : "include/generated/autoconf.h";
@@ -237,6 +237,13 @@ static const char *conf_get_rustccfg_nam
return name ? name : "include/generated/rustc_cfg";
}
+static const char *conf_get_autobase_name(void)
@ -35,7 +35,7 @@ Index: kconfig/confdata.c
static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
{
char *p2;
@@ -1024,19 +1031,19 @@ static int conf_write_autoconf_cmd(const
@@ -1093,19 +1100,19 @@ static int conf_write_autoconf_cmd(const
static int conf_touch_deps(void)
{

View File

@ -1,30 +0,0 @@
From 48ad5c23680c81614663e09c6586ebeb26bf8c18 Mon Sep 17 00:00:00 2001
From: Richard Marko <srk@48.io>
Date: Mon, 16 Oct 2023 15:26:33 +0200
Subject: [PATCH] util/kconfig: chmod +w before savedefconfig
This prevents a headscratcher when .config in root doesn't have a write
permission bit set which causes a build failure of savedefconfig
not able to write to copied file, for example
*** Error while saving defconfig to:
build/mainboard/emulation/qemu-i440fx/cbfs-file.eU5E0t.out.tmp2
Change-Id: I2e7d35c9f6e8add3e7438d163850bc5fda5a99b2
Signed-off-by: Richard Marko <srk@48.io>
---
util/kconfig/Makefile.inc | 1 +
1 file changed, 1 insertion(+)
Index: kconfig/Makefile.inc
===================================================================
--- kconfig.orig/Makefile.inc
+++ kconfig/Makefile.inc
@@ -34,6 +34,7 @@ oldconfig: KCONFIG_STRICT=
savedefconfig: $(objk)/conf
cp $(DOTCONFIG) $(DEFCONFIG)
+ chmod +w $(DEFCONFIG)
$< --savedefconfig=$(DEFCONFIG) $(KBUILD_KCONFIG)
FORCE:

View File

@ -10,4 +10,3 @@
0010-reenable-source-in-choice.patch
0013-util-kconfig-detect-ncurses-on-FreeBSD.patch
0014-util-kconfig-Move-Kconfig-deps-back-into-build-confi.patch
0015-util-kconfig-chmod-w-before-savedefconfig.patch