All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [hardknott] module.bbclass: Improve kernel module dependency detection
@ 2021-09-11 20:28 Charlie Davies
  2021-09-11 21:11 ` [OE-core] " Richard Purdie
  0 siblings, 1 reply; 3+ messages in thread
From: Charlie Davies @ 2021-09-11 20:28 UTC (permalink / raw)
  To: openembedded-core; +Cc: Charlie Davies

If a kernel module recipe specifies a DEPENDS on another
kernel module currently the module being depended on
must have a name starting with kernel-module- .

It is perfectly valid to name a package without the
kernel-module- scheme and instead use:

RPROVIDES_${PN} += "kernel-module-my-module"

in the package's recipe to provide an alias package
name.

This commit introduces functionality which will search
through the RPROVIDES aliases of each dependency package
to allow packages not named kernel-module- to be
recognised as dependencies.

Signed-off-by: Charlie Davies <charles.davies@whitetree.xyz>
---
 meta/classes/module.bbclass | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/meta/classes/module.bbclass b/meta/classes/module.bbclass
index a09ec3ed1e..c4f052234d 100644
--- a/meta/classes/module.bbclass
+++ b/meta/classes/module.bbclass
@@ -6,11 +6,25 @@ MODULES_INSTALL_TARGET ?= "modules_install"
 MODULES_MODULE_SYMVERS_LOCATION ?= ""
 
 python __anonymous () {
+    import oe.packagedata
+
     depends = d.getVar('DEPENDS')
     extra_symbols = []
     for dep in depends.split():
         if dep.startswith("kernel-module-"):
             extra_symbols.append("${STAGING_INCDIR}/" + dep + "/Module.symvers")
+        else:
+            if oe.packagedata.has_subpkgdata(dep, d):
+                data = oe.packagedata.read_subpkgdata(dep, d)
+                key = "RPROVIDES_%s" % dep
+                rprovs = data.get(key)
+
+                if rprovs is not None:
+                    for rprov in rprovs.split():
+                        if rprov.startswith("kernel-module-"):
+                            extra_symbols.append("${STAGING_INCDIR}/" + dep + "/Module.symvers")
+                            break
+
     d.setVar('KBUILD_EXTRA_SYMBOLS', " ".join(extra_symbols))
 }
 
-- 
2.33.0


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

* Re: [OE-core] [PATCH] [hardknott] module.bbclass: Improve kernel module dependency detection
  2021-09-11 20:28 [PATCH] [hardknott] module.bbclass: Improve kernel module dependency detection Charlie Davies
@ 2021-09-11 21:11 ` Richard Purdie
  2021-09-11 22:30   ` Charlie Davies
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2021-09-11 21:11 UTC (permalink / raw)
  To: Charlie Davies, openembedded-core

On Sat, 2021-09-11 at 21:28 +0100, Charlie Davies wrote:
> If a kernel module recipe specifies a DEPENDS on another
> kernel module currently the module being depended on
> must have a name starting with kernel-module- .
> 
> It is perfectly valid to name a package without the
> kernel-module- scheme and instead use:
> 
> RPROVIDES_${PN} += "kernel-module-my-module"
> 
> in the package's recipe to provide an alias package
> name.
> 
> This commit introduces functionality which will search
> through the RPROVIDES aliases of each dependency package
> to allow packages not named kernel-module- to be
> recognised as dependencies.
> 
> Signed-off-by: Charlie Davies <charles.davies@whitetree.xyz>
> ---
>  meta/classes/module.bbclass | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/meta/classes/module.bbclass b/meta/classes/module.bbclass
> index a09ec3ed1e..c4f052234d 100644
> --- a/meta/classes/module.bbclass
> +++ b/meta/classes/module.bbclass
> @@ -6,11 +6,25 @@ MODULES_INSTALL_TARGET ?= "modules_install"
>  MODULES_MODULE_SYMVERS_LOCATION ?= ""
>  
>  python __anonymous () {
> +    import oe.packagedata
> +
>      depends = d.getVar('DEPENDS')
>      extra_symbols = []
>      for dep in depends.split():
>          if dep.startswith("kernel-module-"):
>              extra_symbols.append("${STAGING_INCDIR}/" + dep + "/Module.symvers")
> +        else:
> +            if oe.packagedata.has_subpkgdata(dep, d):
> +                data = oe.packagedata.read_subpkgdata(dep, d)
> +                key = "RPROVIDES_%s" % dep
> +                rprovs = data.get(key)
> +
> +                if rprovs is not None:
> +                    for rprov in rprovs.split():
> +                        if rprov.startswith("kernel-module-"):
> +                            extra_symbols.append("${STAGING_INCDIR}/" + dep + "/Module.symvers")
> +                            break
> +
>      d.setVar('KBUILD_EXTRA_SYMBOLS', " ".join(extra_symbols))
>  }
> 

This looks a bit like a nasty determinism issue. The original code only looks at
DEPENDS which can be determined at parse time. The new code will depend on what
is in the pkgdata sysroot which may or may not be present leading to varying
values of KBUILD_EXTRA_SYMBOLS. It will also have a pretty heavy overhead though
reading extra files.

At the very least this code needs to be scope limited but I'm not sure how
KBUILD_EXTRA_SYMBOLS is being used to be able offer more advice on that.

Cheers,

Richard




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

* Re: [PATCH] [hardknott] module.bbclass: Improve kernel module dependency detection
  2021-09-11 21:11 ` [OE-core] " Richard Purdie
@ 2021-09-11 22:30   ` Charlie Davies
  0 siblings, 0 replies; 3+ messages in thread
From: Charlie Davies @ 2021-09-11 22:30 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

Indeed, as you suspected, I came back to my machine to a bunch of hash mismatch errors so this patch is not the right way to go about this.

There definitely exists an issue and the reason I came across it was by following the hello-mod recipe in meta-skeleton.

KBUILD_EXTRA_SYMBOLS is passed to make and is just a list of filepath(s) to the depended on module(s) Module.symvers file needed by the module which has the dependency to build successfully.

I will have a think about a better solution.

Cheers,

Charlie

[-- Attachment #2: Type: text/html, Size: 657 bytes --]

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

end of thread, other threads:[~2021-09-11 22:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-11 20:28 [PATCH] [hardknott] module.bbclass: Improve kernel module dependency detection Charlie Davies
2021-09-11 21:11 ` [OE-core] " Richard Purdie
2021-09-11 22:30   ` Charlie Davies

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.