Commit b170290c authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'kconfig-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kconfig updates from Masahiro Yamada:

 - allow only 'config', 'comment', 'if' statements inside 'choice' since
   the other statements are not sensible inside 'choice' and should be
   grammatical error

 - support LMC_KEEP env variable for 'make local{yes,mod}config' to
   preserve some CONFIG options

 - deprecate 'make kvmconfig' and 'make xenconfig' in favor of
   'make kvm_guest.config' and 'make xen.config'

 - code cleanups

* tag 'kconfig-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kconfig: announce removal of 'kvmconfig' and 'xenconfig' shorthands
  streamline_config.pl: add LMC_KEEP to preserve some kconfigs
  kconfig: allow only 'config', 'comment', and 'if' inside 'choice'
  kconfig: tests: remove randconfig test for choice in choice
  kconfig: do not assign a variable in the return statement
  kconfig: do not use OR-assignment for zero-cleared structure
parents cff11abe bcfefb61
...@@ -209,15 +209,22 @@ Configuring the kernel ...@@ -209,15 +209,22 @@ Configuring the kernel
store the lsmod of that machine into a file store the lsmod of that machine into a file
and pass it in as a LSMOD parameter. and pass it in as a LSMOD parameter.
Also, you can preserve modules in certain folders
or kconfig files by specifying their paths in
parameter LMC_KEEP.
target$ lsmod > /tmp/mylsmod target$ lsmod > /tmp/mylsmod
target$ scp /tmp/mylsmod host:/tmp target$ scp /tmp/mylsmod host:/tmp
host$ make LSMOD=/tmp/mylsmod localmodconfig host$ make LSMOD=/tmp/mylsmod \
LMC_KEEP="drivers/usb:drivers/gpu:fs" \
localmodconfig
The above also works when cross compiling. The above also works when cross compiling.
"make localyesconfig" Similar to localmodconfig, except it will convert "make localyesconfig" Similar to localmodconfig, except it will convert
all module options to built in (=y) options. all module options to built in (=y) options. You can
also preserve modules by LMC_KEEP.
"make kvmconfig" Enable additional options for kvm guest kernel support. "make kvmconfig" Enable additional options for kvm guest kernel support.
......
...@@ -96,11 +96,13 @@ configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/c ...@@ -96,11 +96,13 @@ configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/c
PHONY += kvmconfig PHONY += kvmconfig
kvmconfig: kvm_guest.config kvmconfig: kvm_guest.config
@: @echo >&2 "WARNING: 'make $@' will be removed after Linux 5.10"
@echo >&2 " Please use 'make $<' instead."
PHONY += xenconfig PHONY += xenconfig
xenconfig: xen.config xenconfig: xen.config
@: @echo >&2 "WARNING: 'make $@' will be removed after Linux 5.10"
@echo >&2 " Please use 'make $<' instead."
PHONY += tinyconfig PHONY += tinyconfig
tinyconfig: tinyconfig:
...@@ -123,7 +125,9 @@ help: ...@@ -123,7 +125,9 @@ help:
@echo ' gconfig - Update current config utilising a GTK+ based front-end' @echo ' gconfig - Update current config utilising a GTK+ based front-end'
@echo ' oldconfig - Update current config utilising a provided .config as base' @echo ' oldconfig - Update current config utilising a provided .config as base'
@echo ' localmodconfig - Update current config disabling modules not loaded' @echo ' localmodconfig - Update current config disabling modules not loaded'
@echo ' except those preserved by LMC_KEEP environment variable'
@echo ' localyesconfig - Update current config converting local mods to core' @echo ' localyesconfig - Update current config converting local mods to core'
@echo ' except those preserved by LMC_KEEP environment variable'
@echo ' defconfig - New config with default from ARCH supplied defconfig' @echo ' defconfig - New config with default from ARCH supplied defconfig'
@echo ' savedefconfig - Save current config as ./defconfig (minimal config)' @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
@echo ' allnoconfig - New config where all options are answered with no' @echo ' allnoconfig - New config where all options are answered with no'
...@@ -137,9 +141,6 @@ help: ...@@ -137,9 +141,6 @@ help:
@echo ' helpnewconfig - List new options and help text' @echo ' helpnewconfig - List new options and help text'
@echo ' olddefconfig - Same as oldconfig but sets new symbols to their' @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
@echo ' default value without prompting' @echo ' default value without prompting'
@echo ' kvmconfig - Enable additional options for kvm guest kernel support'
@echo ' xenconfig - Enable additional options for xen dom0 and guest kernel'
@echo ' support'
@echo ' tinyconfig - Configure the tiniest possible kernel' @echo ' tinyconfig - Configure the tiniest possible kernel'
@echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
......
...@@ -65,7 +65,8 @@ void menu_add_entry(struct symbol *sym) ...@@ -65,7 +65,8 @@ void menu_add_entry(struct symbol *sym)
struct menu *menu_add_menu(void) struct menu *menu_add_menu(void)
{ {
last_entry_ptr = &current_entry->list; last_entry_ptr = &current_entry->list;
return current_menu = current_entry; current_menu = current_entry;
return current_menu;
} }
void menu_end_menu(void) void menu_end_menu(void)
......
...@@ -119,20 +119,24 @@ mainmenu_stmt: T_MAINMENU T_WORD_QUOTE T_EOL ...@@ -119,20 +119,24 @@ mainmenu_stmt: T_MAINMENU T_WORD_QUOTE T_EOL
stmt_list: stmt_list:
/* empty */ /* empty */
| stmt_list common_stmt | stmt_list assignment_stmt
| stmt_list choice_stmt | stmt_list choice_stmt
| stmt_list comment_stmt
| stmt_list config_stmt
| stmt_list if_stmt
| stmt_list menu_stmt | stmt_list menu_stmt
| stmt_list menuconfig_stmt
| stmt_list source_stmt
| stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
| stmt_list error T_EOL { zconf_error("invalid statement"); } | stmt_list error T_EOL { zconf_error("invalid statement"); }
; ;
common_stmt: stmt_list_in_choice:
if_stmt /* empty */
| comment_stmt | stmt_list_in_choice comment_stmt
| config_stmt | stmt_list_in_choice config_stmt
| menuconfig_stmt | stmt_list_in_choice if_stmt_in_choice
| source_stmt | stmt_list_in_choice error T_EOL { zconf_error("invalid statement"); }
| assignment_stmt
; ;
/* config/menuconfig entry */ /* config/menuconfig entry */
...@@ -254,7 +258,7 @@ choice_end: end ...@@ -254,7 +258,7 @@ choice_end: end
} }
}; };
choice_stmt: choice_entry choice_block choice_end choice_stmt: choice_entry stmt_list_in_choice choice_end
; ;
choice_option_list: choice_option_list:
...@@ -305,11 +309,6 @@ default: ...@@ -305,11 +309,6 @@ default:
| T_DEF_BOOL { $$ = S_BOOLEAN; } | T_DEF_BOOL { $$ = S_BOOLEAN; }
| T_DEF_TRISTATE { $$ = S_TRISTATE; } | T_DEF_TRISTATE { $$ = S_TRISTATE; }
choice_block:
/* empty */
| choice_block common_stmt
;
/* if entry */ /* if entry */
if_entry: T_IF expr T_EOL if_entry: T_IF expr T_EOL
...@@ -331,6 +330,9 @@ if_end: end ...@@ -331,6 +330,9 @@ if_end: end
if_stmt: if_entry stmt_list if_end if_stmt: if_entry stmt_list if_end
; ;
if_stmt_in_choice: if_entry stmt_list_in_choice if_end
;
/* menu entry */ /* menu entry */
menu: T_MENU T_WORD_QUOTE T_EOL menu: T_MENU T_WORD_QUOTE T_EOL
......
...@@ -143,6 +143,7 @@ my %depends; ...@@ -143,6 +143,7 @@ my %depends;
my %selects; my %selects;
my %prompts; my %prompts;
my %objects; my %objects;
my %config2kfile;
my $var; my $var;
my $iflevel = 0; my $iflevel = 0;
my @ifdeps; my @ifdeps;
...@@ -201,6 +202,7 @@ sub read_kconfig { ...@@ -201,6 +202,7 @@ sub read_kconfig {
if (/^\s*(menu)?config\s+(\S+)\s*$/) { if (/^\s*(menu)?config\s+(\S+)\s*$/) {
$state = "NEW"; $state = "NEW";
$config = $2; $config = $2;
$config2kfile{"CONFIG_$config"} = $kconfig;
# Add depends for 'if' nesting # Add depends for 'if' nesting
for (my $i = 0; $i < $iflevel; $i++) { for (my $i = 0; $i < $iflevel; $i++) {
...@@ -591,6 +593,20 @@ while ($repeat) { ...@@ -591,6 +593,20 @@ while ($repeat) {
} }
my %setconfigs; my %setconfigs;
my @preserved_kconfigs = split(/:/,$ENV{LMC_KEEP});
sub in_preserved_kconfigs {
my $kconfig = $config2kfile{$_[0]};
if (!defined($kconfig)) {
return 0;
}
foreach my $excl (@preserved_kconfigs) {
if($kconfig =~ /^$excl/) {
return 1;
}
}
return 0;
}
# Finally, read the .config file and turn off any module enabled that # Finally, read the .config file and turn off any module enabled that
# we could not find a reason to keep enabled. # we could not find a reason to keep enabled.
...@@ -644,6 +660,11 @@ foreach my $line (@config_file) { ...@@ -644,6 +660,11 @@ foreach my $line (@config_file) {
} }
if (/^(CONFIG.*)=(m|y)/) { if (/^(CONFIG.*)=(m|y)/) {
if (in_preserved_kconfigs($1)) {
dprint "Preserve config $1";
print;
next;
}
if (defined($configs{$1})) { if (defined($configs{$1})) {
if ($localyesconfig) { if ($localyesconfig) {
$setconfigs{$1} = 'y'; $setconfigs{$1} = 'y';
......
...@@ -831,7 +831,7 @@ struct symbol *sym_lookup(const char *name, int flags) ...@@ -831,7 +831,7 @@ struct symbol *sym_lookup(const char *name, int flags)
memset(symbol, 0, sizeof(*symbol)); memset(symbol, 0, sizeof(*symbol));
symbol->name = new_name; symbol->name = new_name;
symbol->type = S_UNKNOWN; symbol->type = S_UNKNOWN;
symbol->flags |= flags; symbol->flags = flags;
symbol->next = symbol_hash[hash]; symbol->next = symbol_hash[hash];
symbol_hash[hash] = symbol; symbol_hash[hash] = symbol;
......
# SPDX-License-Identifier: GPL-2.0
choice
prompt "choice"
config A
bool "A"
config B
bool "B"
if B
choice
prompt "sub choice"
config C
bool "C"
config D
bool "D"
if D
choice
prompt "subsub choice"
config E
bool "E"
endchoice
endif # D
endchoice
endif # B
endchoice
# SPDX-License-Identifier: GPL-2.0
"""
Set random values recursively in nested choices.
Kconfig can create a choice-in-choice structure by using 'if' statement.
randconfig should correctly set random choice values.
Related Linux commit: 3b9a19e08960e5cdad5253998637653e592a3c29
"""
def test(conf):
for i in range(20):
assert conf.randconfig() == 0
assert (conf.config_contains('expected_stdout0') or
conf.config_contains('expected_stdout1') or
conf.config_contains('expected_stdout2'))
# CONFIG_A is not set
CONFIG_B=y
CONFIG_C=y
# CONFIG_D is not set
# CONFIG_A is not set
CONFIG_B=y
# CONFIG_C is not set
CONFIG_D=y
CONFIG_E=y
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment