alistair23-linux/scripts/kconfig
Thomas Hebb edda15f219 kconfig: list all definitions of a symbol in help text
In Kconfig, each symbol (representing a config option) can be defined in
multiple places. Each definition may or may not have a prompt, which
allows the option to be set via an interface like menuconfig. Each
definition has a set of dependencies, which determine whether its prompt
is visible and whether other pieces of the definition, like a default
value, take effect.

Historically, a symbol's help text (i.e. what's shown when a user
presses '?' in menuconfig) contained some symbol-wide information not
tied to any particular definition (e.g. what other symbols it selects)
as well as the location (file name and line number) and dependencies of
each prompt. Notably, the help text did not show the location or
dependencies of definitions without prompts.

Because this made it hard to reason about symbols that had no prompts,
commit bcdedcc1af ("menuconfig: print more info for symbol without
prompts") changed the help text so that, instead of containing the
location and dependencies of each prompt, it contained the location and
dependencies of the symbol's first definition, regardless of whether or
not that definition had a prompt.

For symbols with only one definition, that change makes sense. However,
it breaks down for symbols with multiple definitions: each definition
has its own set of dependencies (the `dep` field of `struct menu`), and
those dependencies are ORed together to get the symbol's dependency list
(the `dir_dep` field of `struct symbol`). By printing only the
dependencies of the first definition, the help text misleads users into
believing that an option is more narrowly-applicable than it actually
is.

For an extreme example of this, we can look at the SYS_TEXT_BASE symbol
in the Das U-Boot project (version 2019.10), which also uses Kconfig. (I
unfortunately could not find an illustrative example in Linux.) This
config option specifies the load address of the built binary and, as
such, is applicable to basically every configuration possible. And yet,
without this patch, its help text is as follows:

  Symbol: SYS_TEXT_BASE [=]
  Type  : hex
  Prompt: U-Boot base address
    Location:
      -> ARM architecture
  Prompt: Text Base
    Location:
      -> Boot images
    Defined at arch/arm/mach-aspeed/Kconfig:9
    Depends on: ARM [=n] && ARCH_ASPEED [=n]

The help text indicates that the option is applicable only for a
specific unselected architecture (aspeed), because that architecture's
promptless definition (which just sets a default value), happens to be
the first one seen. No definition or dependency information is printed
for either of the two prompts listed.

Because source locations and dependencies are fundamentally properties
of definitions and not of symbols, we should treat them as such. This
patch brings back the pre-bcdedcc1afd6 behavior for definitions with
prompts but also separately prints the location and dependencies of
those without prompts, solving the original problem in a different way.
With this change, our SYS_TEXT_BASE example becomes

   Symbol: SYS_TEXT_BASE [=]
   Type  : hex
   Defined at arch/arm/mach-stm32mp/Kconfig:83
     Prompt: U-Boot base address
     Depends on: ARM [=n] && ARCH_STM32MP [=n]
     Location:
       -> ARM architecture
   Defined at Kconfig:532
     Prompt: Text Base
     Depends on: !NIOS2 [=n] && !XTENSA [=n] && !EFI_APP [=n]
     Location:
       -> Boot images
   Defined at arch/arm/mach-aspeed/Kconfig:9
     Depends on: ARM [=n] && ARCH_ASPEED [=n]
   Defined  at arch/arm/mach-socfpga/Kconfig:25
     Depends on: ARM [=n] && ARCH_SOCFPGA [=n]
   <snip>
   Defined at board/sifive/fu540/Kconfig:15
     Depends on: RISCV [=n] && TARGET_SIFIVE_FU540 [=n]

which is a much more accurate representation.

Note that there is one notable difference between what gets printed for
prompts after this change and what got printed before bcdedcc1af: the
"Depends on" line now accurately represents the prompt's dependencies
instead of conflating those with the prompt's visibility (which can
include extra conditions). See the patch later in this series titled
"kconfig: distinguish between dependencies and visibility in help text"
for more details and better handling of that nuance.

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2020-01-07 02:18:45 +09:00
..
lxdialog kconfig: remove trailing whitespaces 2019-05-09 22:37:17 +09:00
tests docs: kbuild: convert docs to ReST and rename to *.rst 2019-06-14 14:21:21 -06:00
.gitignore kconfig: rename generated .*conf-cfg to *conf-cfg 2019-01-06 10:47:09 +09:00
conf.c kconfig: Add yes2modconfig and mod2yesconfig targets. 2020-01-07 02:18:45 +09:00
confdata.c kconfig: Add yes2modconfig and mod2yesconfig targets. 2020-01-07 02:18:45 +09:00
expr.c kconfig: don't crash on NULL expressions in expr_eq() 2019-12-17 19:21:07 +09:00
expr.h kconfig: remove sym from struct property 2020-01-07 02:18:44 +09:00
gconf-cfg.sh kconfig: do not require pkg-config on make {menu,n}config 2018-09-03 02:13:48 +09:00
gconf.c kconfig: remove trailing whitespaces 2019-05-09 22:37:17 +09:00
gconf.glade scripts/kconfig/gconf.glade Update broken web addresses. 2010-09-17 16:54:42 +02:00
images.c kconfig: split images.c out of qconf.cc/gconf.c to fix gconf warnings 2018-12-28 22:22:39 +09:00
images.h kconfig: split images.c out of qconf.cc/gconf.c to fix gconf warnings 2018-12-28 22:22:39 +09:00
lexer.l kconfig: use snprintf for formatting pathnames 2019-05-14 23:23:25 +09:00
list.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lkc.h kconfig: Add yes2modconfig and mod2yesconfig targets. 2020-01-07 02:18:45 +09:00
lkc_proto.h kconfig: Fix spelling of sym_is_changable 2019-07-06 21:58:23 +09:00
Makefile kconfig: Add yes2modconfig and mod2yesconfig targets. 2020-01-07 02:18:45 +09:00
mconf-cfg.sh kconfig: be more helpful if pkg-config is missing 2019-11-11 20:10:01 +09:00
mconf.c kconfig: Fix spelling of sym_is_changable 2019-07-06 21:58:23 +09:00
menu.c kconfig: list all definitions of a symbol in help text 2020-01-07 02:18:45 +09:00
merge_config.sh merge_config.sh: ignore unwanted grep errors 2019-09-04 23:12:50 +09:00
nconf-cfg.sh kconfig: be more helpful if pkg-config is missing 2019-11-11 20:10:01 +09:00
nconf.c kconfig: Fix spelling of sym_is_changable 2019-07-06 21:58:23 +09:00
nconf.gui.c kconfig/[mn]conf: handle backspace (^H) key 2019-03-29 22:48:01 +09:00
nconf.h kconfig: convert to SPDX License Identifier 2018-12-28 22:22:28 +09:00
parser.y kconfig: remove sym from struct property 2020-01-07 02:18:44 +09:00
preprocess.c kconfig: add static qualifier to expand_string() 2019-06-09 15:08:18 +09:00
qconf-cfg.sh kconfig: do not require pkg-config on make {menu,n}config 2018-09-03 02:13:48 +09:00
qconf.cc kconfig: Fix spelling of sym_is_changable 2019-07-06 21:58:23 +09:00
qconf.h kconfig: fix 'Save As' menu of xconfig 2019-03-12 02:50:24 +09:00
streamline_config.pl kconfig: localmodconfig: fix indentation for closing brace 2020-01-07 02:18:45 +09:00
symbol.c kconfig: squash prop_alloc() into menu_add_prop() 2020-01-07 02:18:44 +09:00
util.c kconfig: convert to SPDX License Identifier 2018-12-28 22:22:28 +09:00