diff mbox series

[XEN,v4,15/18] xen/build: use if_changed to build guest_%.o

Message ID 20200331103102.1105674-16-anthony.perard@citrix.com (mailing list archive)
State Superseded
Headers show
Series xen: Build system improvements | expand

Commit Message

Anthony PERARD March 31, 2020, 10:30 a.m. UTC
Use if_changed for building all guest_%.o objects, and make use of
command that already exist.

This patch make a change to the way guest_%.o files are built, and now
run the same commands that enforce unique symbols. 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.

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

Notes:
    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(-)

Comments

Jan Beulich April 8, 2020, 1:02 p.m. UTC | #1
On 31.03.2020 12:30, Anthony PERARD wrote:
> Use if_changed for building all guest_%.o objects, and make use of
> command that already exist.
> 
> This patch make a change to the way guest_%.o files are built, and now
> run the same commands that enforce unique symbols. 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.

I'm having trouble making the connection between the change to the
symbols tool and the adjustments made here:

> --- 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 $@

The original rules didn't do anything special to arrange for the
resulting kallsyms names; these arrangements instead live at the
top of the respective source files, in the form of asm()-s.

Jan
Anthony PERARD April 16, 2020, 12:57 p.m. UTC | #2
On Wed, Apr 08, 2020 at 03:02:21PM +0200, Jan Beulich wrote:
> On 31.03.2020 12:30, Anthony PERARD wrote:
> > Use if_changed for building all guest_%.o objects, and make use of
> > command that already exist.
> > 
> > This patch make a change to the way guest_%.o files are built, and now
> > run the same commands that enforce unique symbols. 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.
> 
> I'm having trouble making the connection between the change to the
> symbols tool and the adjustments made here:

The change to symbol tool is to allow this change.

> > --- 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 $@
> 
> The original rules didn't do anything special to arrange for the
> resulting kallsyms names; these arrangements instead live at the
> top of the respective source files, in the form of asm()-s.

They still are. I try to consolidate the number of location which have
command that build a target. Those guest_%.o object aren't special
enough to deserve to be built in a different way than every other
object. They do need a different make rule, but they can use the same
command.

Thanks,
Jan Beulich April 16, 2020, 2:28 p.m. UTC | #3
On 16.04.2020 14:57, Anthony PERARD wrote:
> On Wed, Apr 08, 2020 at 03:02:21PM +0200, Jan Beulich wrote:
>> On 31.03.2020 12:30, Anthony PERARD wrote:
>>> Use if_changed for building all guest_%.o objects, and make use of
>>> command that already exist.
>>>
>>> This patch make a change to the way guest_%.o files are built, and now
>>> run the same commands that enforce unique symbols. 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.
>>
>> I'm having trouble making the connection between the change to the
>> symbols tool and the adjustments made here:
> 
> The change to symbol tool is to allow this change.

I've been understanding the fact, but I still don't understand why
the adjustment to that tool is necessary for the change here to be
made.

>>> --- 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 $@
>>
>> The original rules didn't do anything special to arrange for the
>> resulting kallsyms names; these arrangements instead live at the
>> top of the respective source files, in the form of asm()-s.
> 
> They still are. I try to consolidate the number of location which have
> command that build a target. Those guest_%.o object aren't special
> enough to deserve to be built in a different way than every other
> object. They do need a different make rule, but they can use the same
> command.

Again, I understand what the goal is, but not what it is that
changes (and why) in the produced file symbols, making the utility
adjustment necessary. I guess it's obvious to you, but it looks as
if I was dense, sorry.

Jan
diff mbox series

Patch

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)