public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] linux-module: Support emulated module build with cross-compiled kernel
@ 2024-04-30 13:10 Stefan Koch
  2024-04-30 13:44 ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Koch @ 2024-04-30 13:10 UTC (permalink / raw)
  To: isar-users
  Cc: stefan-koch, jan.kiszka, christian.storm, michael.adler,
	simon.sudler, cedric.hombourger, adriaan.schmidt,
	felix.moessbauer, ubely

Signed-off-by: Stefan Koch <stefan-koch@siemens.com>
---
 meta/recipes-kernel/linux-module/module.inc | 9 ++++++++-
 meta/recipes-kernel/linux/linux-custom.inc  | 2 +-
 meta/recipes-kernel/linux/linux-distro.bb   | 1 +
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc
index eddbf177..eaf086eb 100644
--- a/meta/recipes-kernel/linux-module/module.inc
+++ b/meta/recipes-kernel/linux-module/module.inc
@@ -17,7 +17,6 @@ PN .= "-${KERNEL_NAME}"
 
 KERNEL_IMAGE_PKG ??= "linux-image-${KERNEL_NAME}"
 KERNEL_HEADERS_PKG ??= "linux-headers-${KERNEL_NAME}"
-DEPENDS += "${KERNEL_HEADERS_PKG}"
 DEBIAN_BUILD_DEPENDS = "${KERNEL_HEADERS_PKG}"
 
 SIGNATURE_KEYFILE ??= ""
@@ -36,8 +35,16 @@ AUTOLOAD ?= ""
 python() {
     if d.getVar('KERNEL_NAME') in d.getVar('DISTRO_KERNELS').split():
         d.setVar('ISAR_CROSS_COMPILE', '0')
+
+    if d.getVar("DISTRO_ARCH") != d.getVar("HOST_ARCH") and bb.utils.to_boolean(d.getVar("ISAR_CROSS_COMPILE")):
+        d.appendVar("OVERRIDES", ":cross-profile")
 }
 
+DEFAULT_KERNEL_KBUILD_PKG = "linux-kbuild-${KERNEL_NAME}"
+DEFAULT_KERNEL_KBUILD_PKG:cross-profile = "linux-kbuild-${KERNEL_NAME}-native"
+KERNEL_KBUILD_PKG ??= "${DEFAULT_KERNEL_KBUILD_PKG}"
+DEPENDS += "${KERNEL_HEADERS_PKG} ${KERNEL_KBUILD_PKG}"
+
 inherit dpkg
 
 TEMPLATE_FILES = "debian/control.tmpl \
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index 0d222332..16e65d7a 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -97,7 +97,7 @@ KERNEL_NAME_PROVIDED ?= "${@ d.getVar('BPN').partition('linux-')[2]}"
 
 # Determine cross-profile override
 python() {
-    if d.getVar("DISTRO_ARCH") != d.getVar("HOST_ARCH") and d.getVar("ISAR_CROSS_COMPILE", True) == "1" and "class-native" not in d.getVar("OVERRIDES", True).split(":"):
+    if d.getVar("DISTRO_ARCH") != d.getVar("HOST_ARCH") and bb.utils.to_boolean(d.getVar("ISAR_CROSS_COMPILE")) and "class-native" not in d.getVar("OVERRIDES", True).split(":"):
         d.appendVar("OVERRIDES", ":cross-profile")
 }
 
diff --git a/meta/recipes-kernel/linux/linux-distro.bb b/meta/recipes-kernel/linux/linux-distro.bb
index bc43528c..13b8dc7e 100644
--- a/meta/recipes-kernel/linux/linux-distro.bb
+++ b/meta/recipes-kernel/linux/linux-distro.bb
@@ -10,6 +10,7 @@ python() {
     for kernel in distro_kernels.split():
         d.appendVar('PROVIDES', ' linux-image-' + kernel)
         d.appendVar('PROVIDES', ' linux-headers-' + kernel)
+        d.appendVar('PROVIDES', ' linux-kbuild-' + kernel)
     if d.getVar('KERNEL_IMAGE_PKG'):
         d.appendVar('PROVIDES', ' ' + d.getVar('KERNEL_IMAGE_PKG'))
     if d.getVar('KERNEL_HEADERS_PKG'):
-- 
2.39.2


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH] linux-module: Support emulated module build with cross-compiled kernel
@ 2024-05-02 14:09 Stefan Koch
  2024-05-02 14:32 ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Koch @ 2024-05-02 14:09 UTC (permalink / raw)
  To: isar-users
  Cc: stefan-koch, jan.kiszka, christian.storm, michael.adler,
	simon.sudler, cedric.hombourger, adriaan.schmidt,
	felix.moessbauer, ubely

