linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Documentation: kbuild: explain handling optional dependencies
@ 2023-09-13 11:37 Arnd Bergmann
  2023-09-13 14:25 ` Javier Martinez Canillas
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Arnd Bergmann @ 2023-09-13 11:37 UTC (permalink / raw)
  To: Masahiro Yamada, Jonathan Corbet
  Cc: Sakari Ailus, Javier Martinez Canillas, Arnd Bergmann,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier, linux-kbuild,
	linux-doc, linux-kernel

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


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-09-15 15:48 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-13 11:37 [PATCH] Documentation: kbuild: explain handling optional dependencies Arnd Bergmann
2023-09-13 14:25 ` Javier Martinez Canillas
2023-09-13 16:11 ` Sakari Ailus
2023-09-13 19:48 ` Nicolas Schier
2023-09-13 19:55   ` Arnd Bergmann
2023-09-13 20:34     ` Nicolas Schier
2023-09-13 21:16       ` Arnd Bergmann
2023-09-14  3:51         ` Nicolas Schier
2023-09-14  5:05           ` Arnd Bergmann
2023-09-14  3:56         ` Javier Martinez Canillas
2023-09-14 17:07       ` Masahiro Yamada
2023-09-14 13:42 ` Jani Nikula
2023-09-14 14:57   ` Arnd Bergmann
2023-09-14 15:56     ` Jani Nikula
2023-09-14 17:23     ` Masahiro Yamada
2023-09-15  5:26       ` Arnd Bergmann
2023-09-15  7:34         ` Jani Nikula
2023-09-15  7:44           ` Arnd Bergmann
2023-09-15 15:48             ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).