From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Peter Maydell <peter.maydell@linaro.org>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Subject: Re: Linker failures trying to build static qemu-user binary
Date: Fri, 10 Feb 2023 00:33:44 +0100 [thread overview]
Message-ID: <694693aeffdf74cd30aa46aa925a67616c2ee169.camel@linux.ibm.com> (raw)
In-Reply-To: <CAFEAcA-Le_YbaYn6i15EesDMan+OF0S7uteanSXrWYK37HbdvQ@mail.gmail.com>
On Thu, 2023-02-09 at 14:14 +0000, Peter Maydell wrote:
> On Thu, 9 Feb 2023 at 13:54, John Paul Adrian Glaubitz
> <glaubitz@physik.fu-berlin.de> wrote:
> >
> > Hi!
> >
> > I usually build a static qemu-user binary from the git source using
> > the following
> > configure line:
> >
> > export ARCH=m68k && ./configure --target-list=$ARCH-linux-user --
> > static --disable-rdma \
> > --disable-pie --disable-system --disable-xen --
> > disable-pvrdma \
> > --disable-libssh --disable-werror --disable-
> > glusterfs
> >
> > However, that stopped working some time ago with the linker error
> > below.
> >
> > Does anyone know how to fix this?
>
> The "Using getpwuid in statically linked applications" etc warnings
> are expected, so we can ignore those; this is the key error:
>
> > /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libdw.a(debuginfod-
> > client.o): in function `__libdwfl_debuginfod_init':
> > (.text.startup+0x17): undefined reference to `dlopen'
> > /usr/bin/ld: (.text.startup+0x32): undefined reference to `dlsym'
> > /usr/bin/ld: (.text.startup+0x4b): undefined reference to `dlsym'
> > /usr/bin/ld: (.text.startup+0x64): undefined reference to `dlsym'
> > /usr/bin/ld: (.text.startup+0x7d): undefined reference to `dlsym'
> > /usr/bin/ld: (.text.startup+0xdc): undefined reference to `dlclose'
> > collect2: error: ld returned 1 exit status
>
> We use pkg-config to find out what the libdw library needs on
> the compiler/linker command line to link successfully, so
> maybe your distro's pkg-config info isn't right. What does
> "pkg-config --static --libs libdw" say ? If libdw needs libdl
> then it ought to list it in that output, I think. IME pkg-config
> information is often incorrect for static linking, though.
> I guess this one happened to work previously because glibc didn't
> actually mandate linking with '-ldl', and now on your system it
> apparently does. On my system pkg-config says
> -ldw -lbz2 -llzma -pthread -lpthread -lelf -lz
> which looks like it's missing -ldl, but the link succeeds anyway,
> presumably because the symbols are provided by the main glibc .a.
>
> On the other hand, if libdw wants to use dlopen/dlsym then
> I wonder if we should just suppress it for static linking:
> on my (Ubuntu 22.04) ld warns:
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libdw.a(debuginfod-client.o):
> in function `__libdwfl_debuginfod_init':
> (.text.startup+0x1b): warning: Using 'dlopen' in statically linked
> applications requires at runtime the shared libraries from the glibc
> version used for linking
>
> so whatever libdw is trying to do will likely not work in most
> statically-linked situations anyway.
>
> I've cc'd the author of the commit that added the libdw
> dependency.
>
> thanks
> -- PMM
Hi,
libdw uses dlopen() and friends for debuginfod integration, which QEMU
does not currently use. So in principle --extra-ldflags="-ldl"
should be safe.
That said, the functionality provided by libdw is needed for analyzing
performance of JITed code, which is mostly useful to developers and
researchers. Therefore, in order to avoid unpleasant surprises for
people who don't need this, I will send a patch that disables libdw
for static builds.
Best regards,
Ilya
prev parent reply other threads:[~2023-02-09 23:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 13:53 Linker failures trying to build static qemu-user binary John Paul Adrian Glaubitz
2023-02-09 14:14 ` Peter Maydell
2023-02-09 14:21 ` John Paul Adrian Glaubitz
2023-02-09 14:23 ` Peter Maydell
2023-02-09 14:25 ` John Paul Adrian Glaubitz
2023-02-09 23:33 ` Ilya Leoshkevich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=694693aeffdf74cd30aa46aa925a67616c2ee169.camel@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).