[PATCH 1/1] multiarch: inject native variants of preferred providers

2 views
Skip to first unread message

Felix Moessbauer

unread,
Oct 17, 2025, 4:54:16 AM (yesterday) Oct 17
to isar-...@googlegroups.com, adriaan...@siemens.com, Felix Moessbauer, Jan Kiszka
We already create multiarch variants of our recipes in case the host and
target arch are not the same. However, this currently breaks when
combining with PREFERRED_PROVIDERS, as no entries for the -native
variantes are created. By that, bitbake bails out with the following
error:
Multiple .bb files are due to be built which each provide
<recipe>-native.

We fix this by injecting the -native variants for all preferred
providers as well (but only in case no explicit one is provided for the
-native variant). This needs to be done after config parsing (hence in
base.bblcass), as the PREFERRED_PROVIDERS are already used at recipe
parsing time (where multiarch.bbclass is loaded).

Fixes: 5a7c2f70 ("handle DPKG_ARCH=all case for transitive deps")
Reported-by: Jan Kiszka <jan.k...@siemens.com>
Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
---
Note, that this can be tested on isar-cip-core, but requires the other
fix in "image: Fix construction of do_image_tools dependencies" as well.

meta/classes/base.bbclass | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 90fd570c..471442e5 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -62,6 +62,30 @@ def get_deb_host_arch():
HOST_ARCH ??= "${@get_deb_host_arch()}"
HOST_DISTRO ??= "${DISTRO}"

+# Inject the PREFERRED_PROVIDERs for multiarch variants. This corresponds to
+# the multiarch_virtclass_handler logic in multiarch.bbclass, but needs to be
+# done prior to recipe parsing.
+def inject_preferred_providers(provider, suffix, d):
+ PP_PREFIX = 'PREFERRED_PROVIDER_'
+ if provider.endswith(suffix):
+ return
+ prefp_value = d.getVar(PP_PREFIX + provider)
+ if prefp_value and not d.getVar(PP_PREFIX + provider + suffix):
+ d.setVar(PP_PREFIX + provider + suffix, prefp_value + suffix)
+
+python multiarch_preferred_providers_handler() {
+ if d.getVar('HOST_ARCH') == d.getVar('DISTRO_ARCH'):
+ return
+
+ pref_vars = {var: e.data.getVar(var)
+ for var in e.data.keys()
+ if var.startswith('PREFERRED_PROVIDER_')}
+ for p in pref_vars:
+ inject_preferred_providers(p.replace('PREFERRED_PROVIDER_', ''), '-native', e.data)
+}
+addhandler multiarch_preferred_providers_handler
+multiarch_preferred_providers_handler[eventmask] = "bb.event.ConfigParsed"
+
die() {
bbfatal "$*"
}
--
2.51.0

Jan Kiszka

unread,
Oct 17, 2025, 5:09:16 AM (yesterday) Oct 17
to Felix Moessbauer, isar-...@googlegroups.com, adriaan...@siemens.com
Works well.

Tested-by: Jan Kiszka <jan.k...@siemens.com>

I suppose we should do the same for PREFERRED_VERSION, and also for
-kbuildtarget of self-built kernels.

Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center
Reply all
Reply to author
Forward
0 new messages