diff mbox series

[1/9] build: use if_changed more consistently (and correctly) for prelink*.o

Message ID 75d94bf1-b419-8a82-2d15-fb02e56109d8@suse.com (mailing list archive)
State Superseded
Headers show
Series xen: beginnings of moving library-like code into an archive | expand

Commit Message

Jan Beulich Sept. 14, 2020, 10:15 a.m. UTC
Switch to $(call if_changed,ld) where possible; presumably not doing so
in e321576f4047 ("xen/build: start using if_changed") right away was an
oversight, as it did for Arm in (just) one case. It failed to add
prelink.o to $(targets), though, causing - judging from the observed
behavior on x86 - undue rebuilds of the final binary (because of
prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
because of .prelink.o.cmd not getting read) during "make install-xen".

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/arm/Makefile |  4 +++-
 xen/arch/x86/Makefile | 18 ++++++++++--------
 2 files changed, 13 insertions(+), 9 deletions(-)

Comments

Roger Pau Monné Sept. 15, 2020, 11:56 a.m. UTC | #1
On Mon, Sep 14, 2020 at 12:15:39PM +0200, Jan Beulich wrote:
> Switch to $(call if_changed,ld) where possible; presumably not doing so
> in e321576f4047 ("xen/build: start using if_changed") right away was an
> oversight, as it did for Arm in (just) one case. It failed to add
> prelink.o to $(targets), though, causing - judging from the observed
> behavior on x86 - undue rebuilds of the final binary (because of
> prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
> because of .prelink.o.cmd not getting read) during "make install-xen".

I'm not sure I follow why prelink.o needs to be added to targets, does
this offer some kind of protection against rebuilds when doing make
install?

The switch to if_changed LGTM.

Thanks, Roger.
Jan Beulich Sept. 15, 2020, 12:26 p.m. UTC | #2
On 15.09.2020 13:56, Roger Pau Monné wrote:
> On Mon, Sep 14, 2020 at 12:15:39PM +0200, Jan Beulich wrote:
>> Switch to $(call if_changed,ld) where possible; presumably not doing so
>> in e321576f4047 ("xen/build: start using if_changed") right away was an
>> oversight, as it did for Arm in (just) one case. It failed to add
>> prelink.o to $(targets), though, causing - judging from the observed
>> behavior on x86 - undue rebuilds of the final binary (because of
>> prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
>> because of .prelink.o.cmd not getting read) during "make install-xen".
> 
> I'm not sure I follow why prelink.o needs to be added to targets, does
> this offer some kind of protection against rebuilds when doing make
> install?

In a way, but (as I view it) not really. It is the use of ...

> The switch to if_changed LGTM.

... if_changed which requires this. .*.cmd files will only be loaded
for anything explicitly or implicitly listed as a target. While .o
coming from $(obj-y) get added there automatically, prelink.o is not
something that could be recognized as needing adding, hence the
"manual" insertion.

Without .prelink.o.cmd loaded, $(if_changed ) will always arrange
for it to get re-built, because it then will consider the command
used to build the file to have changed (as the stored one appears to
be empty).

Jan
Roger Pau Monné Sept. 15, 2020, 1:46 p.m. UTC | #3
On Tue, Sep 15, 2020 at 02:26:34PM +0200, Jan Beulich wrote:
> On 15.09.2020 13:56, Roger Pau Monné wrote:
> > On Mon, Sep 14, 2020 at 12:15:39PM +0200, Jan Beulich wrote:
> >> Switch to $(call if_changed,ld) where possible; presumably not doing so
> >> in e321576f4047 ("xen/build: start using if_changed") right away was an
> >> oversight, as it did for Arm in (just) one case. It failed to add
> >> prelink.o to $(targets), though, causing - judging from the observed
> >> behavior on x86 - undue rebuilds of the final binary (because of
> >> prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
> >> because of .prelink.o.cmd not getting read) during "make install-xen".
> > 
> > I'm not sure I follow why prelink.o needs to be added to targets, does
> > this offer some kind of protection against rebuilds when doing make
> > install?
> 
> In a way, but (as I view it) not really. It is the use of ...
> 
> > The switch to if_changed LGTM.
> 
> ... if_changed which requires this. .*.cmd files will only be loaded
> for anything explicitly or implicitly listed as a target. While .o
> coming from $(obj-y) get added there automatically, prelink.o is not
> something that could be recognized as needing adding, hence the
> "manual" insertion.

This seems very prone to mistakes, as you have to remember that
whatever object that uses if_changed should also be part of the
targets set, or else it will get rebuild unconditionally.

I think adding some of the above reasoning to the commit message would
be helpful IMO.

> Without .prelink.o.cmd loaded, $(if_changed ) will always arrange
> for it to get re-built, because it then will consider the command
> used to build the file to have changed (as the stored one appears to
> be empty).

Acked-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.
Jan Beulich Sept. 15, 2020, 3:14 p.m. UTC | #4
On 15.09.2020 15:46, Roger Pau Monné wrote:
> On Tue, Sep 15, 2020 at 02:26:34PM +0200, Jan Beulich wrote:
>> On 15.09.2020 13:56, Roger Pau Monné wrote:
>>> On Mon, Sep 14, 2020 at 12:15:39PM +0200, Jan Beulich wrote:
>>>> Switch to $(call if_changed,ld) where possible; presumably not doing so
>>>> in e321576f4047 ("xen/build: start using if_changed") right away was an
>>>> oversight, as it did for Arm in (just) one case. It failed to add
>>>> prelink.o to $(targets), though, causing - judging from the observed
>>>> behavior on x86 - undue rebuilds of the final binary (because of
>>>> prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
>>>> because of .prelink.o.cmd not getting read) during "make install-xen".
>>>
>>> I'm not sure I follow why prelink.o needs to be added to targets, does
>>> this offer some kind of protection against rebuilds when doing make
>>> install?
>>
>> In a way, but (as I view it) not really. It is the use of ...
>>
>>> The switch to if_changed LGTM.
>>
>> ... if_changed which requires this. .*.cmd files will only be loaded
>> for anything explicitly or implicitly listed as a target. While .o
>> coming from $(obj-y) get added there automatically, prelink.o is not
>> something that could be recognized as needing adding, hence the
>> "manual" insertion.
> 
> This seems very prone to mistakes, as you have to remember that
> whatever object that uses if_changed should also be part of the
> targets set, or else it will get rebuild unconditionally.

The use of $(if_changed ...) has further similar pitfalls: One may
not forget to add FORCE to the dependencies, and there may not be
blanks after the comma (where one would usually put one). But I think
the benefits of this construct are so significant that this extra
care that's needed is well justified. Plus this is actually mentioned
(at least in passing) in docs/misc/xen-makefiles/makefile.rst.

> I think adding some of the above reasoning to the commit message would
> be helpful IMO.

Well, I've merely re-explained what I think the commit message
already says.

>> Without .prelink.o.cmd loaded, $(if_changed ) will always arrange
>> for it to get re-built, because it then will consider the command
>> used to build the file to have changed (as the stored one appears to
>> be empty).
> 
> Acked-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks.

Jan
Jan Beulich Sept. 21, 2020, 10:17 a.m. UTC | #5
On 14.09.2020 12:15, Jan Beulich wrote:
> Switch to $(call if_changed,ld) where possible; presumably not doing so
> in e321576f4047 ("xen/build: start using if_changed") right away was an
> oversight, as it did for Arm in (just) one case. It failed to add
> prelink.o to $(targets), though, causing - judging from the observed
> behavior on x86 - undue rebuilds of the final binary (because of
> prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
> because of .prelink.o.cmd not getting read) during "make install-xen".
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
>  xen/arch/arm/Makefile |  4 +++-
>  xen/arch/x86/Makefile | 18 ++++++++++--------
>  2 files changed, 13 insertions(+), 9 deletions(-)

May I ask for an Arm-side ack (or otherwise) here, please?

Jan

> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
> index 51173d97127e..296c5e68bbc3 100644
> --- a/xen/arch/arm/Makefile
> +++ b/xen/arch/arm/Makefile
> @@ -95,12 +95,14 @@ prelink_lto.o: $(ALL_OBJS)
>  
>  # Link it with all the binary objects
>  prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o
> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
> +	$(call if_changed,ld)
>  else
>  prelink.o: $(ALL_OBJS) FORCE
>  	$(call if_changed,ld)
>  endif
>  
> +targets += prelink.o
> +
>  $(TARGET)-syms: prelink.o xen.lds
>  	$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o \
>  	    $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0
> diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
> index 74152f2a0dad..9b368632fb43 100644
> --- a/xen/arch/x86/Makefile
> +++ b/xen/arch/x86/Makefile
> @@ -136,19 +136,21 @@ prelink_lto.o: $(ALL_OBJS)
>  	$(LD_LTO) -r -o $@ $^
>  
>  # Link it with all the binary objects
> -prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o $(EFI_OBJS-y)
> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
> +prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o $(EFI_OBJS-y) FORCE
> +	$(call if_changed,ld)
>  
> -prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o
> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
> +prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o FORCE
> +	$(call if_changed,ld)
>  else
> -prelink.o: $(ALL_OBJS) $(EFI_OBJS-y)
> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
> +prelink.o: $(ALL_OBJS) $(EFI_OBJS-y) FORCE
> +	$(call if_changed,ld)
>  
> -prelink-efi.o: $(ALL_OBJS)
> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
> +prelink-efi.o: $(ALL_OBJS) FORCE
> +	$(call if_changed,ld)
>  endif
>  
> +targets += prelink.o prelink-efi.o
> +
>  $(TARGET)-syms: prelink.o xen.lds
>  	$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
>  	    $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0
>
Julien Grall Sept. 21, 2020, 11:39 a.m. UTC | #6
Hi Jan,

On 21/09/2020 11:17, Jan Beulich wrote:
> On 14.09.2020 12:15, Jan Beulich wrote:
>> Switch to $(call if_changed,ld) where possible; presumably not doing so
>> in e321576f4047 ("xen/build: start using if_changed") right away was an
>> oversight, as it did for Arm in (just) one case. It failed to add
>> prelink.o to $(targets), though, causing - judging from the observed
>> behavior on x86 - undue rebuilds of the final binary (because of
>> prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
>> because of .prelink.o.cmd not getting read) during "make install-xen".
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> ---
>>   xen/arch/arm/Makefile |  4 +++-
>>   xen/arch/x86/Makefile | 18 ++++++++++--------
>>   2 files changed, 13 insertions(+), 9 deletions(-)
> 
> May I ask for an Arm-side ack (or otherwise) here, please?

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

> 
> Jan
> 
>> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
>> index 51173d97127e..296c5e68bbc3 100644
>> --- a/xen/arch/arm/Makefile
>> +++ b/xen/arch/arm/Makefile
>> @@ -95,12 +95,14 @@ prelink_lto.o: $(ALL_OBJS)
>>   
>>   # Link it with all the binary objects
>>   prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o
>> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
>> +	$(call if_changed,ld)
>>   else
>>   prelink.o: $(ALL_OBJS) FORCE
>>   	$(call if_changed,ld)
>>   endif
>>   
>> +targets += prelink.o
>> +
>>   $(TARGET)-syms: prelink.o xen.lds
>>   	$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o \
>>   	    $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0
>> diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
>> index 74152f2a0dad..9b368632fb43 100644
>> --- a/xen/arch/x86/Makefile
>> +++ b/xen/arch/x86/Makefile
>> @@ -136,19 +136,21 @@ prelink_lto.o: $(ALL_OBJS)
>>   	$(LD_LTO) -r -o $@ $^
>>   
>>   # Link it with all the binary objects
>> -prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o $(EFI_OBJS-y)
>> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
>> +prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o $(EFI_OBJS-y) FORCE
>> +	$(call if_changed,ld)
>>   
>> -prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o
>> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
>> +prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o FORCE
>> +	$(call if_changed,ld)
>>   else
>> -prelink.o: $(ALL_OBJS) $(EFI_OBJS-y)
>> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
>> +prelink.o: $(ALL_OBJS) $(EFI_OBJS-y) FORCE
>> +	$(call if_changed,ld)
>>   
>> -prelink-efi.o: $(ALL_OBJS)
>> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
>> +prelink-efi.o: $(ALL_OBJS) FORCE
>> +	$(call if_changed,ld)
>>   endif
>>   
>> +targets += prelink.o prelink-efi.o
>> +
>>   $(TARGET)-syms: prelink.o xen.lds
>>   	$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
>>   	    $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0
>>
>
Jan Beulich Sept. 22, 2020, 8:28 a.m. UTC | #7
On 21.09.2020 13:39, Julien Grall wrote:
> On 21/09/2020 11:17, Jan Beulich wrote:
>> On 14.09.2020 12:15, Jan Beulich wrote:
>>> Switch to $(call if_changed,ld) where possible; presumably not doing so
>>> in e321576f4047 ("xen/build: start using if_changed") right away was an
>>> oversight, as it did for Arm in (just) one case. It failed to add
>>> prelink.o to $(targets), though, causing - judging from the observed
>>> behavior on x86 - undue rebuilds of the final binary (because of
>>> prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
>>> because of .prelink.o.cmd not getting read) during "make install-xen".
>>>
>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>> ---
>>>   xen/arch/arm/Makefile |  4 +++-
>>>   xen/arch/x86/Makefile | 18 ++++++++++--------
>>>   2 files changed, 13 insertions(+), 9 deletions(-)
>>
>> May I ask for an Arm-side ack (or otherwise) here, please?
> 
> Acked-by: Julien Grall <jgrall@amazon.com>

Thanks. On the Arm side this is actually addressing a (minor) bug,
so I wonder whether I should queue this up for backporting. Do you
have an opinion either way?

Jan
Julien Grall Sept. 22, 2020, 9:24 a.m. UTC | #8
Hi Jan,

On 22/09/2020 09:28, Jan Beulich wrote:
> On 21.09.2020 13:39, Julien Grall wrote:
>> On 21/09/2020 11:17, Jan Beulich wrote:
>>> On 14.09.2020 12:15, Jan Beulich wrote:
>>>> Switch to $(call if_changed,ld) where possible; presumably not doing so
>>>> in e321576f4047 ("xen/build: start using if_changed") right away was an
>>>> oversight, as it did for Arm in (just) one case. It failed to add
>>>> prelink.o to $(targets), though, causing - judging from the observed
>>>> behavior on x86 - undue rebuilds of the final binary (because of
>>>> prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
>>>> because of .prelink.o.cmd not getting read) during "make install-xen".
>>>>
>>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>>> ---
>>>>    xen/arch/arm/Makefile |  4 +++-
>>>>    xen/arch/x86/Makefile | 18 ++++++++++--------
>>>>    2 files changed, 13 insertions(+), 9 deletions(-)
>>>
>>> May I ask for an Arm-side ack (or otherwise) here, please?
>>
>> Acked-by: Julien Grall <jgrall@amazon.com>
> 
> Thanks. On the Arm side this is actually addressing a (minor) bug,

Just to confirm, the bug is: Xen will be rebuilt when it is not 
necessary, right?

Cheers,
Jan Beulich Sept. 22, 2020, 10:55 a.m. UTC | #9
On 22.09.2020 11:24, Julien Grall wrote:
> On 22/09/2020 09:28, Jan Beulich wrote:
>> On 21.09.2020 13:39, Julien Grall wrote:
>>> On 21/09/2020 11:17, Jan Beulich wrote:
>>>> On 14.09.2020 12:15, Jan Beulich wrote:
>>>>> Switch to $(call if_changed,ld) where possible; presumably not doing so
>>>>> in e321576f4047 ("xen/build: start using if_changed") right away was an
>>>>> oversight, as it did for Arm in (just) one case. It failed to add
>>>>> prelink.o to $(targets), though, causing - judging from the observed
>>>>> behavior on x86 - undue rebuilds of the final binary (because of
>>>>> prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
>>>>> because of .prelink.o.cmd not getting read) during "make install-xen".
>>>>>
>>>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>>>> ---
>>>>>    xen/arch/arm/Makefile |  4 +++-
>>>>>    xen/arch/x86/Makefile | 18 ++++++++++--------
>>>>>    2 files changed, 13 insertions(+), 9 deletions(-)
>>>>
>>>> May I ask for an Arm-side ack (or otherwise) here, please?
>>>
>>> Acked-by: Julien Grall <jgrall@amazon.com>
>>
>> Thanks. On the Arm side this is actually addressing a (minor) bug,
> 
> Just to confirm, the bug is: Xen will be rebuilt when it is not 
> necessary, right?

Yes. When building as non-root but installing as root, this would
typically involve an owner change of some of the involved files.
That's how I did notice the issue on x86 (after switching to
if_changed) in the first place.

Jan
Julien Grall Sept. 22, 2020, 11:47 a.m. UTC | #10
Hi Jan,

On 22/09/2020 11:55, Jan Beulich wrote:
> On 22.09.2020 11:24, Julien Grall wrote:
>> On 22/09/2020 09:28, Jan Beulich wrote:
>>> On 21.09.2020 13:39, Julien Grall wrote:
>>>> On 21/09/2020 11:17, Jan Beulich wrote:
>>>>> On 14.09.2020 12:15, Jan Beulich wrote:
>>>>>> Switch to $(call if_changed,ld) where possible; presumably not doing so
>>>>>> in e321576f4047 ("xen/build: start using if_changed") right away was an
>>>>>> oversight, as it did for Arm in (just) one case. It failed to add
>>>>>> prelink.o to $(targets), though, causing - judging from the observed
>>>>>> behavior on x86 - undue rebuilds of the final binary (because of
>>>>>> prelink.o getting rebuild for $(cmd_prelink.o) being empty, in turn
>>>>>> because of .prelink.o.cmd not getting read) during "make install-xen".
>>>>>>
>>>>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>>>>> ---
>>>>>>     xen/arch/arm/Makefile |  4 +++-
>>>>>>     xen/arch/x86/Makefile | 18 ++++++++++--------
>>>>>>     2 files changed, 13 insertions(+), 9 deletions(-)
>>>>>
>>>>> May I ask for an Arm-side ack (or otherwise) here, please?
>>>>
>>>> Acked-by: Julien Grall <jgrall@amazon.com>
>>>
>>> Thanks. On the Arm side this is actually addressing a (minor) bug,
>>
>> Just to confirm, the bug is: Xen will be rebuilt when it is not
>> necessary, right?
> 
> Yes. When building as non-root but installing as root, this would
> typically involve an owner change of some of the involved files.
> That's how I did notice the issue on x86 (after switching to
> if_changed) in the first place.

