From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>, "Wei Liu" <wl@xen.org>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"George Dunlap" <George.Dunlap@eu.citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"Tim Deegan" <tim@xen.org>,
"Anthony PERARD" <anthony.perard@gmail.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Anthony PERARD" <anthony.perard@citrix.com>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [XEN PATCH v2 10/12] xen/build: use new $(c_flags) and $(a_flags) instead of $(CFLAGS)
Date: Fri, 17 Jan 2020 10:53:56 +0000 [thread overview]
Message-ID: <20200117105358.607910-11-anthony.perard@citrix.com> (raw)
In-Reply-To: <20200117105358.607910-1-anthony.perard@citrix.com>
From: Anthony PERARD <anthony.perard@gmail.com>
We would like to calculate CFLAGS once and before calling Rules.mk,
so the variable CFLAGS needs to have the same value across the whole
build. Thus we need a new variable where some flags can change
depending on the target name.
Both the dependency and __OBJECT_FILE__ are such flags that change
depending on the target, so there are move out of $(CFLAGS).
__OBJECT_FILE__ is only used by arch/x86/mm/*.c files, so having it in
$(c_flags) is enough, we don't need it in $(a_flags).
This is inspired by the way Kbuild generates CFLAGS for each targets.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
xen/Rules.mk | 27 +++++++++++++++------------
xen/arch/arm/Makefile | 4 ++--
xen/arch/x86/Makefile | 6 +++---
xen/arch/x86/mm/Makefile | 6 +++---
xen/arch/x86/mm/hap/Makefile | 6 +++---
xen/arch/x86/mm/shadow/Makefile | 6 +++---
xen/include/Makefile | 2 +-
7 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/xen/Rules.mk b/xen/Rules.mk
index d20521cc9ec1..c98d5372f3db 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -57,7 +57,6 @@ CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
$(call cc-option-add,CFLAGS,CC,-Wvla)
CFLAGS += -pipe -D__XEN__ -include $(BASEDIR)/include/xen/config.h
CFLAGS-$(CONFIG_DEBUG_INFO) += -g
-CFLAGS += '-D__OBJECT_FILE__="$@"'
ifneq ($(CONFIG_CC_IS_CLANG),y)
# Clang doesn't understand this command line argument, and doesn't appear to
@@ -70,9 +69,6 @@ AFLAGS-y += -D__ASSEMBLY__
ALL_OBJS := $(ALL_OBJS-y)
-# Get gcc to generate the dependencies for us.
-CFLAGS-y += -MMD -MF $(@D)/.$(@F).d
-
CFLAGS += $(CFLAGS-y)
# allow extra CFLAGS externally via EXTRA_CFLAGS_XEN_CORE
CFLAGS += $(EXTRA_CFLAGS_XEN_CORE)
@@ -141,9 +137,16 @@ endif
# Always build obj-bin files as binary even if they come from C source.
$(obj-bin-y): CFLAGS := $(filter-out -flto,$(CFLAGS))
+c_flags = -MMD -MF $(@D)/.$(@F).d \
+ $(CFLAGS) \
+ '-D__OBJECT_FILE__="$@"'
+
+a_flags = -MMD -MF $(@D)/.$(@F).d \
+ $(AFLAGS)
+
built_in.o: $(obj-y) $(extra-y)
ifeq ($(obj-y),)
- $(CC) $(CFLAGS) -c -x c /dev/null -o $@
+ $(CC) $(c_flags) -c -x c /dev/null -o $@
else
ifeq ($(CONFIG_LTO),y)
$(LD_LTO) -r -o $@ $(filter-out $(extra-y),$^)
@@ -154,7 +157,7 @@ endif
built_in_bin.o: $(obj-bin-y) $(extra-y)
ifeq ($(obj-bin-y),)
- $(CC) $(AFLAGS) -c -x assembler /dev/null -o $@
+ $(CC) $(a_flags) -c -x assembler /dev/null -o $@
else
$(LD) $(LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^)
endif
@@ -173,7 +176,7 @@ SRCPATH := $(patsubst $(BASEDIR)/%,%,$(CURDIR))
%.o: %.c Makefile
ifeq ($(CONFIG_ENFORCE_UNIQUE_SYMBOLS),y)
- $(CC) $(CFLAGS) -c $< -o $(@D)/.$(@F).tmp
+ $(CC) $(c_flags) -c $< -o $(@D)/.$(@F).tmp
ifeq ($(CONFIG_CC_IS_CLANG),y)
$(OBJCOPY) --redefine-sym $<=$(SRCPATH)/$< $(@D)/.$(@F).tmp $@
else
@@ -181,11 +184,11 @@ else
endif
rm -f $(@D)/.$(@F).tmp
else
- $(CC) $(CFLAGS) -c $< -o $@
+ $(CC) $(c_flags) -c $< -o $@
endif
%.o: %.S Makefile
- $(CC) $(AFLAGS) -c $< -o $@
+ $(CC) $(a_flags) -c $< -o $@
SPECIAL_DATA_SECTIONS := rodata $(foreach a,1 2 4 8 16, \
$(foreach w,1 2 4, \
@@ -206,13 +209,13 @@ $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): %.init.o: %.o Makefile
$(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
%.i: %.c Makefile
- $(CPP) $(filter-out -Wa$(comma)%,$(CFLAGS)) $< -o $@
+ $(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) $< -o $@
%.s: %.c Makefile
- $(CC) $(filter-out -Wa$(comma)%,$(CFLAGS)) -S $< -o $@
+ $(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -S $< -o $@
# -std=gnu{89,99} gets confused by # as an end-of-line comment marker
%.s: %.S Makefile
- $(CPP) $(filter-out -Wa$(comma)%,$(AFLAGS)) $< -o $@
+ $(CPP) $(filter-out -Wa$(comma)%,$(a_flags)) $< -o $@
-include $(DEPS_INCLUDE)
diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 1044c2298a05..7f1427630b96 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -121,10 +121,10 @@ $(TARGET)-syms: prelink.o xen.lds
rm -f $(@D)/.$(@F).[0-9]*
asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c
- $(CC) $(filter-out -flto,$(CFLAGS)) -S -o $@ $<
+ $(CC) $(filter-out -flto,$(c_flags)) -S -o $@ $<
xen.lds: xen.lds.S
- $(CC) -P -E -Ui386 $(AFLAGS) -o $@ $<
+ $(CC) -P -E -Ui386 $(a_flags) -o $@ $<
sed -e 's/xen\.lds\.o:/xen\.lds:/g' <.xen.lds.d >.xen.lds.d.new
mv -f .xen.lds.d.new .xen.lds.d
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 461d1f3dc2a6..472e3fadb719 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -225,7 +225,7 @@ efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o efi/relocs-dummy.o: $(B
efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o efi/relocs-dummy.o: ;
asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c $(BASEDIR)/include/asm-x86/asm-macros.h
- $(CC) $(filter-out -Wa$(comma)% -flto,$(CFLAGS)) -S -o $@ $<
+ $(CC) $(filter-out -Wa$(comma)% -flto,$(c_flags)) -S -o $@ $<
asm-macros.i: CFLAGS += -D__ASSEMBLY__ -P
@@ -241,12 +241,12 @@ $(BASEDIR)/include/asm-x86/asm-macros.h: asm-macros.i Makefile
$(call move-if-changed,$@.new,$@)
xen.lds: xen.lds.S
- $(CC) -P -E -Ui386 $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $<
+ $(CC) -P -E -Ui386 $(filter-out -Wa$(comma)%,$(a_flags)) -o $@ $<
sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new
mv -f .$(@F).d.new .$(@F).d
efi.lds: xen.lds.S
- $(CC) -P -E -Ui386 -DEFI $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $<
+ $(CC) -P -E -Ui386 -DEFI $(filter-out -Wa$(comma)%,$(a_flags)) -o $@ $<
sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new
mv -f .$(@F).d.new .$(@F).d
diff --git a/xen/arch/x86/mm/Makefile b/xen/arch/x86/mm/Makefile
index d87dc0aa6eeb..a2431fde6bb4 100644
--- a/xen/arch/x86/mm/Makefile
+++ b/xen/arch/x86/mm/Makefile
@@ -12,10 +12,10 @@ obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o
obj-y += paging.o
guest_walk_%.o: guest_walk.c Makefile
- $(CC) $(CFLAGS) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+ $(CC) $(c_flags) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
guest_walk_%.i: guest_walk.c Makefile
- $(CPP) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+ $(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
guest_walk_%.s: guest_walk.c Makefile
- $(CC) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@
+ $(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@
diff --git a/xen/arch/x86/mm/hap/Makefile b/xen/arch/x86/mm/hap/Makefile
index b14a9aff93d2..22e7ad54bd33 100644
--- a/xen/arch/x86/mm/hap/Makefile
+++ b/xen/arch/x86/mm/hap/Makefile
@@ -6,10 +6,10 @@ obj-y += nested_hap.o
obj-y += nested_ept.o
guest_walk_%level.o: guest_walk.c Makefile
- $(CC) $(CFLAGS) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+ $(CC) $(c_flags) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
guest_walk_%level.i: guest_walk.c Makefile
- $(CPP) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+ $(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
guest_walk_%level.s: guest_walk.c Makefile
- $(CC) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@
+ $(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@
diff --git a/xen/arch/x86/mm/shadow/Makefile b/xen/arch/x86/mm/shadow/Makefile
index ff03a9937f9b..23d3ff10802c 100644
--- a/xen/arch/x86/mm/shadow/Makefile
+++ b/xen/arch/x86/mm/shadow/Makefile
@@ -7,10 +7,10 @@ obj-y += none.o
endif
guest_%.o: multi.c Makefile
- $(CC) $(CFLAGS) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+ $(CC) $(c_flags) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
guest_%.i: multi.c Makefile
- $(CPP) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+ $(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
guest_%.s: multi.c Makefile
- $(CC) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@
+ $(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@
diff --git a/xen/include/Makefile b/xen/include/Makefile
index 433bad9055b2..83131c2472f5 100644
--- a/xen/include/Makefile
+++ b/xen/include/Makefile
@@ -64,7 +64,7 @@ compat/%.h: compat/%.i Makefile $(BASEDIR)/tools/compat-build-header.py
mv -f $@.new $@
compat/%.i: compat/%.c Makefile
- $(CPP) $(filter-out -Wa$(comma)% -M% %.d -include %/include/xen/config.h,$(CFLAGS)) $(cppflags-y) -o $@ $<
+ $(CPP) $(filter-out -Wa$(comma)% -M% %.d -include %/include/xen/config.h,$(c_flags)) $(cppflags-y) -o $@ $<
compat/%.c: public/%.h xlat.lst Makefile $(BASEDIR)/tools/compat-build-source.py
mkdir -p $(@D)
--
Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2020-01-17 11:11 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 10:53 [Xen-devel] [XEN PATCH v2 00/12] xen: Build system improvements Anthony PERARD
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 01/12] xen/build: Remove left over -DMAX_PHYS_IRQS Anthony PERARD
2020-01-17 11:03 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 02/12] xen/build: Use obj-y += subdir/ instead of subdir-y Anthony PERARD
2020-01-29 14:19 ` Jan Beulich
2020-01-30 16:54 ` Anthony PERARD
2020-01-31 8:35 ` Jan Beulich
2020-02-03 11:31 ` Anthony PERARD
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 03/12] xen/build: use $(clean) shorthand for clean targets Anthony PERARD
2020-01-29 14:21 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 04/12] xen/build: extract clean target from Rules.mk Anthony PERARD
2020-01-29 14:30 ` Jan Beulich
2020-01-30 18:10 ` Anthony PERARD
2020-01-31 8:50 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 05/12] xen/include: remove include of Config.mk Anthony PERARD
2020-01-29 15:28 ` Jan Beulich
2020-01-29 15:33 ` Jan Beulich
2020-01-30 18:34 ` Anthony PERARD
2020-01-31 8:56 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 06/12] xen/test/livepatch: " Anthony PERARD
2020-01-17 17:17 ` Ross Lagerwall
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 07/12] xen/build: run targets csopes, tags, .. without Rules.mk Anthony PERARD
2020-01-30 11:29 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 08/12] xen/build: make tests in test/ directly Anthony PERARD
2020-01-30 11:31 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 09/12] xen/build: include include/config/auto.conf in main Makefile Anthony PERARD
2020-01-30 13:06 ` Jan Beulich
2020-02-03 11:45 ` Anthony PERARD
2020-02-03 12:20 ` Jan Beulich
2020-01-17 10:53 ` Anthony PERARD [this message]
2020-01-30 13:29 ` [Xen-devel] [XEN PATCH v2 10/12] xen/build: use new $(c_flags) and $(a_flags) instead of $(CFLAGS) Jan Beulich
2020-02-03 12:17 ` Anthony PERARD
2020-02-03 12:34 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 11/12] xen/build: introduce ccflags-y and CFLAGS_$@ Anthony PERARD
2020-01-30 13:39 ` Jan Beulich
2020-02-03 14:23 ` Anthony PERARD
2020-02-03 15:20 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 12/12] xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-01-30 14:33 ` Jan Beulich
2020-02-03 13:57 ` Anthony PERARD
2020-02-03 15:26 ` Jan Beulich
2020-01-21 13:59 ` [Xen-devel] [XEN PATCH v2.1 13/12] Makefile: Fix install-tests Anthony PERARD
2020-01-30 11:37 ` Jan Beulich
2020-02-03 14:29 ` Anthony PERARD
2020-02-03 15:21 ` Jan Beulich
2020-01-21 13:59 ` [Xen-devel] [XEN PATCH v2.1 14/12] squash! xen/build: introduce ccflags-y and CFLAGS_$@ Anthony PERARD
2020-01-21 13:59 ` [Xen-devel] [XEN PATCH v2.1 15/12] squash! xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-01-30 13:32 ` Jan Beulich
2020-02-03 14:32 ` Anthony PERARD
2020-01-21 14:08 ` [Xen-devel] [XEN PATCH v2 00/12] xen: Build system improvements Anthony PERARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200117105358.607910-11-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@gmail.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=konrad.wilk@oracle.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).