build: replace weak symbols with a static library
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 16 Nov 2012 17:35:27 +0000 (18:35 +0100)
committerBlue Swirl <blauwirbel@gmail.com>
Sun, 18 Nov 2012 19:19:23 +0000 (19:19 +0000)
commit3bc2f570ec9fc930619a8ef26a22dd6d03c25dac
treeec92ca7ecc6b9da1c5c8f18e52e6498e42908f50
parent2c5c4451e69a69c0fad3303c25cc7eaad6950f79
build: replace weak symbols with a static library

Weak symbols were a nice idea, but they turned out not to be a good one.
Toolchain support is just too sparse, in particular llvm-gcc is totally
broken.

This patch uses a surprisingly low-tech approach: a static library.
Symbols in a static library are always overridden by symbols in an
object file.  Furthermore, if you place each function in a separate
source file, object files for unused functions will not be taken in.
This means that each function can use all the dependencies that it needs
(especially QAPI stuff such as error_setg).

Thus, all stubs are placed in separate object files and put together in
a static library.  The library then is linked to all programs.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
18 files changed:
Makefile
Makefile.objs
Makefile.target
compiler.h
osdep.c
oslib-win32.c
qemu-sockets.c
qmp.c
rules.mak
stubs/Makefile.objs [new file with mode: 0644]
stubs/arch-query-cpu-def.c [new file with mode: 0644]
stubs/fd-register.c [new file with mode: 0644]
stubs/fdset-add-fd.c [new file with mode: 0644]
stubs/fdset-find-fd.c [new file with mode: 0644]
stubs/fdset-get-fd.c [new file with mode: 0644]
stubs/fdset-remove-fd.c [new file with mode: 0644]
stubs/get-fd.c [new file with mode: 0644]
stubs/set-fd-handler.c [new file with mode: 0644]