diff mbox series

[XEN,v7,02/51] build: use if_changed on built_in.o

Message ID 20210824105038.1257926-3-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show
Series xen: Build system improvements, now with out-of-tree build! | expand

Commit Message

Anthony PERARD Aug. 24, 2021, 10:49 a.m. UTC
In the case where $(obj-y) is empty, we also replace $(c_flags) by
$(XEN_CFLAGS) to avoid generating an .%.d dependency file. This avoid
make trying to include %.h file in the ld command if $(obj-y) isn't
empty anymore on a second run.

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

Notes:
    v7:
    - Display "CC" for cmd_cc_builtin instead of "LD".
    
    v6:
    - use $(if $(strip $(obj-y)),ld_builtin,cc_builtin)
      as suggested
    - rebased
    
    v4:
    - Have cmd_ld_builtin depends on CONFIG_LTO, which simplify built_in.o
      rule.

 xen/Rules.mk | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/xen/Rules.mk b/xen/Rules.mk
index c99c4a9475c9..5a6a5d63260f 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -147,17 +147,22 @@  include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
 c_flags += $(CFLAGS-y)
 a_flags += $(CFLAGS-y) $(AFLAGS-y)
 
-built_in.o: $(obj-y) $(if $(strip $(lib-y)),lib.a) $(extra-y)
-ifeq ($(strip $(obj-y)),)
-	$(CC) $(c_flags) -c -x c /dev/null -o $@
-else
+quiet_cmd_cc_builtin = CC      $@
+cmd_cc_builtin = \
+    $(CC) $(XEN_CFLAGS) -c -x c /dev/null -o $@
+
+quiet_cmd_ld_builtin = LD      $@
 ifeq ($(CONFIG_LTO),y)
-	$(LD_LTO) -r -o $@ $(filter $(obj-y),$^)
+cmd_ld_builtin = \
+    $(LD_LTO) -r -o $@ $(filter $(obj-y),$(real-prereqs))
 else
-	$(LD) $(XEN_LDFLAGS) -r -o $@ $(filter $(obj-y),$^)
-endif
+cmd_ld_builtin = \
+    $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter $(obj-y),$(real-prereqs))
 endif
 
+built_in.o: $(obj-y) $(if $(strip $(lib-y)),lib.a) $(extra-y) FORCE
+	$(call if_changed,$(if $(strip $(obj-y)),ld_builtin,cc_builtin))
+
 lib.a: $(lib-y) FORCE
 	$(call if_changed,ar)