From: Tim Deegan Subject: Re: [PATCH 8 of 8] xen: add "clang=y" option to build Xen with clang/llvm instead of gcc Date: Mon, 7 Mar 2011 16:29:34 +0000 Message-ID: <20110307162934.GD28479@whitby.uk.xensource.com> References: <1299509669.17339.381.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="J/dobhs11T7y2rNN" Return-path: Content-Disposition: inline In-Reply-To: <1299509669.17339.381.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --J/dobhs11T7y2rNN Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline At 14:54 +0000 on 07 Mar (1299509669), Ian Campbell wrote: > Is it worth arranging for "gcc := y" when clang is not enabled? Then a > whole bunch of this sort of thing devolves into the > CFLAGS-$(a-particular-cc) += -Wfoo > pattern. Something like the attached? It tidies up four such ifeqs, at the cost of one new one to define $(gcc). (4 files changed, 17 insertions(+), 16 deletions(-)) > > @@ -1,6 +1,11 @@ > > AS = $(CROSS_COMPILE)as > > +ifeq ($(clang),y) > > +LD = $(CROSS_COMPILE)gold > > +CC = $(CROSS_COMPILE)clang > > +else > > LD = $(CROSS_COMPILE)ld > > CC = $(CROSS_COMPILE)gcc > > +endif > > CPP = $(CC) -E > > AR = $(CROSS_COMPILE)ar > > RANLIB = $(CROSS_COMPILE)ranlib > > LD-$(clang) = ... > LD-$(gcc) = ... > > LD := $(LD-y) I tried that but it looks about as bad, and actually has more repetition. Tim. -- Tim Deegan Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd. (Company #02937203, SL9 0BG) --J/dobhs11T7y2rNN Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: attachment; filename="makeism" diff -r ca556b7bad5c Config.mk --- a/Config.mk Mon Mar 07 16:07:06 2011 +0000 +++ b/Config.mk Mon Mar 07 16:26:43 2011 +0000 @@ -23,6 +23,15 @@ DESTDIR ?= / # Allow phony attribute to be listed as dependency rather than fake target .PHONY: .phony +# Use Clang/LLVM instead of GCC? +clang ?= n +ifeq ($(clang),n) +gcc := y +else +gcc := n +endif + + include $(XEN_ROOT)/config/$(XEN_OS).mk include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk @@ -148,12 +157,9 @@ CFLAGS += -Wall -Wstrict-prototypes # result of any casted expression causes a warning. CFLAGS += -Wno-unused-value -ifeq ($(clang),y) # Clang complains about macros that expand to 'if ( ( foo == bar ) ) ...' -CFLAGS += -Wno-parentheses -# And is over-zealous with the printf format lint -CFLAGS += -Wno-format -endif +# and is over-zealous with the printf format lint +CFLAGS-$(clang) += -Wno-parentheses -Wno-format $(call cc-option-add,HOSTCFLAGS,HOSTCC,-Wdeclaration-after-statement) $(call cc-option-add,CFLAGS,CC,-Wdeclaration-after-statement) diff -r ca556b7bad5c config/StdGNU.mk --- a/config/StdGNU.mk Mon Mar 07 16:07:06 2011 +0000 +++ b/config/StdGNU.mk Mon Mar 07 16:26:43 2011 +0000 @@ -76,14 +76,10 @@ CFLAGS += -O2 -fomit-frame-pointer else # Less than -O1 produces bad code and large stack frames CFLAGS += -O1 -fno-omit-frame-pointer -ifneq ($(clang),y) -CFLAGS += -fno-optimize-sibling-calls -endif +CFLAGS-$(gcc) += -fno-optimize-sibling-calls endif ifeq ($(lto),y) CFLAGS += -flto -ifeq ($(clang),y) -LDFLAGS += -plugin LLVMgold.so +LDFLAGS-$(clang) += -plugin LLVMgold.so endif -endif diff -r ca556b7bad5c xen/Rules.mk --- a/xen/Rules.mk Mon Mar 07 16:07:06 2011 +0000 +++ b/xen/Rules.mk Mon Mar 07 16:26:43 2011 +0000 @@ -9,7 +9,6 @@ perfc_arrays ?= n lock_profile ?= n crash_debug ?= n frame_pointer ?= n -clang ?= n lto ?= n XEN_ROOT=$(BASEDIR)/.. @@ -83,6 +82,8 @@ AFLAGS += $(AFLAGS-y) $(filter-out -std= # LDFLAGS are only passed directly to $(LD) LDFLAGS += $(LDFLAGS_DIRECT) +LDFLAGS += $(LDFLAGS-y) + include Makefile # Ensure each subdirectory has exactly one trailing slash. diff -r ca556b7bad5c xen/arch/x86/Rules.mk --- a/xen/arch/x86/Rules.mk Mon Mar 07 16:07:06 2011 +0000 +++ b/xen/arch/x86/Rules.mk Mon Mar 07 16:26:43 2011 +0000 @@ -14,9 +14,7 @@ supervisor_mode_kernel ?= n # Solaris grabs stdarg.h and friends from the system include directory. # Clang likewise. ifneq ($(XEN_OS),SunOS) -ifneq ($(clang),y) -CFLAGS += -nostdinc -endif +CFLAGS-$(gcc) += -nostdinc endif CFLAGS += -fno-builtin -fno-common -Wredundant-decls @@ -52,7 +50,7 @@ x86_32 := n x86_64 := y endif -ifneq ($(clang),y) +ifeq ($(gcc),y) # Require GCC v3.4+ (to avoid issues with alignment constraints in Xen headers) $(call cc-ver-check,CC,0x030400,"Xen requires at least gcc-3.4") endif --J/dobhs11T7y2rNN Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --J/dobhs11T7y2rNN--