2023-09-17 19:21:42

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH] [v2] 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.

Reviewed-by: Javier Martinez Canillas <[email protected]>
Reviewed-by: Sakari Ailus <[email protected]>
Reviewed-by: Nicolas Schier <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
---
v2: fix typos pointed out by Nicolas Schier
---
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..0135905c0aa35 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--
2.39.2


2023-09-25 07:23:50

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] [v2] Documentation: kbuild: explain handling optional dependencies

On Mon, Sep 18, 2023 at 4:20 AM Arnd Bergmann <[email protected]> wrote:
>
> 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.
>
> Reviewed-by: Javier Martinez Canillas <[email protected]>
> Reviewed-by: Sakari Ailus <[email protected]>
> Reviewed-by: Nicolas Schier <[email protected]>
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> v2: fix typos pointed out by Nicolas Schier


Applied to linux-kbuild. Thanks.



--
Best Regards
Masahiro Yamada

2024-02-15 12:39:36

by Nicolas Schier

[permalink] [raw]
Subject: Re: [PATCH] [v2] Documentation: kbuild: explain handling optional dependencies

On Mon 25 Sep 2023 16:06:41 GMT, Masahiro Yamada wrote:
> On Mon, Sep 18, 2023 at 4:20 AM Arnd Bergmann <[email protected]>
> wrote:
> >
> > 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.
> >
> > Reviewed-by: Javier Martinez Canillas <[email protected]>
> > Reviewed-by: Sakari Ailus <[email protected]>
> > Reviewed-by: Nicolas Schier <[email protected]>
> > Signed-off-by: Arnd Bergmann <[email protected]>
> > ---
> > v2: fix typos pointed out by Nicolas Schier
>
>
> Applied to linux-kbuild. Thanks.

Hi Masahiro,

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

Kind regards,
Nicolas


Attachments:
(No filename) (906.00 B)
signature.asc (849.00 B)
Download all attachments

2024-02-15 13:42:59

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] [v2] Documentation: kbuild: explain handling optional dependencies

On Thu, Feb 15, 2024 at 9:39 PM Nicolas Schier <[email protected]> wrote:
>
> On Mon 25 Sep 2023 16:06:41 GMT, Masahiro Yamada wrote:
> > On Mon, Sep 18, 2023 at 4:20 AM Arnd Bergmann <[email protected]>
> > wrote:
> > >
> > > 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.
> > >
> > > Reviewed-by: Javier Martinez Canillas <[email protected]>
> > > Reviewed-by: Sakari Ailus <[email protected]>
> > > Reviewed-by: Nicolas Schier <[email protected]>
> > > Signed-off-by: Arnd Bergmann <[email protected]>
> > > ---
> > > v2: fix typos pointed out by Nicolas Schier
> >
> >
> > Applied to linux-kbuild. Thanks.
>
> 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





--
Best Regards
Masahiro Yamada

2024-02-15 13:55:18

by Nicolas Schier

[permalink] [raw]
Subject: Re: [PATCH] [v2] Documentation: kbuild: explain handling optional dependencies

On Thu 15 Feb 2024 22:40:46 GMT, Masahiro Yamada wrote:
> On Thu, Feb 15, 2024 at 9:39 PM Nicolas Schier <[email protected]>
> wrote:
> >
> > On Mon 25 Sep 2023 16:06:41 GMT, Masahiro Yamada wrote:
> > > On Mon, Sep 18, 2023 at 4:20 AM Arnd Bergmann <[email protected]>
> > > wrote:
> > > >
> > > > 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.
> > > >
> > > > Reviewed-by: Javier Martinez Canillas <[email protected]>
> > > > Reviewed-by: Sakari Ailus <[email protected]>
> > > > Reviewed-by: Nicolas Schier <[email protected]>
> > > > Signed-off-by: Arnd Bergmann <[email protected]>
> > > > ---
> > > > v2: fix typos pointed out by Nicolas Schier
> > >
> > >
> > > Applied to linux-kbuild. Thanks.
> >
> > 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.

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


Attachments:
(No filename) (1.33 kB)
signature.asc (849.00 B)
Download all attachments