diff mbox series

qemu: Restrict the built qemu targets

Message ID 20230526142746.3220960-1-mingli.yu@eng.windriver.com
State New
Headers show
Series qemu: Restrict the built qemu targets | expand

Commit Message

mingli.yu@eng.windriver.com May 26, 2023, 2:27 p.m. UTC
From: Mingli Yu <mingli.yu@windriver.com>

Now the QEMU_TARGETS used to set the supported built qemu targets
both for "bitbake qemu-native" and "bitbake qemu".

After the qemu package installed on the target, it will take up
464M which includes not only the one matches the arch of the target
but aslo all available built qemu targets which set by QEMU_TARGETS.

Making "bitbake qemu" to only build the arch matches the target should
satisfy our usual need and ease the concerns who cares much about the
size in embedded device as it decreases the qemu rpm size from about 65M
to about 17M and the size of the extracted qemu RPM decreased from
about 464M to about 248M.

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
 meta/recipes-devtools/qemu/qemu-targets.inc | 15 +++++++++++++--
 meta/recipes-devtools/qemu/qemu_8.0.0.bb    |  2 +-
 2 files changed, 14 insertions(+), 3 deletions(-)

Comments

Alexander Kanavin May 26, 2023, 2:39 p.m. UTC | #1
I can't agree with this. The whole point of qemu is that it can
emulate any target on any other target. If you would like to trim it
down, can this be configured via PACKAGECONFIG, and off by default?

Alex

On Fri, 26 May 2023 at 16:27, Yu, Mingli <mingli.yu@eng.windriver.com> wrote:
>
> From: Mingli Yu <mingli.yu@windriver.com>
>
> Now the QEMU_TARGETS used to set the supported built qemu targets
> both for "bitbake qemu-native" and "bitbake qemu".
>
> After the qemu package installed on the target, it will take up
> 464M which includes not only the one matches the arch of the target
> but aslo all available built qemu targets which set by QEMU_TARGETS.
>
> Making "bitbake qemu" to only build the arch matches the target should
> satisfy our usual need and ease the concerns who cares much about the
> size in embedded device as it decreases the qemu rpm size from about 65M
> to about 17M and the size of the extracted qemu RPM decreased from
> about 464M to about 248M.
>
> Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> ---
>  meta/recipes-devtools/qemu/qemu-targets.inc | 15 +++++++++++++--
>  meta/recipes-devtools/qemu/qemu_8.0.0.bb    |  2 +-
>  2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/meta/recipes-devtools/qemu/qemu-targets.inc b/meta/recipes-devtools/qemu/qemu-targets.inc
> index 24f9a03948..bd0b47a4e7 100644
> --- a/meta/recipes-devtools/qemu/qemu-targets.inc
> +++ b/meta/recipes-devtools/qemu/qemu-targets.inc
> @@ -3,9 +3,20 @@
>  #    mips mipsel mips64 mips64el ppc ppc64 ppc64abi32 ppcemb
>  #    riscv32 riscv64 sparc sparc32 sparc32plus
>
> -def get_qemu_target_list(d):
> +def get_qemu_target_list(d, target=False):
>      import bb
> -    archs = d.getVar('QEMU_TARGETS').split()
> +    if target:
> +        archs = []
> +        allarchs = d.getVar('QEMU_TARGETS').split()
> +        if d.getVar("TARGET_ARCH") in ["x86", "i486", "i586", "i686"]:
> +            machine_arch = "i386"
> +        else:
> +            machine_arch = d.getVar("TARGET_ARCH")
> +        for arch in allarchs:
> +            if arch in machine_arch:
> +                archs.append(arch)
> +    else:
> +        archs = d.getVar('QEMU_TARGETS').split()
>      tos = d.getVar('HOST_OS')
>      softmmuonly = ""
>      for arch in ['ppcemb', 'lm32']:
> diff --git a/meta/recipes-devtools/qemu/qemu_8.0.0.bb b/meta/recipes-devtools/qemu/qemu_8.0.0.bb
> index 42e133967e..6c25d99ade 100644
> --- a/meta/recipes-devtools/qemu/qemu_8.0.0.bb
> +++ b/meta/recipes-devtools/qemu/qemu_8.0.0.bb
> @@ -10,7 +10,7 @@ CFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'x11', '', '-DEGL_NO_X11=1',
>
>  RDEPENDS:${PN}:class-target += "bash"
>
> -EXTRA_OECONF:append:class-target = " --target-list=${@get_qemu_target_list(d)}"
> +EXTRA_OECONF:append:class-target = " --target-list=${@get_qemu_target_list(d, target=True)}"
>  EXTRA_OECONF:append:class-target:mipsarcho32 = "${@bb.utils.contains('BBEXTENDCURR', 'multilib', ' --disable-capstone', '', d)}"
>  EXTRA_OECONF:append:class-nativesdk = " --target-list=${@get_qemu_target_list(d)}"
>
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#181773): https://lists.openembedded.org/g/openembedded-core/message/181773
> Mute This Topic: https://lists.openembedded.org/mt/99150807/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-devtools/qemu/qemu-targets.inc b/meta/recipes-devtools/qemu/qemu-targets.inc
index 24f9a03948..bd0b47a4e7 100644
--- a/meta/recipes-devtools/qemu/qemu-targets.inc
+++ b/meta/recipes-devtools/qemu/qemu-targets.inc
@@ -3,9 +3,20 @@ 
 #    mips mipsel mips64 mips64el ppc ppc64 ppc64abi32 ppcemb
 #    riscv32 riscv64 sparc sparc32 sparc32plus
 
-def get_qemu_target_list(d):
+def get_qemu_target_list(d, target=False):
     import bb
-    archs = d.getVar('QEMU_TARGETS').split()
+    if target:
+        archs = []
+        allarchs = d.getVar('QEMU_TARGETS').split()
+        if d.getVar("TARGET_ARCH") in ["x86", "i486", "i586", "i686"]:
+            machine_arch = "i386"
+        else:
+            machine_arch = d.getVar("TARGET_ARCH")
+        for arch in allarchs:
+            if arch in machine_arch:
+                archs.append(arch)
+    else:
+        archs = d.getVar('QEMU_TARGETS').split()
     tos = d.getVar('HOST_OS')
     softmmuonly = ""
     for arch in ['ppcemb', 'lm32']:
diff --git a/meta/recipes-devtools/qemu/qemu_8.0.0.bb b/meta/recipes-devtools/qemu/qemu_8.0.0.bb
index 42e133967e..6c25d99ade 100644
--- a/meta/recipes-devtools/qemu/qemu_8.0.0.bb
+++ b/meta/recipes-devtools/qemu/qemu_8.0.0.bb
@@ -10,7 +10,7 @@  CFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'x11', '', '-DEGL_NO_X11=1',
 
 RDEPENDS:${PN}:class-target += "bash"
 
-EXTRA_OECONF:append:class-target = " --target-list=${@get_qemu_target_list(d)}"
+EXTRA_OECONF:append:class-target = " --target-list=${@get_qemu_target_list(d, target=True)}"
 EXTRA_OECONF:append:class-target:mipsarcho32 = "${@bb.utils.contains('BBEXTENDCURR', 'multilib', ' --disable-capstone', '', d)}"
 EXTRA_OECONF:append:class-nativesdk = " --target-list=${@get_qemu_target_list(d)}"