Re: [XEN PATCH v5 14/16] build: use if_changed to build mm/*/guest_%.o

2020-04-28 Thread Jan Beulich
On 21.04.2020 18:12, Anthony PERARD wrote:
> 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 

Reviewed-by: Jan Beulich 




[XEN PATCH v5 14/16] build: use if_changed to build mm/*/guest_%.o

2020-04-21 Thread Anthony PERARD
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 
---

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