All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Fam Zheng <famz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	hjl.tools@gmail.com, Michael Tokarev <mjt@tls.msk.ru>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols
Date: Mon, 1 Sep 2014 11:59:07 +0100	[thread overview]
Message-ID: <CAFEAcA9T1NPpVe1UMCwKXSiaTFQaxzGt86vK1wT2_+72knvmCA@mail.gmail.com> (raw)
In-Reply-To: <1409567710-26217-1-git-send-email-famz@redhat.com>

On 1 September 2014 11:35, Fam Zheng <famz@redhat.com> wrote:
> This fixes an issue with module build system. block/iscsi.so is
> currently broken:
>
>     $ ~/build/last/qemu-img
>     Failed to open module: /home/fam/build/master/block-iscsi.so:
>     undefined symbol: qmp_query_uuid
>     qemu-img: Not enough arguments
>     Try 'qemu-img --help' for more information
>
> To fix this, we should (at least) let qemu-img link qmp_query_uuid from
> libqemustub.a. (There are a few other symbols missing, as well.)
>
> This patch changes the linking rules to:
>
> 1) Build ".mo" with "ld -r -o $@ $^" for each ".so", and later build .so
>    with it.
>
> 2) Always build all the .mo before linking the executables. This is
>    achieved by adding those .mo files to the executables' "-y"
>    variables.
>
> 3) When linking an executable, those .mo files in its "-y" variables are
>    filtered out, and replaced by one or more -Wl,-u,$symbol flags. This
>    is done in the added macro "process-archive-undefs".
>
>    These "-Wl,-u,$symbol" flags will force ld to pull in the function
>    definition from the archives when linking.
>
>    Note that the .mo objects, that are actually meant to be linked in
>    the executables, are already expanded in unnest-vars, before the
>    linking command. So we are safe to simply filter out .mo for the
>    purpose of pulling undefined symbols.
>
>    process-archive-undefs works as this: For each ".mo", find all the
>    undefined symbols in it, filter ones that are defined in the
>    archives. For each of these symbols, generate a "-Wl,-u,$symbol" in
>    the link command, and put them before archive names in the command
>    line.
>
> Suggested-by: H.J. Lu <hjl.tools@gmail.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>

This patch causes the build on MacOSX to spit out a bunch of
warnings every time we do a link:

warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm:
no name list
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm:
no name list
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm:
no name list
  LINK  qemu-nbd

> +find-symbols = $(if $1, $(sort $(shell nm -P -g $1 | $2)))
> +defined-symbols = $(call find-symbols,$1,awk '$$2!="U"{print $$1}')
> +undefined-symbols = $(call find-symbols,$1,awk '$$2=="U"{print $$1}')

Are you sure your nm invocations are portable?

thanks
-- PMM

  parent reply	other threads:[~2014-09-01 10:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-01 10:35 [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols Fam Zheng
2014-09-01 10:37 ` Paolo Bonzini
2014-09-01 10:59 ` Peter Maydell [this message]
2014-09-01 11:28   ` Paolo Bonzini
2014-09-01 11:46     ` Peter Maydell
2014-09-01 12:04       ` Paolo Bonzini
2014-09-01 12:07         ` Peter Maydell
2014-09-02  1:19           ` Fam Zheng
2014-09-02 12:07             ` Paolo Bonzini
2014-09-03  3:19               ` Fam Zheng

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=CAFEAcA9T1NPpVe1UMCwKXSiaTFQaxzGt86vK1wT2_+72knvmCA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=famz@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.