[XEN] xen/arch/x86/Makefile: Remove $(guard) use from $(TARGET).efi target
diff mbox series

Message ID 20191119175855.1716278-1-anthony.perard@citrix.com
State New
Headers show
Series
  • [XEN] xen/arch/x86/Makefile: Remove $(guard) use from $(TARGET).efi target
Related show

Commit Message

Anthony PERARD Nov. 19, 2019, 5:58 p.m. UTC
Following the patch 65d104984c04 ("x86: fix race to build
arch/x86/efi/relocs-dummy.o"), the error message
  nm: 'efi/relocs-dummy.o': No such file"
started to appear on system which can't build the .efi target. This is
because relocs-dummy.o isn't built anymore.
The error is printed by the evaluation of VIRT_BASE and ALT_BASE which
aren't use anyway.

But, we don't need that file as we don't want to build `$(TARGET).efi'
anyway.  On such system, $(guard) evaluate to the shell builtin ':',
which prevent any of the shell commands in `$(TARGET).efi' from been
executed.

Even if $(guard) is evaluated opon use, it depends on $(XEN_BUILD_PE)
which is evaluated at the assignment. So, we can replace $(guard) in
$(TARGET).efi by having two different rules depending on
$(XEN_BUILD_PE) instead.

The change with this patch is that none of the dependency of
$(TARGET).efi will be built if the linker doesn't support PE
and VIRT_BASE and ALT_BASE don't get evaluated anymore, so nm will not
complain about the missing relocs-dummy.o file anymore.

Since prelink-efi.o isn't built on system that can't build
$(TARGET).efi anymore, we can remove the $(guard) variable everywhere.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 xen/arch/x86/Makefile | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

Comments

Jan Beulich Nov. 20, 2019, 7:50 a.m. UTC | #1
On 19.11.2019 18:58, Anthony PERARD wrote:
> Following the patch 65d104984c04 ("x86: fix race to build
> arch/x86/efi/relocs-dummy.o"), the error message
>   nm: 'efi/relocs-dummy.o': No such file"
> started to appear on system which can't build the .efi target. This is
> because relocs-dummy.o isn't built anymore.
> The error is printed by the evaluation of VIRT_BASE and ALT_BASE which
> aren't use anyway.
> 
> But, we don't need that file as we don't want to build `$(TARGET).efi'
> anyway.  On such system, $(guard) evaluate to the shell builtin ':',
> which prevent any of the shell commands in `$(TARGET).efi' from been
> executed.
> 
> Even if $(guard) is evaluated opon use, it depends on $(XEN_BUILD_PE)
> which is evaluated at the assignment. So, we can replace $(guard) in
> $(TARGET).efi by having two different rules depending on
> $(XEN_BUILD_PE) instead.
> 
> The change with this patch is that none of the dependency of
> $(TARGET).efi will be built if the linker doesn't support PE
> and VIRT_BASE and ALT_BASE don't get evaluated anymore, so nm will not
> complain about the missing relocs-dummy.o file anymore.
> 
> Since prelink-efi.o isn't built on system that can't build
> $(TARGET).efi anymore, we can remove the $(guard) variable everywhere.

And indeed the need for it had disappeared with 18cd4997d2 ("x86/efi:
move the logic to detect PE build support").

> Reported-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Also Cc-ing Jürgen, as this addresses a (cosmetic) regression from
65d104984c ("x86: fix race to build arch/x86/efi/relocs-dummy.o").

> @@ -178,8 +178,6 @@ CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI
>  
>  $(TARGET).efi: VIRT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A VIRT_START$$,,p')
>  $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_START$$,,p')
> -# Don't use $(wildcard ...) here - at least make 3.80 expands this too early!
> -$(TARGET).efi: guard = $(if $(filter y,$(XEN_BUILD_PE)),,:)

It is particularly telling that the comment here had been stale
as of that earlier change from Roger, as the (shell level)
wildcard use was the whole reason for needing $(guard) here.

Jan
Juergen Gross Nov. 20, 2019, 3:50 p.m. UTC | #2
On 20.11.19 08:50, Jan Beulich wrote:
> On 19.11.2019 18:58, Anthony PERARD wrote:
>> Following the patch 65d104984c04 ("x86: fix race to build
>> arch/x86/efi/relocs-dummy.o"), the error message
>>    nm: 'efi/relocs-dummy.o': No such file"
>> started to appear on system which can't build the .efi target. This is
>> because relocs-dummy.o isn't built anymore.
>> The error is printed by the evaluation of VIRT_BASE and ALT_BASE which
>> aren't use anyway.
>>
>> But, we don't need that file as we don't want to build `$(TARGET).efi'
>> anyway.  On such system, $(guard) evaluate to the shell builtin ':',
>> which prevent any of the shell commands in `$(TARGET).efi' from been
>> executed.
>>
>> Even if $(guard) is evaluated opon use, it depends on $(XEN_BUILD_PE)
>> which is evaluated at the assignment. So, we can replace $(guard) in
>> $(TARGET).efi by having two different rules depending on
>> $(XEN_BUILD_PE) instead.
>>
>> The change with this patch is that none of the dependency of
>> $(TARGET).efi will be built if the linker doesn't support PE
>> and VIRT_BASE and ALT_BASE don't get evaluated anymore, so nm will not
>> complain about the missing relocs-dummy.o file anymore.
>>
>> Since prelink-efi.o isn't built on system that can't build
>> $(TARGET).efi anymore, we can remove the $(guard) variable everywhere.
> 
> And indeed the need for it had disappeared with 18cd4997d2 ("x86/efi:
> move the logic to detect PE build support").
> 
>> Reported-by: Jan Beulich <jbeulich@suse.com>
>> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> Also Cc-ing Jürgen, as this addresses a (cosmetic) regression from
> 65d104984c ("x86: fix race to build arch/x86/efi/relocs-dummy.o").

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen

Patch
diff mbox series

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index a6df19e901b3..a0b2f4ab1577 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -120,20 +120,20 @@  prelink_lto.o: $(ALL_OBJS)
 	$(LD_LTO) -r -o $@ $^
 
 prelink-efi_lto.o: $(ALL_OBJS) efi/runtime.o efi/compat.o
-	$(guard) $(LD_LTO) -r -o $@ $(filter-out %/efi/built_in.o,$^)
+	$(LD_LTO) -r -o $@ $(filter-out %/efi/built_in.o,$^)
 
 # Link it with all the binary objects
 prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o
 	$(LD) $(LDFLAGS) -r -o $@ $^
 
 prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink-efi_lto.o efi/boot.init.o
-	$(guard) $(LD) $(LDFLAGS) -r -o $@ $^
+	$(LD) $(LDFLAGS) -r -o $@ $^
 else
 prelink.o: $(ALL_OBJS)
 	$(LD) $(LDFLAGS) -r -o $@ $^
 
 prelink-efi.o: $(ALL_OBJS) efi/boot.init.o efi/runtime.o efi/compat.o
-	$(guard) $(LD) $(LDFLAGS) -r -o $@ $(filter-out %/efi/built_in.o,$^)
+	$(LD) $(LDFLAGS) -r -o $@ $(filter-out %/efi/built_in.o,$^)
 endif
 
 $(TARGET)-syms: prelink.o xen.lds
@@ -178,8 +178,6 @@  CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI
 
 $(TARGET).efi: VIRT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A VIRT_START$$,,p')
 $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_START$$,,p')
-# Don't use $(wildcard ...) here - at least make 3.80 expands this too early!
-$(TARGET).efi: guard = $(if $(filter y,$(XEN_BUILD_PE)),,:)
 
 ifneq ($(build_id_linker),)
 ifeq ($(call ld-ver-build-id,$(LD) $(filter -m%,$(EFI_LDFLAGS))),y)
@@ -197,27 +195,31 @@  note_file :=
 endif
 note_file_option ?= $(note_file)
 
+ifeq ($(filter y,$(XEN_BUILD_PE)),y)
 $(TARGET).efi: prelink-efi.o $(note_file) efi.lds efi/relocs-dummy.o efi/mkreloc
 	$(foreach base, $(VIRT_BASE) $(ALT_BASE), \
-	          $(guard) $(LD) $(call EFI_LDFLAGS,$(base)) -T efi.lds -N $< efi/relocs-dummy.o \
+	          $(LD) $(call EFI_LDFLAGS,$(base)) -T efi.lds -N $< efi/relocs-dummy.o \
 	                $(BASEDIR)/common/symbols-dummy.o $(note_file_option) -o $(@D)/.$(@F).$(base).0 &&) :
-	$(guard) efi/mkreloc $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(@D)/.$(@F).$(base).0) >$(@D)/.$(@F).0r.S
-	$(guard) $(NM) -pa --format=sysv $(@D)/.$(@F).$(VIRT_BASE).0 \
-		| $(guard) $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).0s.S
-	$(guard) $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0r.o $(@D)/.$(@F).0s.o
+	efi/mkreloc $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(@D)/.$(@F).$(base).0) >$(@D)/.$(@F).0r.S
+	$(NM) -pa --format=sysv $(@D)/.$(@F).$(VIRT_BASE).0 \
+		| $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).0s.S
+	$(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0r.o $(@D)/.$(@F).0s.o
 	$(foreach base, $(VIRT_BASE) $(ALT_BASE), \
-	          $(guard) $(LD) $(call EFI_LDFLAGS,$(base)) -T efi.lds -N $< \
+	          $(LD) $(call EFI_LDFLAGS,$(base)) -T efi.lds -N $< \
 	                $(@D)/.$(@F).0r.o $(@D)/.$(@F).0s.o $(note_file_option) -o $(@D)/.$(@F).$(base).1 &&) :
-	$(guard) efi/mkreloc $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(@D)/.$(@F).$(base).1) >$(@D)/.$(@F).1r.S
-	$(guard) $(NM) -pa --format=sysv $(@D)/.$(@F).$(VIRT_BASE).1 \
-		| $(guard) $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).1s.S
-	$(guard) $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o
-	$(guard) $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T efi.lds -N $< \
+	efi/mkreloc $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(@D)/.$(@F).$(base).1) >$(@D)/.$(@F).1r.S
+	$(NM) -pa --format=sysv $(@D)/.$(@F).$(VIRT_BASE).1 \
+		| $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).1s.S
+	$(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o
+	$(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T efi.lds -N $< \
 	                $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o $(note_file_option) -o $@
-	if $(guard) false; then rm -f $@; echo 'EFI support disabled'; \
-	else $(NM) -pa --format=sysv $(@D)/$(@F) \
-		| $(BASEDIR)/tools/symbols --xensyms --sysv --sort >$(@D)/$(@F).map; fi
+	$(NM) -pa --format=sysv $(@D)/$(@F) \
+		| $(BASEDIR)/tools/symbols --xensyms --sysv --sort >$(@D)/$(@F).map
 	rm -f $(@D)/.$(@F).[0-9]* $(@D)/..$(@F).[0-9]*
+else
+$(TARGET).efi: FORCE
+	rm -f $@; echo 'EFI support disabled'
+endif
 
 efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o efi/relocs-dummy.o: $(BASEDIR)/arch/x86/efi/built_in.o
 efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o efi/relocs-dummy.o: ;