Skip to content

Commit 28d49e1

Browse files
arndbmasahir0y
authored andcommitted
Documentation: kbuild: explain handling optional dependencies
This problem frequently comes up in randconfig testing, with drivers failing to link because of a dependency on an optional feature. The Kconfig language for this is very confusing, so try to document it in "Kconfig hints" section. Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent fbf5892 commit 28d49e1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Documentation/kbuild/kconfig-language.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,32 @@ above, leading to:
573573
bool "Support for foo hardware"
574574
depends on ARCH_FOO_VENDOR || COMPILE_TEST
575575

576+
Optional dependencies
577+
~~~~~~~~~~~~~~~~~~~~~
578+
579+
Some drivers are able to optionally use a feature from another module
580+
or build cleanly with that module disabled, but cause a link failure
581+
when trying to use that loadable module from a built-in driver.
582+
583+
The most common way to express this optional dependency in Kconfig logic
584+
uses the slightly counterintuitive::
585+
586+
config FOO
587+
tristate "Support for foo hardware"
588+
depends on BAR || !BAR
589+
590+
This means that there is either a dependency on BAR that disallows
591+
the combination of FOO=y with BAR=m, or BAR is completely disabled.
592+
For a more formalized approach if there are multiple drivers that have
593+
the same dependency, a helper symbol can be used, like::
594+
595+
config FOO
596+
tristate "Support for foo hardware"
597+
depends on BAR_OPTIONAL
598+
599+
config BAR_OPTIONAL
600+
def_tristate BAR || !BAR
601+
576602
Kconfig recursive dependency limitations
577603
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
578604

0 commit comments

Comments
 (0)