diff mbox series

[XEN,v3,18/23] xen/build: use if_changed on built_in.o

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

Commit Message

Anthony PERARD Feb. 26, 2020, 11:33 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>
---
 xen/Rules.mk | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Jan Beulich March 4, 2020, 4:03 p.m. UTC | #1
On 26.02.2020 12:33, Anthony PERARD wrote:
> --- a/xen/Rules.mk
> +++ b/xen/Rules.mk
> @@ -126,14 +126,21 @@ include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
>  c_flags += $(CFLAGS-y)
>  a_flags += $(CFLAGS-y) $(AFLAGS-y)
>  
> -built_in.o: $(obj-y) $(extra-y)
> +quiet_cmd_ld_builtin = LD      $@
> +cmd_ld_builtin = \
> +    $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$(real-prereqs))
> +quiet_cmd_cc_builtin = LD      $@
> +cmd_cc_builtin = \
> +    $(CC) $(XEN_CFLAGS) -c -x c /dev/null -o $@
> +
> +built_in.o: $(obj-y) $(extra-y) FORCE
>  ifeq ($(obj-y),)
> -	$(CC) $(c_flags) -c -x c /dev/null -o $@
> +	$(call if_changed,cc_builtin)
>  else
>  ifeq ($(CONFIG_LTO),y)
>  	$(LD_LTO) -r -o $@ $(filter-out $(extra-y),$^)

What about this? Couldn't you simply vary what cmd_ld_builtin
expands to, and drop this inner ifeq()?

Jan

>  else
> -	$(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^)
> +	$(call if_changed,ld_builtin)
>  endif
>  endif
>  
>
Anthony PERARD March 18, 2020, 10:55 a.m. UTC | #2
On Wed, Mar 04, 2020 at 05:03:40PM +0100, Jan Beulich wrote:
> On 26.02.2020 12:33, Anthony PERARD wrote:
> > --- a/xen/Rules.mk
> > +++ b/xen/Rules.mk
> > @@ -126,14 +126,21 @@ include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
> >  c_flags += $(CFLAGS-y)
> >  a_flags += $(CFLAGS-y) $(AFLAGS-y)
> >  
> > -built_in.o: $(obj-y) $(extra-y)
> > +quiet_cmd_ld_builtin = LD      $@
> > +cmd_ld_builtin = \
> > +    $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$(real-prereqs))
> > +quiet_cmd_cc_builtin = LD      $@
> > +cmd_cc_builtin = \
> > +    $(CC) $(XEN_CFLAGS) -c -x c /dev/null -o $@
> > +
> > +built_in.o: $(obj-y) $(extra-y) FORCE
> >  ifeq ($(obj-y),)
> > -	$(CC) $(c_flags) -c -x c /dev/null -o $@
> > +	$(call if_changed,cc_builtin)
> >  else
> >  ifeq ($(CONFIG_LTO),y)
> >  	$(LD_LTO) -r -o $@ $(filter-out $(extra-y),$^)
> 
> What about this? Couldn't you simply vary what cmd_ld_builtin
> expands to, and drop this inner ifeq()?

Yes, that should be possible. I was trying to leave CONFIG_LTO out, but
it's probably just make readability worse.

Thanks,
diff mbox series

Patch

diff --git a/xen/Rules.mk b/xen/Rules.mk
index bb4ced5f0dd4..cbf4feba0e0f 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -126,14 +126,21 @@  include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
 c_flags += $(CFLAGS-y)
 a_flags += $(CFLAGS-y) $(AFLAGS-y)
 
-built_in.o: $(obj-y) $(extra-y)
+quiet_cmd_ld_builtin = LD      $@
+cmd_ld_builtin = \
+    $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$(real-prereqs))
+quiet_cmd_cc_builtin = LD      $@
+cmd_cc_builtin = \
+    $(CC) $(XEN_CFLAGS) -c -x c /dev/null -o $@
+
+built_in.o: $(obj-y) $(extra-y) FORCE
 ifeq ($(obj-y),)
-	$(CC) $(c_flags) -c -x c /dev/null -o $@
+	$(call if_changed,cc_builtin)
 else
 ifeq ($(CONFIG_LTO),y)
 	$(LD_LTO) -r -o $@ $(filter-out $(extra-y),$^)
 else
-	$(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^)
+	$(call if_changed,ld_builtin)
 endif
 endif