Skip to content

Commit

Permalink
Re-enable qemu-user-static builds
Browse files Browse the repository at this point in the history
Static builds were failing due to incorrect build flags in
glibc 2.35.

See https://sourceware.org/bugzilla/show_bug.cgi?id=29514.
  • Loading branch information
ewlsh committed Sep 27, 2023
1 parent f3e3198 commit 4942f9c
Showing 1 changed file with 83 additions and 4 deletions.
87 changes: 83 additions & 4 deletions extra/qemu/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

# ALARM: Kevin Mihelich <[email protected]>
# - remove makedepends on seabios, revert not installing qemu seabios files
# ALARM: Qu Wenruo <[email protected]>
# - remove static build, make qemu-base/qemu-desktop meta packages to use their native system emulator as default dependency

pkgbase=qemu
pkgname=(
Expand All @@ -25,7 +23,7 @@ pkgname=(
qemu-tests
qemu-tools
qemu-ui-{curses,dbus,egl-headless,gtk,opengl,sdl,spice-{app,core}}
qemu-user{,-binfmt}
qemu-user{,-static}{,-binfmt}
qemu-vhost-user-gpu
qemu-{base,desktop,emulators-full,full}
)
Expand Down Expand Up @@ -280,6 +278,7 @@ prepare() {

# create build dir
mkdir -vp build
mkdir -vp build-static
}

build() {
Expand All @@ -300,6 +299,51 @@ build() {
--with-coroutine=ucontext
)

local configure_static_options=(
"${common_configure_options[@]}"
--enable-attr
--enable-linux-user
--enable-tcg
--disable-bpf
--disable-bsd-user
--disable-capstone
--disable-docs
--disable-fdt
--disable-gcrypt
--disable-glusterfs
--disable-gnutls
--disable-gtk
--disable-install-blobs
--disable-kvm
--disable-libiscsi
--disable-libnfs
--disable-libssh
--disable-linux-io-uring
--disable-nettle
--disable-opengl
--disable-qom-cast-debug
--disable-sdl
--disable-system
--disable-tools
--disable-tpm
--disable-vde
--disable-vhost-crypto
--disable-vhost-kernel
--disable-vhost-net
--disable-vhost-user
--disable-vnc
--disable-werror
--disable-xen
--disable-zstd
--static
)

(
cd build-static
../$pkgbase-$pkgver/configure "${configure_static_options[@]}"
ninja
)

(
cd build
../$pkgbase-$pkgver/configure "${configure_options[@]}"
Expand All @@ -324,6 +368,23 @@ package_qemu-common() {
)
install=$pkgname.install

# install static binaries
meson install -C build-static --destdir "$pkgdir"
install -vdm 755 "$pkgdir/usr/lib/binfmt.d/"
$pkgbase-$pkgver/scripts/qemu-binfmt-conf.sh "${binfmt_conf_options[@]}"

# rename static binaries to prevent name conflicts
for _src in "$pkgdir/usr/bin/qemu-"*; do
mv -v "$_src" "$pkgdir/usr/bin/$(basename "$_src")-static"
done
# modify and rename binfmt.d configs to prevent name conflicts
for _conf in "$pkgdir/usr/lib/binfmt.d/"*; do
_exe_name="$(basename "${_conf/.conf/}")"
_new_exe_name="${_exe_name}-static"
_new_conf_name="${_conf/.conf/-static.conf}"
sed -e "s|usr/bin/${_exe_name}|usr/bin/${_new_exe_name}|" "$_conf" > "${_new_conf_name}"
done

# install default binaries
meson install -C build --destdir "$pkgdir"

Expand Down Expand Up @@ -513,6 +574,9 @@ package_qemu-common() {
_pick qemu-ui-spice-app usr/lib/qemu/ui-spice-app.so
_pick qemu-ui-spice-core usr/lib/qemu/ui-spice-core.so

_pick qemu-user-static usr/bin/qemu-*-static
_pick qemu-user-static-binfmt usr/lib/binfmt.d/*-static.conf

_pick qemu-user usr/bin/qemu-{aarch64{,_be},alpha,arm{,eb},cris,hexagon,hppa,i386,loongarch64,m68k,microblaze{,el},mips{,64,64el,el,n32,n32el},nios2,or1k,ppc{,64,64le},riscv{32,64},s390x,sh4{,eb},sparc{,32plus,64},x86_64,xtensa{,eb}}
_pick qemu-user-binfmt usr/lib/binfmt.d/*.conf

Expand Down Expand Up @@ -852,7 +916,7 @@ package_qemu-system-tricore() {

package_qemu-system-x86() {
pkgdesc="QEMU system emulator for x86"
depends=("${_qemu_system_deps[@]}" edk2-ovmf qemu-system-x86-firmware=$pkgver-$pkgrel seabios systemd-libs libudev.so)
depends=("${_qemu_system_deps[@]}" qemu-system-x86-firmware=$pkgver-$pkgrel systemd-libs libudev.so)
mv -v $pkgname/* "$pkgdir"
}

Expand Down Expand Up @@ -991,6 +1055,21 @@ package_qemu-user-binfmt() {
mv -v $pkgname/* "$pkgdir"
}

package_qemu-user-static() {
pkgdesc="QEMU static user mode emulation"
depends=(glibc)
optdepends=('qemu-user-static-binfmt: for binary format rules')
mv -v $pkgname/* "$pkgdir"
}

package_qemu-user-static-binfmt() {
pkgdesc="Binary format rules for QEMU static user mode emulation"
depends=(qemu-user-static=$pkgver-$pkgrel)
provides=(qemu-user-binfmt-provider)
conflicts=(qemu-user-binfmt-provider)
mv -v $pkgname/* "$pkgdir"
}

package_qemu-vhost-user-gpu() {
pkgdesc="QEMU vhost-user-gpu display device"
depends=(gcc-libs glib2 libglib-2.0.so libgmodule-2.0.so glibc pixman libepoxy libpixman-1.so mesa numactl libnuma.so qemu-common=$pkgver-$pkgrel virglrenderer)
Expand Down

0 comments on commit 4942f9c

Please sign in to comment.