Thanks for the explanation. I think it would be fine to backport.
@Stefano, what do you think?

Cheers,
Stefano Stabellini Sept. 22, 2020, 5:40 p.m. UTC | #11
On Tue, 22 Sep 2020, Julien Grall wrote:
> Hi Jan,
> 
> On 22/09/2020 11:55, Jan Beulich wrote:
> > On 22.09.2020 11:24, Julien Grall wrote:
> > > On 22/09/2020 09:28, Jan Beulich wrote:
> > > > On 21.09.2020 13:39, Julien Grall wrote:
> > > > > On 21/09/2020 11:17, Jan Beulich wrote:
> > > > > > On 14.09.2020 12:15, Jan Beulich wrote:
> > > > > > > Switch to $(call if_changed,ld) where possible; presumably not
> > > > > > > doing so
> > > > > > > in e321576f4047 ("xen/build: start using if_changed") right away
> > > > > > > was an
> > > > > > > oversight, as it did for Arm in (just) one case. It failed to add
> > > > > > > prelink.o to $(targets), though, causing - judging from the
> > > > > > > observed
> > > > > > > behavior on x86 - undue rebuilds of the final binary (because of
> > > > > > > prelink.o getting rebuild for $(cmd_prelink.o) being empty, in
> > > > > > > turn
> > > > > > > because of .prelink.o.cmd not getting read) during "make
> > > > > > > install-xen".
> > > > > > > 
> > > > > > > Signed-off-by: Jan Beulich <jbeulich@suse.com>
> > > > > > > ---
> > > > > > >     xen/arch/arm/Makefile |  4 +++-
> > > > > > >     xen/arch/x86/Makefile | 18 ++++++++++--------
> > > > > > >     2 files changed, 13 insertions(+), 9 deletions(-)
> > > > > > 
> > > > > > May I ask for an Arm-side ack (or otherwise) here, please?
> > > > > 
> > > > > Acked-by: Julien Grall <jgrall@amazon.com>
> > > > 
> > > > Thanks. On the Arm side this is actually addressing a (minor) bug,
> > > 
> > > Just to confirm, the bug is: Xen will be rebuilt when it is not
> > > necessary, right?
> > 
> > Yes. When building as non-root but installing as root, this would
> > typically involve an owner change of some of the involved files.
> > That's how I did notice the issue on x86 (after switching to
> > if_changed) in the first place.
> 
> Thanks for the explanation. I think it would be fine to backport.
> @Stefano, what do you think?

I am OK with that
diff mbox series

Patch

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 51173d97127e..296c5e68bbc3 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -95,12 +95,14 @@  prelink_lto.o: $(ALL_OBJS)
 
 # Link it with all the binary objects
 prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o
-	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
+	$(call if_changed,ld)
 else
 prelink.o: $(ALL_OBJS) FORCE
 	$(call if_changed,ld)
 endif
 
+targets += prelink.o
+
 $(TARGET)-syms: prelink.o xen.lds
 	$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o \
 	    $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 74152f2a0dad..9b368632fb43 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -136,19 +136,21 @@  prelink_lto.o: $(ALL_OBJS)
 	$(LD_LTO) -r -o $@ $^
 
 # Link it with all the binary objects
-prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o $(EFI_OBJS-y)
-	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
+prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o $(EFI_OBJS-y) FORCE
+	$(call if_changed,ld)
 
-prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o
-	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
+prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o FORCE
+	$(call if_changed,ld)
 else
-prelink.o: $(ALL_OBJS) $(EFI_OBJS-y)
-	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
+prelink.o: $(ALL_OBJS) $(EFI_OBJS-y) FORCE
+	$(call if_changed,ld)
 
-prelink-efi.o: $(ALL_OBJS)
-	$(LD) $(XEN_LDFLAGS) -r -o $@ $^
+prelink-efi.o: $(ALL_OBJS) FORCE
+	$(call if_changed,ld)
 endif
 
+targets += prelink.o prelink-efi.o
+
 $(TARGET)-syms: prelink.o xen.lds
 	$(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
 	    $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0