Skip to contentSkip to conversation

qemu: split the native version into usermode and system parts

PATCH New Alexander Kanavin 1 participant 3 messages Feb 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 qemu: split the native version into usermode and system parts

The rationale is to streamline the overall build.

The system parts are only needed to run target images, and so can be built towards the end of the build process. At the same time, the system parts may need gtk+-native and mesa-native which add significantly to the build time.

On the other hand, the usermode parts have almost no dependencies and can be built quickly. They are needed at recipes build time to run target binaries, and so are required quite early in the typical build process.

---
 meta/conf/distro/include/no-static-libs.inc   |  1 +
 .../qemu/qemu-helper-native_1.0.bb            |  4 +-
 meta/recipes-devtools/qemu/qemu-native.inc    | 17 ++++
 .../qemu/qemu-native_3.1.0.bb                 |  9 ++
 .../qemu/qemu-system-native_3.1.0.bb          | 23 +++++
 meta/recipes-devtools/qemu/qemu-targets.inc   |  6 ++
 meta/recipes-devtools/qemu/qemu.inc           | 97 ++++++++++++-------
 meta/recipes-devtools/qemu/qemu_3.1.0.bb      | 68 +++----------
 8 files changed, 134 insertions(+), 91 deletions(-)
 create mode 100644 meta/recipes-devtools/qemu/qemu-native.inc
 create mode 100644 meta/recipes-devtools/qemu/qemu-native_3.1.0.bb
 create mode 100644 meta/recipes-devtools/qemu/qemu-system-native_3.1.0.bb
meta/conf/distro/include/no-static-libs.inc +1 -0
index cdc53916d07..712d858dc0d 100644
@@ -4,6 +4,7 @@ DISABLE_STATIC ?= " --disable-static"
 DISABLE_STATIC_pn-qemu = ""
 DISABLE_STATIC_pn-qemu-native = ""
 DISABLE_STATIC_pn-nativesdk-qemu = ""
+DISABLE_STATIC_pn-qemu-system-native = ""
 # pciutils fails build
 DISABLE_STATIC_pn-pciutils = ""
 # libcap aborts on unrecognised option
meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb +2 -2
index d86b1551762..d9d9da0fade 100644
@@ -1,6 +1,6 @@
 SUMMARY = "Helper utilities needed by the runqemu script"
 LICENSE = "GPLv2"
-RDEPENDS_${PN} = "qemu-native"
+RDEPENDS_${PN} = "qemu-system-native"
 PR = "r1"
 
 LIC_FILES_CHKSUM = "file://${WORKDIR}/tunctl.c;endline=4;md5=ff3a09996bc5fff6bc5d4e0b4c28f999"
@@ -20,5 +20,5 @@ do_install() {
 	install tunctl ${D}${bindir}/
 }
 
-DEPENDS += "qemu-native"
+DEPENDS += "qemu-system-native"
 addtask addto_recipe_sysroot after do_populate_sysroot before do_build
