Skip to content

Commit 147a89b

Browse files
committed
Merge tag 'kconfig-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kconfig updates from Masahiro Yamada: - improve checkpatch for more precise Kconfig code checking - clarify effective selects by grouping reverse dependencies in help - do not write out '# CONFIG_FOO is not set' from invisible symbols - make oldconfig as silent as it should be - rename 'silentoldconfig' to 'syncconfig' - add unit-test framework and several test cases - warn unmet dependency of tristate symbols - make unmet dependency warnings readable, removing false positives - improve recursive include detection - use yylineno to simplify the line number tracking - misc cleanups * tag 'kconfig-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (30 commits) kconfig: use yylineno option instead of manual lineno increments kconfig: detect recursive inclusion earlier kconfig: remove duplicated file name and lineno of recursive inclusion kconfig: do not include both curses.h and ncurses.h for nconfig kconfig: make unmet dependency warnings readable kconfig: warn unmet direct dependency of tristate symbols selected by y kconfig: tests: test if recursive inclusion is detected kconfig: tests: test if recursive dependencies are detected kconfig: tests: test randconfig for choice in choice kconfig: tests: test defconfig when two choices interact kconfig: tests: check visibility of tristate choice values in y choice kconfig: tests: check unneeded "is not set" with unmet dependency kconfig: tests: test if new symbols in choice are asked kconfig: tests: test automatic submenu creation kconfig: tests: add basic choice tests kconfig: tests: add framework for Kconfig unit testing kbuild: add PYTHON2 and PYTHON3 variables kconfig: remove redundant streamline_config.pl prerequisite kconfig: rename silentoldconfig to syncconfig kconfig: invoke oldconfig instead of silentoldconfig from local*config ...
2 parents 3b24b83 + 1849268 commit 147a89b

58 files changed

Lines changed: 1043 additions & 139 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/kbuild/kconfig.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Examples:
119119
15% of tristates will be set to 'y', 15% to 'm', 70% to 'n'
120120

121121
______________________________________________________________________
122-
Environment variables for 'silentoldconfig'
122+
Environment variables for 'syncconfig'
123123

124124
KCONFIG_NOSILENTUPDATE
125125
--------------------------------------------------

‎Documentation/networking/i40e.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Enabling the driver
3232
The driver is enabled via the standard kernel configuration system,
3333
using the make command:
3434

35-
Make oldconfig/silentoldconfig/menuconfig/etc.
35+
make config/oldconfig/menuconfig/etc.
3636

3737
The driver is located in the menu structure at:
3838

‎Makefile‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ INSTALLKERNEL := installkernel
386386
DEPMOD = /sbin/depmod
387387
PERL = perl
388388
PYTHON = python
389+
PYTHON2 = python2
390+
PYTHON3 = python3
389391
CHECK = sparse
390392

391393
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
@@ -432,7 +434,7 @@ GCC_PLUGINS_CFLAGS :=
432434

433435
export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
434436
export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES
435-
export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE
437+
export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE
436438
export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
437439

438440
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
@@ -591,7 +593,7 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
591593
# include/generated/ and include/config/. Update them if .config is newer than
592594
# include/config/auto.conf (which mirrors .config).
593595
include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
594-
$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
596+
$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
595597
else
596598
# external modules needs include/generated/autoconf.h and include/config/auto.conf
597599
# but do not care if they are up-to-date. Use auto.conf to trigger the test

