From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSRNr-0005ms-5V for qemu-devel@nongnu.org; Fri, 12 Sep 2014 09:59:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XSRNg-0000fY-OU for qemu-devel@nongnu.org; Fri, 12 Sep 2014 09:59:31 -0400 Received: from mail-qa0-x22a.google.com ([2607:f8b0:400d:c00::22a]:58092) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSRNg-0000e5-CH for qemu-devel@nongnu.org; Fri, 12 Sep 2014 09:59:20 -0400 Received: by mail-qa0-f42.google.com with SMTP id j7so756047qaq.15 for ; Fri, 12 Sep 2014 06:59:19 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 12 Sep 2014 15:58:42 +0200 Message-Id: <1410530338-17615-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1410530338-17615-1-git-send-email-pbonzini@redhat.com> References: <1410530338-17615-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 05/21] rules.mak: Fix DSO build by pulling in archive symbols List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Fam Zheng From: Fam Zheng 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 Signed-off-by: Fam Zheng Signed-off-by: Paolo Bonzini --- rules.mak | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/rules.mak b/rules.mak index ba2f4c1..1d73293 100644 --- a/rules.mak +++ b/rules.mak @@ -22,6 +22,32 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d # Same as -I$(SRC_PATH) -I., but for the nested source/object directories QEMU_INCLUDES += -I$(