qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Are user static builds really dynamically linked ?
@ 2020-12-16  6:27 Tj (Elloe Linux)
  2020-12-16 11:07 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Tj (Elloe Linux) @ 2020-12-16  6:27 UTC (permalink / raw)
  To: qemu-devel

user --static builds are apparently resulting in dynamically linked
executables (to the glibc library, not other shared objects )

Concise summary:

$ file ../qemu-aarch64_v*

../qemu-aarch64_v4.2.1: ELF 64-bit LSB executable, x86-64, version 1
(GNU/Linux), statically linked,
BuildID[sha1]=70f5e10ac0eb9b63d7758850e2f18d0a047d4b79, for GNU/Linux
3.2.0, with debug_info, not stripped

../qemu-aarch64_v5.2:   ELF 64-bit LSB shared object, x86-64, version 1
(GNU/Linux), dynamically linked,
BuildID[sha1]=91fda2fa08f46d1bb6d19b6f72a4819a7c20fd7e, for GNU/Linux
3.2.0, stripped

$ ldd  ../qemu-aarch64_v*

../qemu-aarch64_v4.2.1:
        not a dynamic executable
../qemu-aarch64_v5.2:
        statically linked


Between v4.2.1 and HEAD and (trying to) perform git-bisect builds using:

$ ../../qemu/configure --disable-system --enable-linux-user --static
--target-list=aarch64-linux-user

All builds from v5.x onwards report:

$ 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

Whereas builds of v4.2.1 report:

$ file ./aarch64-linux-user/qemu-aarch64
./aarch64-linux-user/qemu-aarch64: ELF 64-bit LSB executable, x86-64,
version 1 (GNU/Linux), statically linked,
BuildID[sha1]=70f5e10ac0eb9b63d7758850e2f18d0a047d4b79, for GNU/Linux
3.2.0, with debug_info, not stripped

... the same as the v4.2.0 built by Debian/Ubuntu:

$ 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



This could be a problem because when the executable is dynamically
linked to glibc the same glibc version needs to be installed in the
chroot and that isn't always possible.

I'm unsure whether this is a cosmetic issue of file/ldd reporting or is
a regression.

Hit this whilst in the process of trying to isolate commits that fixed
another issue where using qemu-aarch64 on x86_64 Debian/Ubuntu host with
a foreign architecture chroot that results in "handle_cpu_signal
received signal outside vCPU context" when doing "chroot
debian-buster-aarch64 aptitude full-upgrade".


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Are user static builds really dynamically linked ?
  2020-12-16  6:27 Are user static builds really dynamically linked ? Tj (Elloe Linux)
@ 2020-12-16 11:07 ` Peter Maydell
  2020-12-16 11:39   ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2020-12-16 11:07 UTC (permalink / raw)
  To: Tj (Elloe Linux); +Cc: Paolo Bonzini, QEMU Developers

On Wed, 16 Dec 2020 at 06:39, Tj (Elloe Linux) <ml.linux@elloe.vision> wrote:
>
> user --static builds are apparently resulting in dynamically linked
> executables (to the glibc library, not other shared objects )

I think you mean that you end up with an executable that's
dynamically linked but although it requires the dynamic
linker (ld.so) it has an empty list of dynamic libraries
(ie not even glibc).

> Concise summary:
>
> $ file ../qemu-aarch64_v*
>
> ../qemu-aarch64_v4.2.1: ELF 64-bit LSB executable, x86-64, version 1
> (GNU/Linux), statically linked,
> BuildID[sha1]=70f5e10ac0eb9b63d7758850e2f18d0a047d4b79, for GNU/Linux
> 3.2.0, with debug_info, not stripped
>
> ../qemu-aarch64_v5.2:   ELF 64-bit LSB shared object, x86-64, version 1
> (GNU/Linux), dynamically linked,
> BuildID[sha1]=91fda2fa08f46d1bb6d19b6f72a4819a7c20fd7e, for GNU/Linux
> 3.2.0, stripped
>
> $ ldd  ../qemu-aarch64_v*
>
> ../qemu-aarch64_v4.2.1:
>         not a dynamic executable
> ../qemu-aarch64_v5.2:
>         statically linked

Something has definitely changed here. What you had with 4.2.1
is what you should be getting. The obvious suspect is that
something weird happened in the meson conversion...

That said, there must be something specific to your setup which
is causing this. I just tried (on Ubuntu 18.04):

$ git clone  https://git.qemu.org/git/qemu.git
$ cd qemu
$ mkdir build
$ cd build
$ ../configure --disable-system --enable-linux-user --static
--target-list=aarch64-linux-user
$ make -j8

and 'file qemu-aarch64' says:
qemu-aarch64: ELF 64-bit LSB executable, x86-64, version 1
(GNU/Linux), statically linked, for GNU/Linux 3.2.0,
BuildID[sha1]=c3e1ffd0a2805a7043a40659ecbc7774cb42f7bf, with
debug_info, not stripped
and 'ldd qemu-aarch64' says:
        not a dynamic executable

as expected.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Are user static builds really dynamically linked ?
  2020-12-16 11:07 ` Peter Maydell