The dependency to linux-kbuild is modeled using bitbake dependencies as
well as downstream users need to individually select the headers and kbuild
packages - for different architectures in the cross build case.

So, the linux-kbuild package must be explicitly installed within
host arch to build a cross-module. Bitbake must be able to resolve the
dependencies for distro kernels (emulated build), too.

Since distro kernels do not support cross-build kernel modules,
for these kernels an emulated module build is automatically selected.

Signed-off-by: Stefan Koch <stefan-koch@siemens.com>
---
 meta/recipes-kernel/linux-module/module.inc | 9 ++++++++-
 meta/recipes-kernel/linux/linux-custom.inc  | 2 +-
 meta/recipes-kernel/linux/linux-distro.bb   | 1 +
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc
index eddbf177..eaf086eb 100644
--- a/meta/recipes-kernel/linux-module/module.inc
+++ b/meta/recipes-kernel/linux-module/module.inc
@@ -17,7 +17,6 @@ PN .= "-${KERNEL_NAME}"
 
 KERNEL_IMAGE_PKG ??= "linux-image-${KERNEL_NAME}"
 KERNEL_HEADERS_PKG ??= "linux-headers-${KERNEL_NAME}"
-DEPENDS += "${KERNEL_HEADERS_PKG}"
 DEBIAN_BUILD_DEPENDS = "${KERNEL_HEADERS_PKG}"
 
 SIGNATURE_KEYFILE ??= ""
@@ -36,8 +35,16 @@ AUTOLOAD ?= ""
 python() {
     if d.getVar('KERNEL_NAME') in d.getVar('DISTRO_KERNELS').split():
         d.setVar('ISAR_CROSS_COMPILE', '0')
+
+    if d.getVar("DISTRO_ARCH") != d.getVar("HOST_ARCH") and bb.utils.to_boolean(d.getVar("ISAR_CROSS_COMPILE")):
+        d.appendVar("OVERRIDES", ":cross-profile")
 }
 
+DEFAULT_KERNEL_KBUILD_PKG = "linux-kbuild-${KERNEL_NAME}"
+DEFAULT_KERNEL_KBUILD_PKG:cross-profile = "linux-kbuild-${KERNEL_NAME}-native"
+KERNEL_KBUILD_PKG ??= "${DEFAULT_KERNEL_KBUILD_PKG}"
+DEPENDS += "${KERNEL_HEADERS_PKG} ${KERNEL_KBUILD_PKG}"
+
 inherit dpkg
 
 TEMPLATE_FILES = "debian/control.tmpl \
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index 0d222332..16e65d7a 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -97,7 +97,7 @@ KERNEL_NAME_PROVIDED ?= "${@ d.getVar('BPN').partition('linux-')[2]}"
 
 # Determine cross-profile override
 python() {
-    if d.getVar("DISTRO_ARCH") != d.getVar("HOST_ARCH") and d.getVar("ISAR_CROSS_COMPILE", True) == "1" and "class-native" not in d.getVar("OVERRIDES", True).split(":"):
+    if d.getVar("DISTRO_ARCH") != d.getVar("HOST_ARCH") and bb.utils.to_boolean(d.getVar("ISAR_CROSS_COMPILE")) and "class-native" not in d.getVar("OVERRIDES", True).split(":"):
         d.appendVar("OVERRIDES", ":cross-profile")
 }
 
diff --git a/meta/recipes-kernel/linux/linux-distro.bb b/meta/recipes-kernel/linux/linux-distro.bb
index bc43528c..13b8dc7e 100644
--- a/meta/recipes-kernel/linux/linux-distro.bb
+++ b/meta/recipes-kernel/linux/linux-distro.bb
@@ -10,6 +10,7 @@ python() {
     for kernel in distro_kernels.split():
         d.appendVar('PROVIDES', ' linux-image-' + kernel)
         d.appendVar('PROVIDES', ' linux-headers-' + kernel)
+        d.appendVar('PROVIDES', ' linux-kbuild-' + kernel)
     if d.getVar('KERNEL_IMAGE_PKG'):
         d.appendVar('PROVIDES', ' ' + d.getVar('KERNEL_IMAGE_PKG'))
     if d.getVar('KERNEL_HEADERS_PKG'):
-- 
2.39.2


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

end of thread, other threads:[~2024-05-02 14:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-30 13:10 [PATCH] linux-module: Support emulated module build with cross-compiled kernel Stefan Koch
2024-04-30 13:44 ` Jan Kiszka
2024-04-30 16:52   ` Koch, Stefan
2024-05-02 14:09 Stefan Koch
2024-05-02 14:32 ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox