On 20.04 (qemu 4.2) the binaries built for qemu-user-static - specifically in the case I've hit /usr/bin/qemu-aarch64-static - are completely static executables. Although they don't link to other shared libraries they are dynamically linked to glibc and therefore require the same version of the glibc shared libraries at runtime. This breaks many uses in foreign architecture chroots; in my case an aarch64 being built with debootstrap:
$ file /usr/bin/qemu-aarch64-static
/usr/bin/qemu-aarch64-static: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=abad039a2cfc5bc87215554230a572b085fbc37a, for GNU/Linux 3.2.0, with debug_info, not stripped
$ apt list qemu-user-static
qemu-user-static/focal-updates,focal-security,now 1:4.2-3ubuntu6.10 amd64 [installed]
But recent builds of 5.2 are not; for example from hirsute (qemu-user-static_5.2+dfsg-2ubuntu1_amd64.deb)
$ file /tmp/qemu-aarch64-static
/tmp/qemu-aarch64-static: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=91fda2fa08f46d1bb6d19b6f72a4819a7c20fd7e, for GNU/Linux 3.2.0, stripped
I hit this whilst trying to track down another bug and building upstream git HEAD on 20.04 with:
$ ../../qemu/configure --disable-system --enable-linux-user --static --target-list=aarch64-linux-user
$ make
$ file qemu-aarch64
qemu-aarch64: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=546ba11f0de940f7f3cbfaffae3c2bb54b683386, for GNU/Linux 3.2.0, with debug_info, not stripped
It looks like changes to the qemu build system are responsible. I asked on OFTC #qemu and at that time no-one was particularly aware of the significance/difference.
Looking at the configure output summary between the focal and hirsute/upstream builds I noticed that there is no longer a separate summary for LDFLAGS - it now only reports QEMU_LDFLAGS.
That seems significant since focal passed "-static" with LDFLAGS not QEMU_LDFLAGS:
I've seen mention in qemu commit messages of the meson build system changes causing issues around passing of linker flags but it needs someone familiar with the project and build system to figure this out.
On 20.04 (qemu 4.2) the binaries built for qemu-user-static - specifically in the case I've hit /usr/bin/ qemu-aarch64- static - are completely static executables. Although they don't link to other shared libraries they are dynamically linked to glibc and therefore require the same version of the glibc shared libraries at runtime. This breaks many uses in foreign architecture chroots; in my case an aarch64 being built with debootstrap:
$ file /usr/bin/ qemu-aarch64- static qemu-aarch64- static: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[ sha1]=abad039a2 cfc5bc872155542 30a572b085fbc37 a, for GNU/Linux 3.2.0, with debug_info, not stripped
/usr/bin/
$ dpkg -S /usr/bin/ qemu-aarch64- static qemu-aarch64- static
qemu-user-static: /usr/bin/
$ apt list qemu-user-static static/ focal-updates, focal-security, now 1:4.2-3ubuntu6.10 amd64 [installed]
qemu-user-
But recent builds of 5.2 are not; for example from hirsute (qemu-user- static_ 5.2+dfsg- 2ubuntu1_ amd64.deb)
$ file /tmp/qemu- aarch64- static aarch64- static: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[ sha1]=91fda2fa0 8f46d1bb6d19b6f 72a4819a7c20fd7 e, for GNU/Linux 3.2.0, stripped
/tmp/qemu-
I hit this whilst trying to track down another bug and building upstream git HEAD on 20.04 with:
$ ../../qemu/ configure --disable-system --enable-linux-user --static --target- list=aarch64- linux-user sha1]=546ba11f0 de940f7f3cbfaff ae3c2bb54b68338 6, for GNU/Linux 3.2.0, with debug_info, not stripped
$ make
$ file qemu-aarch64
qemu-aarch64: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[
It looks like changes to the qemu build system are responsible. I asked on OFTC #qemu and at that time no-one was particularly aware of the significance/ difference.
Looking at the configure output summary between the focal and hirsute/upstream builds I noticed that there is no longer a separate summary for LDFLAGS - it now only reports QEMU_LDFLAGS.
That seems significant since focal passed "-static" with LDFLAGS not QEMU_LDFLAGS:
LDFLAGS -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g -Wl,-Bsymbolic- functions -Wl,-z,relro -Wl,--as-needed
QEMU_LDFLAGS
whereas hirsute shows:
QEMU_LDFLAGS: -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -m64 -g -O2 -fdebug- prefix- map=/<< BUILDDIR> >/qemu- 5.2+dfsg= . -fstack- protector- strong -Wformat -Werror= format- security -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-Bsymbolic- functions -Wl,-z,relro -Wl,--as-needed -fstack- protector- strong
I've seen mention in qemu commit messages of the meson build system changes causing issues around passing of linker flags but it needs someone familiar with the project and build system to figure this out.