From 3bc2f570ec9fc930619a8ef26a22dd6d03c25dac Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 16 Nov 2012 18:35:27 +0100 Subject: 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 Tested-by: Peter Maydell Reviewed-by: Peter Maydell Tested-by: Stefan Weil Signed-off-by: Blue Swirl --- stubs/Makefile.objs | 8 ++++++++ stubs/arch-query-cpu-def.c | 9 +++++++++ stubs/fd-register.c | 6 ++++++ stubs/fdset-add-fd.c | 7 +++++++ stubs/fdset-find-fd.c | 7 +++++++ stubs/fdset-get-fd.c | 7 +++++++ stubs/fdset-remove-fd.c | 7 +++++++ stubs/get-fd.c | 8 ++++++++ stubs/set-fd-handler.c | 11 +++++++++++ 9 files changed, 70 insertions(+) create mode 100644 stubs/Makefile.objs create mode 100644 stubs/arch-query-cpu-def.c create mode 100644 stubs/fd-register.c create mode 100644 stubs/fdset-add-fd.c create mode 100644 stubs/fdset-find-fd.c create mode 100644 stubs/fdset-get-fd.c create mode 100644 stubs/fdset-remove-fd.c create mode 100644 stubs/get-fd.c create mode 100644 stubs/set-fd-handler.c (limited to 'stubs') diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs new file mode 100644 index 0000000000..035b29a1f3 --- /dev/null +++ b/stubs/Makefile.objs @@ -0,0 +1,8 @@ +stub-obj-y += arch-query-cpu-def.o +stub-obj-y += fdset-add-fd.o +stub-obj-y += fdset-find-fd.o +stub-obj-y += fdset-get-fd.o +stub-obj-y += fdset-remove-fd.o +stub-obj-y += get-fd.o +stub-obj-y += set-fd-handler.o +stub-obj-$(CONFIG_WIN32) += fd-register.o diff --git a/stubs/arch-query-cpu-def.c b/stubs/arch-query-cpu-def.c new file mode 100644 index 0000000000..47b524628d --- /dev/null +++ b/stubs/arch-query-cpu-def.c @@ -0,0 +1,9 @@ +#include "qemu-common.h" +#include "arch_init.h" +#include "qerror.h" + +CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) +{ + error_set(errp, QERR_NOT_SUPPORTED); + return NULL; +} diff --git a/stubs/fd-register.c b/stubs/fd-register.c new file mode 100644 index 0000000000..813b6dd7c0 --- /dev/null +++ b/stubs/fd-register.c @@ -0,0 +1,6 @@ +#include "qemu-common.h" +#include "main-loop.h" + +void qemu_fd_register(int fd) +{ +} diff --git a/stubs/fdset-add-fd.c b/stubs/fdset-add-fd.c new file mode 100644 index 0000000000..09fe2a839a --- /dev/null +++ b/stubs/fdset-add-fd.c @@ -0,0 +1,7 @@ +#include "qemu-common.h" +#include "monitor.h" + +int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd) +{ + return -1; +} diff --git a/stubs/fdset-find-fd.c b/stubs/fdset-find-fd.c new file mode 100644 index 0000000000..f82baa066c --- /dev/null +++ b/stubs/fdset-find-fd.c @@ -0,0 +1,7 @@ +#include "qemu-common.h" +#include "monitor.h" + +int monitor_fdset_dup_fd_find(int dup_fd) +{ + return -1; +} diff --git a/stubs/fdset-get-fd.c b/stubs/fdset-get-fd.c new file mode 100644 index 0000000000..4106cf90f0 --- /dev/null +++ b/stubs/fdset-get-fd.c @@ -0,0 +1,7 @@ +#include "qemu-common.h" +#include "monitor.h" + +int monitor_fdset_get_fd(int64_t fdset_id, int flags) +{ + return -1; +} diff --git a/stubs/fdset-remove-fd.c b/stubs/fdset-remove-fd.c new file mode 100644 index 0000000000..861b31247e --- /dev/null +++ b/stubs/fdset-remove-fd.c @@ -0,0 +1,7 @@ +#include "qemu-common.h" +#include "monitor.h" + +int monitor_fdset_dup_fd_remove(int dupfd) +{ + return -1; +} diff --git a/stubs/get-fd.c b/stubs/get-fd.c new file mode 100644 index 0000000000..3561ab60e2 --- /dev/null +++ b/stubs/get-fd.c @@ -0,0 +1,8 @@ +#include "qemu-common.h" +#include "monitor.h" + +int monitor_get_fd(Monitor *mon, const char *name, Error **errp) +{ + error_setg(errp, "only QEMU supports file descriptor passing"); + return -1; +} diff --git a/stubs/set-fd-handler.c b/stubs/set-fd-handler.c new file mode 100644 index 0000000000..4807b5dc22 --- /dev/null +++ b/stubs/set-fd-handler.c @@ -0,0 +1,11 @@ +#include "qemu-common.h" +#include "main-loop.h" + +int qemu_set_fd_handler2(int fd, + IOCanReadHandler *fd_read_poll, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque) +{ + abort(); +} -- cgit v1.2.1