History

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.

Masahiro Yamada committed 6 years ago

Commit 3a9dd3e1 parent def2fbf2 files · +16 −3Browse files

Unified · Split

2 files
  1. Documentation/kbuild/kconfig-language.rst +13 −2
  2. scripts/kconfig/symbol.c +3 −1
Documentation/kbuild/kconfig-language.rst+13−2
@@ -159,11 +159,11 @@ applicable everywhere (see syntax). · 158 unmodified lines
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). · 4 unmodified lines
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). · 11 unmodified lines
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+3−1
@@ -221,7 +221,7 @@ static void sym_calc_visibility(struct symbol *sym) · 220 unmodified lines
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) · 166 unmodified lines
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: