From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqFiV-0007Cb-Gy for qemu-devel@nongnu.org; Thu, 07 May 2015 02:55:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqFiS-0006Bd-BC for qemu-devel@nongnu.org; Thu, 07 May 2015 02:55:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59272) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqFiS-0006BX-56 for qemu-devel@nongnu.org; Thu, 07 May 2015 02:55:28 -0400 From: Fam Zheng Date: Thu, 7 May 2015 14:55:15 +0800 Message-Id: <1430981715-31465-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2] rules.mak: Force CFLAGS for all objects in DSO List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Fam Zheng , Stefan Weil , Michael Tokarev , agraf@suse.de, Paolo Bonzini Because of the trick of process-archive-undefs, all .mo objects, even with --enable-modules, are dependencies of executables. This breaks CFLAGS propogation because the compiling of module object will happen too early before building for DSO. With GCC 5, the linking would fail because .o doesn't have -fPIC. Also, BUILD_DSO will be missed. (module-common.o will have it, so the stamp symbol was still liked in .so). Fix the problem by forcing the CFLAGS on individual .o-cflags during unnest-vars. Reported-by: Alexander Graf Signed-off-by: Fam Zheng --- v2: Simplify as Paolo suggested, while keeping the CFLAGS of module-common.o --- rules.mak | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rules.mak b/rules.mak index 3a05627..aec27f8 100644 --- a/rules.mak +++ b/rules.mak @@ -102,7 +102,8 @@ endif %.o: %.dtrace $(call quiet-command,dtrace -o $@ -G -s $<, " GEN $(TARGET_DIR)$@") -%$(DSOSUF): CFLAGS += -fPIC -DBUILD_DSO +DSO_OBJ_CFLAGS := -fPIC -DBUILD_DSO +module-common.o: CFLAGS += $(DSO_OBJ_CFLAGS) %$(DSOSUF): LDFLAGS += $(LDFLAGS_SHARED) %$(DSOSUF): %.mo $(call LINK,$^) @@ -351,6 +352,7 @@ define unnest-vars # For non-module build, add -m to -y $(if $(CONFIG_MODULES), $(foreach o,$($v), + $(eval $($o-objs): CFLAGS += $(DSO_OBJ_CFLAGS)) $(eval $o: $($o-objs))) $(eval $(patsubst %-m,%-y,$v) += $($v)) $(eval modules: $($v:%.mo=%$(DSOSUF))), -- 2.1.0