From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 05/25] kernel-arch: Move kernel and uboot arch functions to lib/oe/kernel.py
Date: Sun, 2 Aug 2026 11:28:34 +0100 [thread overview]
Message-ID: <20260802102854.3952760-6-richard.purdie@linuxfoundation.org> (raw)
In-Reply-To: <20260802102854.3952760-1-richard.purdie@linuxfoundation.org>
Move the ARCH and UBOOT_ARCH python functions to the python library code.
The ability to alter valid_archs is removed as:
- the values should be long since established by now
- non-linux targets have an escape in the code
- the lower case variable name is not normal convention and should be
replaced if we were to retain it
By removing it we'll find out if anyone does actually need that (and we
can probably fix the entries in the file if there is anything missing).
The code itself is full of redundant codepaths but that is for another
patch if we try and improve it.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
meta/classes-recipe/kernel-arch.bbclass | 54 +------------------------
meta/lib/oe/kernel.py | 39 ++++++++++++++++++
2 files changed, 41 insertions(+), 52 deletions(-)
diff --git a/meta/classes-recipe/kernel-arch.bbclass b/meta/classes-recipe/kernel-arch.bbclass
index 5f8dbacc0c0..b00341c2180 100644
--- a/meta/classes-recipe/kernel-arch.bbclass
+++ b/meta/classes-recipe/kernel-arch.bbclass
@@ -4,61 +4,11 @@
# SPDX-License-Identifier: MIT
#
-#
# set the ARCH environment variable for kernel compilation (including
# modules). return value must match one of the architecture directories
# in the kernel source "arch" directory
-#
-
-valid_archs = "alpha cris ia64 \
- i386 x86 \
- m68knommu m68k ppc powerpc powerpc64 ppc64 \
- sparc sparc64 \
- arm aarch64 \
- m32r mips \
- sh sh64 um h8300 \
- parisc s390 v850 \
- avr32 blackfin \
- loongarch64 \
- microblaze \
- nios2 arc riscv xtensa"
-
-def map_kernel_arch(a, d):
- import re
-
- valid_archs = d.getVar('valid_archs').split()
-
- if re.match('(i.86|athlon|x86.64)$', a): return 'x86'
- elif re.match('arceb$', a): return 'arc'
- elif re.match('armeb$', a): return 'arm'
- elif re.match('aarch64$', a): return 'arm64'
- elif re.match('aarch64_be$', a): return 'arm64'
- elif re.match('aarch64_ilp32$', a): return 'arm64'
- elif re.match('aarch64_be_ilp32$', a): return 'arm64'
- elif re.match('loongarch(32|64|)$', a): return 'loongarch'
- elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'mips'
- elif re.match('mcf', a): return 'm68k'
- elif re.match('riscv(32|64|)(eb|)$', a): return 'riscv'
- elif re.match('p(pc|owerpc)(|64)', a): return 'powerpc'
- elif re.match('sh(3|4)$', a): return 'sh'
- elif re.match('bfin', a): return 'blackfin'
- elif re.match('microblazee[bl]', a): return 'microblaze'
- elif a in valid_archs: return a
- else:
- if not d.getVar("TARGET_OS").startswith("linux"):
- return a
- bb.error("cannot map '%s' to a linux kernel architecture" % a)
-
-export ARCH = "${@map_kernel_arch(d.getVar('TARGET_ARCH'), d)}"
-
-def map_uboot_arch(a, d):
- import re
-
- if re.match('p(pc|owerpc)(|64)', a): return 'ppc'
- elif re.match('i.86$', a): return 'x86'
- return a
-
-export UBOOT_ARCH = "${@map_uboot_arch(d.getVar('ARCH'), d)}"
+export ARCH = "${@oe.kernel.map_kernel_arch(d)}"
+export UBOOT_ARCH = "${@oe.kernel.map_uboot_arch(d)}"
# Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
# specific options necessary for building the kernel and modules.
diff --git a/meta/lib/oe/kernel.py b/meta/lib/oe/kernel.py
index 421debed9af..bab375c37ae 100644
--- a/meta/lib/oe/kernel.py
+++ b/meta/lib/oe/kernel.py
@@ -6,6 +6,45 @@
import re
+# Return a value for the ARCH environment variable for kernel compilation (including
+# modules). return value must match one of the architecture directories
+# in the kernel source "arch" directory
+def map_kernel_arch(d):
+ a = d.getVar('TARGET_ARCH')
+
+ valid_archs = ["alpha", "cris", "ia64", "i386", "x86", "m68knommu", "m68k", "ppc", "powerpc",
+ "powerpc64", "ppc64", "sparc", "sparc64", "arm", "aarch64", "m32r", "mips",
+ "sh", "sh64", "um", "h8300", "parisc", "s390", "v850", "avr32", "blackfin",
+ "loongarch64", "microblaze", "nios2", "arc", "riscv", "xtensa"]
+
+ if re.match('(i.86|athlon|x86.64)$', a): return 'x86'
+ elif re.match('arceb$', a): return 'arc'
+ elif re.match('armeb$', a): return 'arm'
+ elif re.match('aarch64$', a): return 'arm64'
+ elif re.match('aarch64_be$', a): return 'arm64'
+ elif re.match('aarch64_ilp32$', a): return 'arm64'
+ elif re.match('aarch64_be_ilp32$', a): return 'arm64'
+ elif re.match('loongarch(32|64|)$', a): return 'loongarch'
+ elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'mips'
+ elif re.match('mcf', a): return 'm68k'
+ elif re.match('riscv(32|64|)(eb|)$', a): return 'riscv'
+ elif re.match('p(pc|owerpc)(|64)', a): return 'powerpc'
+ elif re.match('sh(3|4)$', a): return 'sh'
+ elif re.match('bfin', a): return 'blackfin'
+ elif re.match('microblazee[bl]', a): return 'microblaze'
+ elif a in valid_archs: return a
+ else:
+ if not d.getVar("TARGET_OS").startswith("linux"):
+ return a
+ bb.error("cannot map '%s' to a linux kernel architecture" % a)
+
+def map_uboot_arch(d):
+ a = map_kernel_arch(d)
+
+ if re.match('p(pc|owerpc)(|64)', a): return 'ppc'
+ elif re.match('i.86$', a): return 'x86'
+ return a
+
# parse kernel ABI version out of <linux/version.h>
def get_version_headers(p):
fn = p + '/include/linux/utsrelease.h'
next prev parent reply other threads:[~2026-08-02 10:29 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 10:28 [PATCH 00/25] Class file improvements Richard Purdie
2026-08-02 10:28 ` [PATCH 01/25] sstatesig: Use kernel.bbclass instead of linux-kernel-base.bbclass Richard Purdie
2026-08-02 10:28 ` [PATCH 02/25] linux-kernel-base: Delete unused function Richard Purdie
2026-08-02 10:28 ` [PATCH 03/25] lib/oe/kernel: Move python functions from linux-kernel-base to library code Richard Purdie
2026-08-02 10:28 ` [PATCH 04/25] kernel-yocto: Simplify code for cleanliness and slight performance Richard Purdie
2026-08-02 10:28 ` Richard Purdie [this message]
2026-08-02 10:28 ` [PATCH 06/25] kernel-arch: Simplify KERNEL_ARCH variable usage Richard Purdie
2026-08-02 10:28 ` [PATCH 07/25] kernel-arch: Don't export UBOOT_ARCH Richard Purdie
2026-08-02 10:28 ` [PATCH 08/25] u-boot: Separate out from kernel-arch.bbclass Richard Purdie
2026-08-02 10:28 ` [PATCH 09/25] barebox: " Richard Purdie
2026-08-02 10:28 ` [PATCH 10/25] lib/oe/kernel: Simplify map_uboot_arch Richard Purdie
2026-08-02 10:28 ` [PATCH 11/25] image_types/kernel-uimage: Swap UBOOT_ARCH for oe.kernel.map_uboot_arch call Richard Purdie
2026-08-02 10:58 ` Patchtest results for " patchtest
2026-08-02 10:28 ` [PATCH 12/25] kernel-fit-image: " Richard Purdie
2026-08-02 10:28 ` [PATCH 13/25] linux-yocto-fitimage: Set UBOOT_ARCH Richard Purdie
2026-08-02 10:28 ` [PATCH 14/25] kernel-arch: Drop UBOOT_ARCH Richard Purdie
2026-08-02 10:28 ` [PATCH 15/25] linux-libc-headers: Drop kernel-arch and set ARCH directly Richard Purdie
2026-08-02 10:28 ` [PATCH 16/25] toolchain-scripts: Drop usage of kernel-arch Richard Purdie
2026-08-02 10:28 ` [PATCH 17/25] kernel-arch: Move ARCH usage into target classes Richard Purdie
2026-08-02 10:28 ` [PATCH 18/25] linux-yocto-fitimage: Drop obsolete dependency on linux-kernel-base Richard Purdie
2026-08-02 10:58 ` Patchtest results for " patchtest
2026-08-02 10:28 ` [PATCH 19/25] linux-kernel-base: Fold remainder into kernel-arch and drop Richard Purdie
2026-08-02 10:28 ` [PATCH 20/25] kernel-devicetree: Add missing function prefixes Richard Purdie
2026-08-02 10:28 ` [PATCH 21/25] utils: Drop explode_deps function Richard Purdie
2026-08-02 10:28 ` [PATCH 22/25] utils: Move functions from utils.bbclass to utils.py Richard Purdie
2026-08-02 10:58 ` Patchtest results for " patchtest
2026-08-02 10:28 ` [PATCH 23/25] lib/oe/lsb: Merge distro_identifier functions Richard Purdie
2026-08-02 10:28 ` [PATCH 24/25] sanity: Move code to lib/oe Richard Purdie
2026-08-02 10:58 ` Patchtest results for " patchtest
2026-08-02 10:28 ` [PATCH 25/25] sanity: Drop unreachable code Richard Purdie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260802102854.3952760-6-richard.purdie@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox