Skip to contentSkip to conversation

kernel.bbclass: Set CROSS_COMPILE_COMPAT

RFC PATCH New Richard Weinberger 1 participant 2 messages Feb 7, 2024

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 kernel.bbclass: Set CROSS_COMPILE_COMPAT

To be able to build with CONFIG_COMPAT_VDSO=y on arm64 an arm32 toolchain is needed by the kernel build system.

This patch implements the necessary logic to locate the arm32 toolchain in an arm64 multilib environment.

---
Hi!

This is the least ugly version I came up so far,
please tell me what you think.

Thanks,
//richard

P.s: I tested this only on Kirkstone, yet.

---
 meta/classes-recipe/kernel.bbclass | 33 ++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
meta/classes-recipe/kernel.bbclass +33 -0
index a76aaee5bac4..9a0e95bb1925 100644
@@ -208,6 +208,39 @@ PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
 PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
 PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
 
+def get_arm32_prefix(d):
+    arm_prefix = ''
+
+    if d.getVar('TARGET_ARCH').startswith('aarch64'):
+        pfxs = all_multilib_tune_values(d, 'TARGET_PREFIX').split()
+        for p in pfxs:
+           if p.startswith("arm-"):
+               arm_prefix = p
+
+    return arm_prefix
+
+def arm32_full_prefix(d):
+    pfx = get_arm32_prefix(d)
+    if pfx == '':
+        return ''
+
+    ps = all_multilib_tune_values(d, 'STAGING_BINDIR_TOOLCHAIN').split()
+    for p in ps:
+        if p.endswith(pfx[:-1]):
+            return p + '/' + pfx
+
+    return ''
+
+def arm32_gcc_dep(d):
+    pfx = get_arm32_prefix(d)
+    if pfx != '':
+        return 'virtual/lib32-' + pfx + 'gcc'
+    else:
+        return ''
+
+DEPENDS += "${@arm32_gcc_dep(d)}"
+export CROSS_COMPILE_COMPAT="${@arm32_full_prefix(d)}"
+
 export OS = "${TARGET_OS}"
 export CROSS_COMPILE = "${TARGET_PREFIX}"
 
Signature · 1 line
2.26.2
#1 lore raw

RFC PATCH 1/1 kernel.bbclass: Set CROSS_COMPILE_COMPAT

To be able to build with CONFIG_COMPAT_VDSO=y on arm64 an arm32 toolchain is needed by the kernel build system.

This patch implements the necessary logic to locate the arm32 toolchain in an arm64 multilib environment.

---
 meta/classes-recipe/kernel.bbclass | 33 ++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
meta/classes-recipe/kernel.bbclass +33 -0
index a76aaee5bac4..9a0e95bb1925 100644
@@ -208,6 +208,39 @@ PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
 PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
 PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
 
+def get_arm32_prefix(d):
+    arm_prefix = ''
+
+    if d.getVar('TARGET_ARCH').startswith('aarch64'):
+        pfxs = all_multilib_tune_values(d, 'TARGET_PREFIX').split()
+        for p in pfxs:
+           if p.startswith("arm-"):
+               arm_prefix = p
+
+    return arm_prefix
+
+def arm32_full_prefix(d):
+    pfx = get_arm32_prefix(d)
+    if pfx == '':
+        return ''
+
+    ps = all_multilib_tune_values(d, 'STAGING_BINDIR_TOOLCHAIN').split()
+    for p in ps:
+        if p.endswith(pfx[:-1]):
+            return p + '/' + pfx
+
+    return ''
+
+def arm32_gcc_dep(d):
+    pfx = get_arm32_prefix(d)
+    if pfx != '':
+        return 'virtual/lib32-' + pfx + 'gcc'
+    else:
+        return ''
+
+DEPENDS += "${@arm32_gcc_dep(d)}"
+export CROSS_COMPILE_COMPAT="${@arm32_full_prefix(d)}"
+
 export OS = "${TARGET_OS}"
 export CROSS_COMPILE = "${TARGET_PREFIX}"
 
Signature · 1 line
2.26.2