From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from szxga01-in.huawei.com ([119.145.14.64]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WUqPF-0006tL-58 for kexec@lists.infradead.org; Tue, 01 Apr 2014 04:34:40 +0000 From: Wang Nan Subject: [PATCH] makedumpfile: inhibit predefined macros when cross building Date: Tue, 1 Apr 2014 12:28:40 +0800 Message-ID: <1396326520-42618-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=twosheds.infradead.org@lists.infradead.org To: kumagai-atsushi@mxc.nes.nec.co.jp Cc: Wang Nan , kexec@lists.infradead.org, Geng Hui When cross building makedumpfile, for example, build x86_64 exec for dealing with arm vmcore, makefile passes a "-D__arm__" to gcc, but gcc predefined macros still take effect, defines "__x86_64__". Which makes definitions for x86_64 and arm mixed together in makedumpfile.h, causes many problems. This patch changes Makefile: if host arch and target arch are different, passes "-U__$(HOST_ARCH)__" to gcc. I have tested by running following command on x86_64 machine: make ARCH=arm Signed-off-by: Wang Nan Cc: Atsushi Kumagai Cc: kexec@lists.infradead.org Cc: Geng Hui --- Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2f4845c..f85cc21 100644 --- a/Makefile +++ b/Makefile @@ -15,10 +15,11 @@ CFLAGS_ARCH = -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE # LDFLAGS = -L/usr/local/lib -I/usr/local/include +HOST_ARCH := $(shell uname -m) # Use TARGET as the target architecture if specified. # Defaults to uname -m ifeq ($(strip($TARGET)),) -TARGET := $(shell uname -m) +TARGET := $(HOST_ARCH) endif ARCH := $(shell echo ${TARGET} | sed -e s/i.86/x86/ -e s/sun4u/sparc64/ \ @@ -26,8 +27,13 @@ ARCH := $(shell echo ${TARGET} | sed -e s/i.86/x86/ -e s/sun4u/sparc64/ \ -e s/s390x/s390/ -e s/parisc64/parisc/ \ -e s/ppc64/powerpc64/ -e s/ppc/powerpc32/) -CFLAGS += -D__$(ARCH)__ -CFLAGS_ARCH += -D__$(ARCH)__ +CROSS := +ifneq ($(TARGET), $(HOST_ARCH)) +CROSS := -U__$(HOST_ARCH)__ +endif + +CFLAGS += -D__$(ARCH)__ $(CROSS) +CFLAGS_ARCH += -D__$(ARCH)__ $(CROSS) ifeq ($(ARCH), powerpc64) CFLAGS += -m64 -- 1.8.4 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec