|
|
Subscribe / Log in / New account

Documentation: kbuild: explain handling optional dependencies

From:  Arnd Bergmann <arnd-AT-kernel.org>
To:  Masahiro Yamada <masahiroy-AT-kernel.org>, Jonathan Corbet <corbet-AT-lwn.net>
Subject:  [PATCH] Documentation: kbuild: explain handling optional dependencies
Date:  Wed, 13 Sep 2023 13:37:52 +0200
Message-ID:  <20230913113801.1901152-1-arnd@kernel.org>
Cc:  Sakari Ailus <sakari.ailus-AT-iki.fi>, Javier Martinez Canillas <javierm-AT-redhat.com>, Arnd Bergmann <arnd-AT-arndb.de>, Nathan Chancellor <nathan-AT-kernel.org>, Nick Desaulniers <ndesaulniers-AT-google.com>, Nicolas Schier <nicolas-AT-fjasle.eu>, linux-kbuild-AT-vger.kernel.org, linux-doc-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org
Archive-link:  Article

From: Arnd Bergmann <arnd@arndb.de>

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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 Documentation/kbuild/kconfig-language.rst | 26 +++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst
index 858ed5d80defe..89dea587a469a 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 slighly counterintuitive
+
+  config FOO
+	bool "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
+	bool "Support for foo hardware"
+	depends on BAR_OPTIONAL
+
+  config BAR_OPTIONAL
+	def_tristate BAR || !BAR
+
 Kconfig recursive dependency limitations
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.39.2



Copyright © 2023, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds