aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Documentation/kbuild
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2023-09-17 21:19:59 +0200
committerMasahiro Yamada <masahiroy@kernel.org>2023-09-25 16:01:05 +0900
commit28d49e171676afb7df7f47798391364af9abed7f (patch)
tree958b34bd540d22f2d8af5c2f64b6ca978fd1ba05 /Documentation/kbuild
parentkbuild: Use CRC32 and a 1MiB dictionary for XZ compressed modules (diff)
downloadwireguard-linux-28d49e171676afb7df7f47798391364af9abed7f.tar.xz
wireguard-linux-28d49e171676afb7df7f47798391364af9abed7f.zip
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>
Diffstat (limited to 'Documentation/kbuild')
-rw-r--r--Documentation/kbuild/kconfig-language.rst26
1 files changed, 26 insertions, 0 deletions
diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst
index 858ed5d80def..0135905c0aa3 100644
--- a/Documentation/kbuild/kconfig-language.rst
+++ b/Documentation/kbuild/kconfig-language.rst
@@ -573,6 +573,32 @@ above, leading to:
bool "Support for foo hardware"
depends on ARCH_FOO_VENDOR || COMPILE_TEST
+Optional dependencies
+~~~~~~~~~~~~~~~~~~~~~
+
+Some drivers are able to optionally use a feature from another module
+or build cleanly with that module disabled, but cause a link failure
+when trying to use that loadable module from a built-in driver.
+
+The most common way to express this optional dependency in Kconfig logic
+uses the slightly counterintuitive::
+
+ config FOO
+ tristate "Support for foo hardware"
+ depends on BAR || !BAR
+
+This means that there is either a dependency on BAR that disallows
+the combination of FOO=y with BAR=m, or BAR is completely disabled.
+For a more formalized approach if there are multiple drivers that have
+the same dependency, a helper symbol can be used, like::
+
+ config FOO
+ tristate "Support for foo hardware"
+ depends on BAR_OPTIONAL
+
+ config BAR_OPTIONAL
+ def_tristate BAR || !BAR
+
Kconfig recursive dependency limitations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~