All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: "Wei Liu" <wl@xen.org>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Tim Deegan" <tim@xen.org>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Anthony PERARD" <anthony.perard@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [XEN PATCH v5 14/16] build: use if_changed to build mm/*/guest_%.o
Date: Tue, 21 Apr 2020 17:12:06 +0100	[thread overview]
Message-ID: <20200421161208.2429539-15-anthony.perard@citrix.com> (raw)
In-Reply-To: <20200421161208.2429539-1-anthony.perard@citrix.com>

Use if_changed for building all guest_%.o objects, and make use of
command that already exist.

The current command only runs `CC`, but the runes to build every other
object in Xen also runs `objcopy` (when CONFIG_ENFORCE_UNIQUE_SYMBOLS=y)
which modify the file symbol. But with patch
"xen,symbols: rework file symbols selection", ./symbols should still
select the file symbols directive intended to be used for guest_%.o
objects.

The goal here is to reduce the number of commands written in
makefiles.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v5:
    - reword commit message
    
    v4:
    - remove the introduction of Kbuild's CFLAGS_$@
      and simply use make's per-target variable customization.
      Mostly to avoid using $(eval ) which might not work as expected on
      make 3.80.

 xen/arch/x86/mm/Makefile        | 14 ++++++++------
 xen/arch/x86/mm/hap/Makefile    | 15 +++++++++------
 xen/arch/x86/mm/shadow/Makefile | 14 ++++++++------
 3 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/mm/Makefile b/xen/arch/x86/mm/Makefile
index a2431fde6bb4..a66a57314489 100644
--- a/xen/arch/x86/mm/Makefile
+++ b/xen/arch/x86/mm/Makefile
@@ -11,11 +11,13 @@ obj-y += p2m.o p2m-pt.o
 obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o
 obj-y += paging.o
 
-guest_walk_%.o: guest_walk.c Makefile
-	$(CC) $(c_flags) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+guest_walk_%.o guest_walk_%.i guest_walk_%.s: CFLAGS-y += -DGUEST_PAGING_LEVELS=$*
 
-guest_walk_%.i: guest_walk.c Makefile
-	$(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+guest_walk_%.o: guest_walk.c FORCE
+	$(call if_changed_rule,cc_o_c)
 
-guest_walk_%.s: guest_walk.c Makefile
-	$(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@
+guest_walk_%.i: guest_walk.c FORCE
+	$(call if_changed,cpp_i_c)
+
+guest_walk_%.s: guest_walk.c FORCE
+	$(call if_changed,cc_s_c)
diff --git a/xen/arch/x86/mm/hap/Makefile b/xen/arch/x86/mm/hap/Makefile
index 22e7ad54bd33..34720b2fbe2e 100644
--- a/xen/arch/x86/mm/hap/Makefile
+++ b/xen/arch/x86/mm/hap/Makefile
@@ -5,11 +5,14 @@ obj-y += guest_walk_4level.o
 obj-y += nested_hap.o
 obj-y += nested_ept.o
 
-guest_walk_%level.o: guest_walk.c Makefile
-	$(CC) $(c_flags) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+guest_walk_%level.o guest_walk_%level.i guest_walk_%level.s: \
+    CFLAGS-y += -DGUEST_PAGING_LEVELS=$*
 
-guest_walk_%level.i: guest_walk.c Makefile
-	$(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+guest_walk_%level.o: guest_walk.c FORCE
+	$(call if_changed_rule,cc_o_c)
 
-guest_walk_%level.s: guest_walk.c Makefile
-	$(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@
+guest_walk_%level.i: guest_walk.c FORCE
+	$(call if_changed,cpp_i_c)
+
+guest_walk_%level.s: guest_walk.c FORCE
+	$(call if_changed,cc_s_c)
diff --git a/xen/arch/x86/mm/shadow/Makefile b/xen/arch/x86/mm/shadow/Makefile
index 23d3ff10802c..e00f9cb1aaba 100644
--- a/xen/arch/x86/mm/shadow/Makefile
+++ b/xen/arch/x86/mm/shadow/Makefile
@@ -6,11 +6,13 @@ else
 obj-y += none.o
 endif
 
-guest_%.o: multi.c Makefile
-	$(CC) $(c_flags) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+guest_%.o guest_%.i guest_%.s: CFLAGS-y += -DGUEST_PAGING_LEVELS=$*
 
-guest_%.i: multi.c Makefile
-	$(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
+guest_%.o: multi.c FORCE
+	$(call if_changed_rule,cc_o_c)
 
-guest_%.s: multi.c Makefile
-	$(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@
+guest_%.i: multi.c FORCE
+	$(call if_changed,cpp_i_c)
+
+guest_%.s: multi.c FORCE
+	$(call if_changed,cc_s_c)
-- 
Anthony PERARD



  parent reply	other threads:[~2020-04-21 16:13 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 16:11 [XEN PATCH v5 00/16] xen: Build system improvements Anthony PERARD
2020-04-21 16:11 ` [XEN PATCH v5 01/16] build,xsm: Fix multiple call Anthony PERARD
2020-04-21 16:11 ` [XEN PATCH v5 02/16] xen/build: include include/config/auto.conf in main Makefile Anthony PERARD
2020-04-21 16:11 ` [XEN PATCH v5 03/16] xen/build: use new $(c_flags) and $(a_flags) instead of $(CFLAGS) Anthony PERARD
2020-04-24  9:20   ` Julien Grall
2020-04-21 16:11 ` [XEN PATCH v5 04/16] xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-04-23 16:40   ` Jan Beulich
2020-04-24  9:45     ` Anthony PERARD
2020-04-24 11:20       ` Jan Beulich
2020-04-24  9:26   ` Julien Grall
2020-04-24 13:01   ` Jan Beulich
2020-04-24 13:30     ` Anthony PERARD
2020-04-24 14:07       ` Anthony PERARD
2020-04-21 16:11 ` [XEN PATCH v5 05/16] build: Introduce documentation for xen Makefiles Anthony PERARD
2020-04-21 16:11 ` [XEN PATCH v5 06/16] xen/build: introduce if_changed and if_changed_rule Anthony PERARD
2020-04-21 16:11 ` [XEN PATCH v5 07/16] xen/build: Start using if_changed Anthony PERARD
2020-04-24  9:28   ` Julien Grall
2020-04-21 16:12 ` [XEN PATCH v5 08/16] build: Introduce $(cpp_flags) Anthony PERARD
2020-04-23 16:48   ` Jan Beulich
2020-04-28 14:01     ` Anthony PERARD
2020-04-28 14:20       ` Jan Beulich
2020-05-01 14:32         ` Anthony PERARD
2020-05-04  9:09           ` Jan Beulich
2020-04-21 16:12 ` [XEN PATCH v5 09/16] xen/build: use if_changed on built_in.o Anthony PERARD
2020-04-28 13:48   ` Jan Beulich
2020-05-01 14:42     ` Anthony PERARD
2020-05-04  9:11       ` Jan Beulich
2020-04-21 16:12 ` [XEN PATCH v5 10/16] xen/build: Use if_changed_rules with %.o:%.c targets Anthony PERARD
2020-04-21 16:12 ` [XEN PATCH v5 11/16] xen/build: factorise generation of the linker scripts Anthony PERARD
2020-04-24  9:29   ` Julien Grall
2020-04-28 13:50   ` Jan Beulich
2020-04-21 16:12 ` [XEN PATCH v5 12/16] xen/build: Use if_changed for prelink*.o Anthony PERARD
2020-04-21 16:12 ` [XEN PATCH v5 13/16] xen,symbols: rework file symbols selection Anthony PERARD
2020-04-28 14:05   ` Jan Beulich
2020-04-21 16:12 ` Anthony PERARD [this message]
2020-04-28 14:07   ` [XEN PATCH v5 14/16] build: use if_changed to build mm/*/guest_%.o Jan Beulich
2020-04-21 16:12 ` [XEN PATCH v5 15/16] build,include: rework compat-build-source.py Anthony PERARD
2020-04-28 14:37   ` [XEN PATCH v5 15/16] build, include: " Jan Beulich
2020-04-21 16:12 ` [XEN PATCH v5 16/16] build,include: rework compat-build-header.py Anthony PERARD
2020-04-28 14:39   ` [XEN PATCH v5 16/16] build, include: " Jan Beulich
2020-04-28 14:54   ` Wei Liu

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=20200421161208.2429539-15-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.