@ 2020-12-16 11:39   ` Paolo Bonzini
  2020-12-16 14:18     ` Tj (Elloe Linux)
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2020-12-16 11:39 UTC (permalink / raw)
  To: Peter Maydell, Tj (Elloe Linux); +Cc: QEMU Developers

On 16/12/20 12:07, Peter Maydell wrote:
> On Wed, 16 Dec 2020 at 06:39, Tj (Elloe Linux) <ml.linux@elloe.vision> wrote:
>>
>> user --static builds are apparently resulting in dynamically linked
>> executables (to the glibc library, not other shared objects )
> 
> I think you mean that you end up with an executable that's
> dynamically linked but although it requires the dynamic
> linker (ld.so) it has an empty list of dynamic libraries
> (ie not even glibc).
> 
>> Concise summary:
>>
>> $ file ../qemu-aarch64_v*
>>
>> ../qemu-aarch64_v4.2.1: ELF 64-bit LSB executable, x86-64, version 1
>> (GNU/Linux), statically linked,
>> BuildID[sha1]=70f5e10ac0eb9b63d7758850e2f18d0a047d4b79, for GNU/Linux
>> 3.2.0, with debug_info, not stripped
>>
>> ../qemu-aarch64_v5.2:   ELF 64-bit LSB shared object, x86-64, version 1
>> (GNU/Linux), dynamically linked,
>> BuildID[sha1]=91fda2fa08f46d1bb6d19b6f72a4819a7c20fd7e, for GNU/Linux
>> 3.2.0, stripped
>>
>> $ ldd  ../qemu-aarch64_v*
>>
>> ../qemu-aarch64_v4.2.1:
>>          not a dynamic executable
>> ../qemu-aarch64_v5.2:
>>          statically linked
> 
> Something has definitely changed here. What you had with 4.2.1
> is what you should be getting. The obvious suspect is that
> something weird happened in the meson conversion...

Please send the (gzipped) build.ninja file.

Paolo

> 
> That said, there must be something specific to your setup which
> is causing this. I just tried (on Ubuntu 18.04):
> 
> $ git clone  https://git.qemu.org/git/qemu.git
> $ cd qemu
> $ mkdir build
> $ cd build
> $ ../configure --disable-system --enable-linux-user --static
> --target-list=aarch64-linux-user
> $ make -j8
> 
> and 'file qemu-aarch64' says:
> qemu-aarch64: ELF 64-bit LSB executable, x86-64, version 1
> (GNU/Linux), statically linked, for GNU/Linux 3.2.0,
> BuildID[sha1]=c3e1ffd0a2805a7043a40659ecbc7774cb42f7bf, with
> debug_info, not stripped
> and 'ldd qemu-aarch64' says:
>          not a dynamic executable
> 
> as expected.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Are user static builds really dynamically linked ?
  2020-12-16 11:39   ` Paolo Bonzini
@ 2020-12-16 14:18     ` Tj (Elloe Linux)
  0 siblings, 0 replies; 4+ messages in thread
From: Tj (Elloe Linux) @ 2020-12-16 14:18 UTC (permalink / raw)
  To: qemu-devel

On 16/12/2020 11:39, Paolo Bonzini wrote:
> On 16/12/20 12:07, Peter Maydell wrote:
>> Something has definitely changed here. What you had with 4.2.1
>> is what you should be getting. The obvious suspect is that
>> something weird happened in the meson conversion...

Ubuntu/Debian maintainer reproduced and confirmed my findings. It's been
git-bisect-ed to the addition/use of -static-pie on 'supported'
architectures when calling configure with --static at commit 127814629b
"configure: Support -static-pie if requested".

Using --disable-pie works around it on x86_64 for us.

https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1908331

https://salsa.debian.org/qemu-team/qemu/-/merge_requests/16

> Please send the (gzipped) build.ninja file.

build.ninja archives with and without --disable-pie can be fetched from:

https://iam.tj/projects/qemu/


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-16 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-16  6:27 Are user static builds really dynamically linked ? Tj (Elloe Linux)
2020-12-16 11:07 ` Peter Maydell
2020-12-16 11:39   ` Paolo Bonzini
2020-12-16 14:18     ` Tj (Elloe Linux)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).