[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archi
From: |
Peter Maydell |
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 |
On 1 September 2014 11:35, Fam Zheng <address@hidden> 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 <address@hidden>
> Signed-off-by: Fam Zheng <address@hidden>
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
- [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols, Fam Zheng, 2014/09/01
- Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols, Paolo Bonzini, 2014/09/01
- Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols,
Peter Maydell <=
- Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols, Paolo Bonzini, 2014/09/01
- Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols, Peter Maydell, 2014/09/01
- Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols, Paolo Bonzini, 2014/09/01
- Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols, Peter Maydell, 2014/09/01
- Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols, Fam Zheng, 2014/09/01
- Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols, Paolo Bonzini, 2014/09/02
- Re: [Qemu-devel] [PATCH v2] rules.mak: Fix DSO build by pulling in archive symbols, Fam Zheng, 2014/09/02