‎scripts/checkpatch.pl‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,7 +2797,10 @@ sub process {
27972797
# Only applies when adding the entry originally, after that we do not have
27982798
# sufficient context to determine whether it is indeed long enough.
27992799
if ($realfile =~ /Kconfig/ &&
2800-
$line =~ /^\+\s*config\s+/) {
2800+
# 'choice' is usually the last thing on the line (though
2801+
# Kconfig supports named choices), so use a word boundary
2802+
# (\b) rather than a whitespace character (\s)
2803+
$line =~ /^\+\s*(?:config|menuconfig|choice)\b/) {
28012804
my $length = 0;
28022805
my $cnt = $realcnt;
28032806
my $ln = $linenr + 1;
@@ -2812,17 +2815,27 @@ sub process {
28122815
next if ($f =~ /^-/);
28132816
last if (!$file && $f =~ /^\@\@/);
28142817

2815-
if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate)\s*\"/) {
2818+
if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate|prompt)\s*["']/) {
28162819
$is_start = 1;
2817-
} elsif ($lines[$ln - 1] =~ /^\+\s*(?:---)?help(?:---)?$/) {
2820+
} elsif ($lines[$ln - 1] =~ /^\+\s*(?:help|---help---)\s*$/) {
2821+
if ($lines[$ln - 1] =~ "---help---") {
2822+
WARN("CONFIG_DESCRIPTION",
2823+
"prefer 'help' over '---help---' for new help texts\n" . $herecurr);
2824+
}
28182825
$length = -1;
28192826
}
28202827

28212828
$f =~ s/^.//;
28222829
$f =~ s/#.*//;
28232830
$f =~ s/^\s+//;
28242831
next if ($f =~ /^$/);
2825-
if ($f =~ /^\s*config\s/) {
2832+
2833+
# This only checks context lines in the patch
2834+
# and so hopefully shouldn't trigger false
2835+
# positives, even though some of these are
2836+
# common words in help texts
2837+
if ($f =~ /^\s*(?:config|menuconfig|choice|endchoice|
2838+
if|endif|menu|endmenu|source)\b/x) {
28262839
$is_end = 1;
28272840
last;
28282841
}

‎scripts/kconfig/Makefile‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Kernel configuration targets
44
# These targets are used from top-level makefile
55

6-
PHONY += xconfig gconfig menuconfig config silentoldconfig update-po-config \
6+
PHONY += xconfig gconfig menuconfig config syncconfig update-po-config \
77
localmodconfig localyesconfig
88

99
ifdef KBUILD_KCONFIG
@@ -36,22 +36,22 @@ nconfig: $(obj)/nconf
3636

3737
# This has become an internal implementation detail and is now deprecated
3838
# for external use.
39-
silentoldconfig: $(obj)/conf
39+
syncconfig: $(obj)/conf
4040
$(Q)mkdir -p include/config include/generated
4141
$< $(silent) --$@ $(Kconfig)
4242

43-
localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
43+
localyesconfig localmodconfig: $(obj)/conf
4444
$(Q)mkdir -p include/config include/generated
45-
$(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
45+
$(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
4646
$(Q)if [ -f .config ]; then \
4747
cmp -s .tmp.config .config || \
4848
(mv -f .config .config.old.1; \
4949
mv -f .tmp.config .config; \
50-
$(obj)/conf $(silent) --silentoldconfig $(Kconfig); \
50+
$< $(silent) --oldconfig $(Kconfig); \
5151
mv -f .config.old.1 .config.old) \
5252
else \
5353
mv -f .tmp.config .config; \
54-
$(obj)/conf $(silent) --silentoldconfig $(Kconfig); \
54+
$< $(silent) --oldconfig $(Kconfig); \
5555
fi
5656
$(Q)rm -f .tmp.config
5757

@@ -86,7 +86,7 @@ PHONY += $(simple-targets)
8686
$(simple-targets): $(obj)/conf
8787
$< $(silent) --$@ $(Kconfig)
8888

89-
PHONY += oldnoconfig savedefconfig defconfig
89+
PHONY += oldnoconfig silentoldconfig savedefconfig defconfig
9090

9191
# oldnoconfig is an alias of olddefconfig, because people already are dependent
9292
# on its behavior (sets new symbols to their default value but not 'n') with the
@@ -95,6 +95,13 @@ oldnoconfig: olddefconfig
9595
@echo " WARNING: \"oldnoconfig\" target will be removed after Linux 4.19"
9696
@echo " Please use \"olddefconfig\" instead, which is an alias."
9797

98+
# We do not expect manual invokcation of "silentoldcofig" (or "syncconfig").
99+
silentoldconfig: syncconfig
100+
@echo " WARNING: \"silentoldconfig\" has been renamed to \"syncconfig\""
101+
@echo " and is now an internal implementation detail."
102+
@echo " What you want is probably \"oldconfig\"."
103+
@echo " \"silentoldconfig\" will be removed after Linux 4.19"
104+
98105
savedefconfig: $(obj)/conf
99106
$< $(silent) --$@=defconfig $(Kconfig)
100107

@@ -133,6 +140,14 @@ PHONY += tinyconfig
133140
tinyconfig:
134141
$(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
135142

143+
# CHECK: -o cache_dir=<path> working?
144+
PHONY += testconfig
145+
testconfig: $(obj)/conf
146+
$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
147+
-o cache_dir=$(abspath $(obj)/tests/.cache) \
148+
$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
149+
clean-dirs += tests/.cache
150+
136151
# Help text used by make help
137152
help:
138153
@echo ' config - Update current config utilising a line-oriented program'

‎scripts/kconfig/conf.c‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static void check_conf(struct menu *menu);
2323

2424
enum input_mode {
2525
oldaskconfig,
26-
silentoldconfig,
26+
syncconfig,
2727
oldconfig,
2828
allnoconfig,
2929
allyesconfig,
@@ -100,7 +100,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
100100

101101
switch (input_mode) {
102102
case oldconfig:
103-
case silentoldconfig:
103+
case syncconfig:
104104
if (sym_has_value(sym)) {
105105
printf("%s\n", def);
106106
return 0;
@@ -293,7 +293,7 @@ static int conf_choice(struct menu *menu)
293293
printf("[1-%d?]: ", cnt);
294294
switch (input_mode) {
295295
case oldconfig:
296-
case silentoldconfig:
296+
case syncconfig:
297297
if (!is_new) {
298298
cnt = def;
299299
printf("%d\n", cnt);
@@ -358,10 +358,11 @@ static void conf(struct menu *menu)
358358

359359
switch (prop->type) {
360360
case P_MENU:
361-
if ((input_mode == silentoldconfig ||
362-
input_mode == listnewconfig ||
363-
input_mode == olddefconfig) &&
364-
rootEntry != menu) {
361+
/*
362+
* Except in oldaskconfig mode, we show only menus that
363+
* contain new symbols.
364+
*/
365+
if (input_mode != oldaskconfig && rootEntry != menu) {
365366
check_conf(menu);
366367
return;
367368
}
@@ -424,7 +425,7 @@ static void check_conf(struct menu *menu)
424425
if (sym->name && !sym_is_choice_value(sym)) {
425426
printf("%s%s\n", CONFIG_, sym->name);
426427
}
427-
} else if (input_mode != olddefconfig) {
428+
} else {
428429
if (!conf_cnt++)
429430
printf(_("*\n* Restart config...\n*\n"));
430431
rootEntry = menu_get_parent_menu(menu);
@@ -440,7 +441,7 @@ static void check_conf(struct menu *menu)
440441
static struct option long_opts[] = {
441442
{"oldaskconfig", no_argument, NULL, oldaskconfig},
442443
{"oldconfig", no_argument, NULL, oldconfig},
443-
{"silentoldconfig", no_argument, NULL, silentoldconfig},
444+
{"syncconfig", no_argument, NULL, syncconfig},
444445
{"defconfig", optional_argument, NULL, defconfig},
445446
{"savedefconfig", required_argument, NULL, savedefconfig},
446447
{"allnoconfig", no_argument, NULL, allnoconfig},
@@ -467,8 +468,8 @@ static void conf_usage(const char *progname)
467468
printf(" --listnewconfig List new options\n");
468469
printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
469470
printf(" --oldconfig Update a configuration using a provided .config as base\n");
470-
printf(" --silentoldconfig Similar to oldconfig but generates configuration in\n"
471-
" include/{generated/,config/} (oldconfig used to be more verbose)\n");
471+
printf(" --syncconfig Similar to oldconfig but generates configuration in\n"
472+
" include/{generated/,config/}\n");
472473
printf(" --olddefconfig Same as oldconfig but sets new symbols to their default value\n");
473474
printf(" --oldnoconfig An alias of olddefconfig\n");
474475
printf(" --defconfig <file> New config with default defined in <file>\n");
@@ -500,7 +501,7 @@ int main(int ac, char **av)
500501
}
501502
input_mode = (enum input_mode)opt;
502503
switch (opt) {
503-
case silentoldconfig:
504+
case syncconfig:
504505
sync_kconfig = 1;
505506
break;
506507
case defconfig:
@@ -582,7 +583,7 @@ int main(int ac, char **av)
582583
}
583584
break;
584585
case savedefconfig:
585-
case silentoldconfig:
586+
case syncconfig:
586587
case oldaskconfig:
587588
case oldconfig:
588589
case listnewconfig:
@@ -662,24 +663,24 @@ int main(int ac, char **av)
662663
case oldaskconfig:
663664
rootEntry = &rootmenu;
664665
conf(&rootmenu);
665-
input_mode = silentoldconfig;
666+
input_mode = oldconfig;
666667
/* fall through */
667668
case oldconfig:
668669
case listnewconfig:
669-
case olddefconfig:
670-
case silentoldconfig:
670+
case syncconfig:
671671
/* Update until a loop caused no more changes */
672672
do {
673673
conf_cnt = 0;
674674
check_conf(&rootmenu);
675-
} while (conf_cnt &&
676-
(input_mode != listnewconfig &&
677-
input_mode != olddefconfig));
675+
} while (conf_cnt);
676+
break;
677+
case olddefconfig:
678+
default:
678679
break;
679680
}
680681

681682
if (sync_kconfig) {
682-
/* silentoldconfig is used during the build so we shall update autoconf.
683+
/* syncconfig is used during the build so we shall update autoconf.
683684
* All other commands are only used to generate a config.
684685
*/
685686
if (conf_get_changed() && conf_write(NULL)) {

‎scripts/kconfig/expr.c‎

Lines changed: 28 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,49 +1137,9 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2)
11371137
return 0;
11381138
}
11391139

1140-
static inline struct expr *
1141-
expr_get_leftmost_symbol(const struct expr *e)
1142-
{
1143-
1144-
if (e == NULL)
1145-
return NULL;
1146-
1147-
while (e->type != E_SYMBOL)
1148-
e = e->left.expr;
1149-
1150-
return expr_copy(e);
1151-
}
1152-
1153-
/*
1154-
* Given expression `e1' and `e2', returns the leaf of the longest
1155-
* sub-expression of `e1' not containing 'e2.
1156-
*/
1157-
struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
1158-
{
1159-
struct expr *ret;
1160-
1161-
switch (e1->type) {
1162-
case E_OR:
1163-
return expr_alloc_and(
1164-
expr_simplify_unmet_dep(e1->left.expr, e2),
1165-
expr_simplify_unmet_dep(e1->right.expr, e2));
1166-
case E_AND: {
1167-
struct expr *e;
1168-
e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
1169-
e = expr_eliminate_dups(e);
1170-
ret = (!expr_eq(e, e1)) ? e1 : NULL;
1171-
expr_free(e);
1172-
break;
1173-
}
1174-
default:
1175-
ret = e1;
1176-
break;
1177-
}
1178-
1179-
return expr_get_leftmost_symbol(ret);
1180-
}
1181-
1182-
static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken, bool revdep)
1140+
void expr_print(struct expr *e,
1141+
void (*fn)(void *, struct symbol *, const char *),
1142+
void *data, int prevtoken)
11831143
{
11841144
if (!e) {
11851145
fn(data, NULL, "y");
@@ -1234,14 +1194,9 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con
12341194
fn(data, e->right.sym, e->right.sym->name);
12351195
break;
12361196
case E_OR:
1237-
if (revdep && e->left.expr->type != E_OR)
1238-
fn(data, NULL, "\n - ");
1239-
__expr_print(e->left.expr, fn, data, E_OR, revdep);
1240-
if (revdep)
1241-
fn(data, NULL, "\n - ");
1242-
else
1243-
fn(data, NULL, " || ");
1244-
__expr_print(e->right.expr, fn, data, E_OR, revdep);
1197+
expr_print(e->left.expr, fn, data, E_OR);
1198+
fn(data, NULL, " || ");
1199+
expr_print(e->right.expr, fn, data, E_OR);
12451200
break;
12461201
case E_AND:
12471202
expr_print(e->left.expr, fn, data, E_AND);
@@ -1274,11 +1229,6 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con
12741229
fn(data, NULL, ")");
12751230
}
12761231

1277-
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
1278-
{
1279-
__expr_print(e, fn, data, prevtoken, false);
1280-
}
1281-
12821232
static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
12831233
{
12841234
xfwrite(str, strlen(str), 1, data);
@@ -1329,7 +1279,27 @@ void expr_gstr_print(struct expr *e, struct gstr *gs)
13291279
* line with a minus. This makes expressions much easier to read.
13301280
* Suitable for reverse dependency expressions.
13311281
*/
1332-
void expr_gstr_print_revdep(struct expr *e, struct gstr *gs)
1282+
static void expr_print_revdep(struct expr *e,
1283+
void (*fn)(void *, struct symbol *, const char *),
1284+
void *data, tristate pr_type, const char **title)
1285+
{
1286+
if (e->type == E_OR) {
1287+
expr_print_revdep(e->left.expr, fn, data, pr_type, title);
1288+
expr_print_revdep(e->right.expr, fn, data, pr_type, title);
1289+
} else if (expr_calc_value(e) == pr_type) {
1290+
if (*title) {
1291+
fn(data, NULL, *title);
1292+
*title = NULL;
1293+
}
1294+
1295+
fn(data, NULL, " - ");
1296+
expr_print(e, fn, data, E_NONE);
1297+
fn(data, NULL, "\n");
1298+
}
1299+
}
1300+
1301+
void expr_gstr_print_revdep(struct expr *e, struct gstr *gs,
1302+
tristate pr_type, const char *title)
13331303
{
1334-
__expr_print(e, expr_print_gstr_helper, gs, E_NONE, true);
1304+
expr_print_revdep(e, expr_print_gstr_helper, gs, pr_type, &title);
13351305
}

0 commit comments

Comments
 (0)