From: Jan Beulich Date: Fri, 11 Dec 2020 10:53:24 +0000 (+0100) Subject: xen: fix build when $(obj-y) consists of just blanks X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~1333 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8e0fe4fe5fd89d80a362d8a9a46726aded3b49c4;p=xen.git xen: fix build when $(obj-y) consists of just blanks This case can occur when combining empty lists obj-y := ... obj-y += $(empty) or obj-y := $(empty) $(empty) where (only) blanks would accumulate. This was only a latent issue until now, but would become an active issue for Arm once lib/ gets populated with all respective objects going into the to be introduced lib.a. Also address a related issue at this occasion: When an empty built_in.o gets created, .built_in.o.d will have its dependencies recorded. If, on a subsequent incremental build, an actual constituent of built_in.o appeared, the $(filter-out ) would leave these recorded dependencies in place. But of course the linker won't know what to do with C header files. (The apparent alternative of avoiding to pass $(c_flags) or $(a_flags) would not be reliable afaict, as among these flags there may be some affecting information conveyed via the object file to the linker. The linker, finding inconsistent flags across object files, may then error out.) Using just $(obj-y) won't work either: It breaks when the same object file is listed more than once. Reported-by: Julien Grall Signed-off-by: Jan Beulich Acked-by: Wei Liu Reviewed-by: Bertrand Marquis Reviewed-by: Anthony PERARD --- diff --git a/xen/Rules.mk b/xen/Rules.mk index 333e19bec3..d5e5eb33de 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -130,13 +130,13 @@ c_flags += $(CFLAGS-y) a_flags += $(CFLAGS-y) $(AFLAGS-y) built_in.o: $(obj-y) $(extra-y) -ifeq ($(obj-y),) +ifeq ($(strip $(obj-y)),) $(CC) $(c_flags) -c -x c /dev/null -o $@ else ifeq ($(CONFIG_LTO),y) - $(LD_LTO) -r -o $@ $(filter-out $(extra-y),$^) + $(LD_LTO) -r -o $@ $(filter $(obj-y),$^) else - $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^) + $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter $(obj-y),$^) endif endif @@ -145,10 +145,10 @@ targets += $(filter-out $(subdir-obj-y), $(obj-y)) $(extra-y) targets += $(MAKECMDGOALS) built_in_bin.o: $(obj-bin-y) $(extra-y) -ifeq ($(obj-bin-y),) +ifeq ($(strip $(obj-bin-y)),) $(CC) $(a_flags) -c -x assembler /dev/null -o $@ else - $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^) + $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter $(obj-bin-y),$^) endif # Force execution of pattern rules (for which PHONY cannot be directly used).