meta/recipes-devtools/qemu/qemu-native.inc new file +17 -0
new file mode 100644
index 00000000000..4373ad9e63a
@@ -0,0 +1,17 @@
+inherit native
+
+require qemu.inc
+
+SRC_URI_append = " \
+            file://0012-fix-libcap-header-issue-on-some-distro.patch \
+            file://0013-cpus.c-Add-error-messages-when-qemi_cpu_kick_thread-.patch \
+            "
+EXTRA_OECONF_append = " --python=python2.7"
+
+EXTRA_OEMAKE_append = " LD='${LD}' AR='${AR}' OBJCOPY='${OBJCOPY}' LDFLAGS='${LDFLAGS}'"
+
+LDFLAGS_append = " -fuse-ld=bfd"
+
+do_install_append() {
+     ${@bb.utils.contains('PACKAGECONFIG', 'gtk+', 'make_qemu_wrapper', '', d)}
+}
meta/recipes-devtools/qemu/qemu-native_3.1.0.bb new file +9 -0
new file mode 100644
index 00000000000..c8acff8e196
@@ -0,0 +1,9 @@
+BPN = "qemu"
+
+DEPENDS = "glib-2.0-native zlib-native"
+
+require qemu-native.inc
+
+EXTRA_OECONF_append = " --target-list=${@get_qemu_usermode_target_list(d)} --disable-tools --disable-blobs --disable-guest-agent"
+
+PACKAGECONFIG ??= ""
meta/recipes-devtools/qemu/qemu-system-native_3.1.0.bb new file +23 -0
new file mode 100644
index 00000000000..5bf528bec12
@@ -0,0 +1,23 @@
+BPN = "qemu"
+
+require qemu-native.inc
+
+# As some of the files installed by qemu-native and qemu-system-native 
+# are the same, we depend on qemu-native to get the full installation set
+# and avoid file clashes
+DEPENDS = "glib-2.0-native zlib-native pixman-native qemu-native"
+
+EXTRA_OECONF_append = " --target-list=${@get_qemu_system_target_list(d)}"
+
+PACKAGECONFIG ??= "fdt alsa kvm"
+
+# Handle distros such as CentOS 5 32-bit that do not have kvm support
+PACKAGECONFIG_remove = "${@'kvm' if not os.path.exists('/usr/include/linux/kvm.h') else ''}"
+
+do_install_append() {
+    install -Dm 0755 ${WORKDIR}/powerpc_rom.bin ${D}${datadir}/qemu
+
+    # The following is also installed by qemu-native
+    rm -f ${D}${datadir}/qemu/trace-events-all
+    rm -rf ${D}${datadir}/qemu/keymaps
+}
meta/recipes-devtools/qemu/qemu-targets.inc +6 -0
index a7d7b5f7084..550d6f0ab1e 100644
@@ -20,3 +20,9 @@ def get_qemu_target_list(d):
     if 'linux' not in tos:
         return softmmuonly + ''.join([arch + "-softmmu" + "," for arch in archs]).rstrip(',')
     return softmmuonly + linuxuseronly + ''.join([arch + "-linux-user" + "," + arch + "-softmmu" + "," for arch in archs]).rstrip(',')
+
+def get_qemu_usermode_target_list(d):
+    return ",".join(filter(lambda i: "-linux-user" in i, get_qemu_target_list(d).split(',')))
+
+def get_qemu_system_target_list(d):
+    return ",".join(filter(lambda i: "-linux-user" not in i, get_qemu_target_list(d).split(',')))
meta/recipes-devtools/qemu/qemu.inc +60 -37

127 lines not on this page · raw message

meta/recipes-devtools/qemu/qemu_3.1.0.bb +16 -52

74 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/3 python3: depend on qemu-native, not qemu-helper-native

qemu-helper-native would erroneously pull in the qemu system parts, where we only want usermode parts for pgo.

---
 meta/recipes-devtools/python/python3_3.7.2.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/python/python3_3.7.2.bb +1 -1
index 4a1cbae8670..9626ee546b2 100644
@@ -72,7 +72,7 @@ PACKAGECONFIG_class-native ??= "readline"
 PACKAGECONFIG_class-nativesdk ??= "readline"
 PACKAGECONFIG[readline] = ",,readline"
 # Use profile guided optimisation by running PyBench inside qemu-user
-PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-helper-native"
+PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native"
 PACKAGECONFIG[tk] = ",,tk"
 
 CPPFLAGS_append = " -I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid"
Signature · 1 line
2.17.1
#2 lore raw

PATCH 3/3 local.conf.sample: adjust the qemu configuration to refer to qemu-system-native

In reply to Alexander Kanavin
---
 meta-poky/conf/local.conf.sample | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-poky/conf/local.conf.sample +1 -1
index 267108d6850..9068e567dcd 100644
@@ -241,7 +241,7 @@ BB_DISKMON_DIRS ??= "\
 # seen. The two lines below enable the SDL backend too. By default libsdl2-native will
 # be built, if you want to use your host's libSDL instead of the minimal libsdl built
 # by libsdl2-native then uncomment the ASSUME_PROVIDED line below.
-PACKAGECONFIG_append_pn-qemu-native = " sdl"
+PACKAGECONFIG_append_pn-qemu-system-native = " sdl"
 PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
 #ASSUME_PROVIDED += "libsdl2-native"
 
Signature · 1 line
2.17.1