Skip to content

Commit 3a9dd3e

Browse files
committed
kconfig: make 'imply' obey the direct dependency
The 'imply' statement may create unmet direct dependency when the implied symbol depends on m. [Test Code] config FOO tristate "foo" imply BAZ config BAZ tristate "baz" depends on BAR config BAR def_tristate m config MODULES def_bool y option modules If you set FOO=y, BAZ is also promoted to y, which results in the following .config file: CONFIG_FOO=y CONFIG_BAZ=y CONFIG_BAR=m CONFIG_MODULES=y This does not meet the dependency 'BAZ depends on BAR'. Unlike 'select', what is worse, Kconfig never shows the 'WARNING: unmet direct dependencies detected for ...' for this case. Because 'imply' is considered to be weaker than 'depends on', Kconfig should take the direct dependency into account. For clarification, describe this case in kconfig-language.rst too. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Nicolas Pitre <nico@fluxnic.net> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
1 parent def2fbf commit 3a9dd3e

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎Documentation/kbuild/kconfig-language.rst‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ applicable everywhere (see syntax).
159159
Given the following example::
160160

161161
config FOO
162-
tristate
162+
tristate "foo"
163163
imply BAZ
164164

165165
config BAZ
166-
tristate
166+
tristate "baz"
167167
depends on BAR
168168

169169
The following values are possible:
@@ -174,6 +174,9 @@ applicable everywhere (see syntax).
174174
n y n N/m/y
175175
m y m M/y/n
176176
y y y Y/m/n
177+
n m n N/m
178+
m m m M/n
179+
y m n M/n
177180
y n * N
178181
=== === ============= ==============
179182

@@ -191,6 +194,14 @@ applicable everywhere (see syntax).
191194
...
192195
}
193196

197+
Note: If the feature provided by BAZ is highly desirable for FOO,
198+
FOO should imply not only BAZ, but also its dependency BAR::
199+
200+
config FOO
201+
tristate "foo"
202+
imply BAR
203+
imply BAZ
204+
194205
- limiting menu display: "visible if" <expr>
195206

196207
This attribute is only applicable to menu blocks, if the condition is

‎scripts/kconfig/symbol.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static void sym_calc_visibility(struct symbol *sym)
221221
sym_set_changed(sym);
222222
}
223223
tri = no;
224-
if (sym->implied.expr && sym->dir_dep.tri != no)
224+
if (sym->implied.expr)
225225
tri = expr_calc_value(sym->implied.expr);
226226
if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
227227
tri = yes;
@@ -394,6 +394,8 @@ void sym_calc_value(struct symbol *sym)
394394
if (sym->implied.tri != no) {
395395
sym->flags |= SYMBOL_WRITE;
396396
newval.tri = EXPR_OR(newval.tri, sym->implied.tri);
397+
newval.tri = EXPR_AND(newval.tri,
398+
sym->dir_dep.tri);
397399
}
398400
}
399401
calc_newval:

0 commit comments

Comments
 (0)