Skip to contentSkip to conversation

Documentation: kbuild: explain handling optional dependencies

PATCH In review Arnd Bergmann 3 participants 5 messages Sep 17, 2023 – Feb 15, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Documentation: kbuild: explain handling optional dependencies

From: Arnd Bergmann <[email protected]>

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.

---
v2: fix typos pointed out by Nicolas Schier

---
 Documentation/kbuild/kconfig-language.rst | 26 +++++++++++++++++++++++
 1 file changed, 26 insertions(+)
Documentation/kbuild/kconfig-language.rst +26 -0
index 858ed5d80defe..0135905c0aa35 100644
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Signature · 1 line
2.39.2
#1 lore raw
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 6 lines

---
v2: fix typos pointed out by Nicolas Schier

Applied to linux-kbuild. Thanks.

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 20 lines · Masahiro Yamada
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 6 lines

---
v2: fix typos pointed out by Nicolas Schier

Quoted 1 line

Applied to linux-kbuild. Thanks.

Hi Masahiro,

this patch seems to got lost, or did you intentionally removed it again?

Kind regards,
Nicolas

#3 lore raw
Quoted 24 lines · Nicolas Schier
Quoted 20 lines · Masahiro Yamada
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 6 lines

---
v2: fix typos pointed out by Nicolas Schier

Quoted 1 line

Applied to linux-kbuild. Thanks.

Quoted 7 lines

Hi Masahiro,

this patch seems to got lost, or did you intentionally removed it again?

Kind regards,
Nicolas

Oh?

I can see it in the mainline.

commit 28d49e171676afb7df7f47798391364af9abed7f

Author:     Arnd Bergmann <[email protected]>
AuthorDate: Sun Sep 17 21:19:59 2023 +0200
Commit:     Masahiro Yamada <[email protected]>
CommitDate: Mon Sep 25 16:01:05 2023 +0900

Documentation: kbuild: explain handling optional dependencies

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw
Quoted 31 lines · Masahiro Yamada
Quoted 29 lines · Nicolas Schier
Quoted 20 lines · Masahiro Yamada
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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.

Quoted 6 lines

---
v2: fix typos pointed out by Nicolas Schier

Quoted 1 line

Applied to linux-kbuild. Thanks.

Hi Masahiro,

this patch seems to got lost, or did you intentionally removed it again?

Quoted 8 lines
Quoted 2 lines

Kind regards,
Nicolas

Oh?

I can see it in the mainline.

ups, I'm sorry for the noise. You are right, I had an heavily out-dated tree at hand and wasn't aware of it ...

Kind regards,
Nicolas