]> git.proxmox.com Git - mirror_qemu.git/commit - rules.mak
rules.mak: Fix DSO build by pulling in archive symbols
authorFam Zheng <famz@redhat.com>
Mon, 1 Sep 2014 10:35:10 +0000 (18:35 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 9 Sep 2014 11:13:05 +0000 (13:13 +0200)
commitc261d774fb9093d00e0938a19f502fb220f62718
tree181d3cb60edf8feba7ec792e2fcbfd2335999774
parent2ceee4b0521241eb8595a5501b54bb3534ebb99a
rules.mak: Fix DSO build by pulling in archive symbols

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>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rules.mak