[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [XEN PATCH v3 23/23] xen/build: use if_changed to build guest_%.o



On 26.02.2020 12:33, Anthony PERARD wrote:
> --- a/xen/Rules.mk
> +++ b/xen/Rules.mk
> @@ -115,6 +115,9 @@ endif
>  # FIXME LTO broken, but we would need a different way to filter -flto out
>  # $(obj-bin-y): CFLAGS := $(filter-out -flto,$(CFLAGS))
>  
> +# target with its suffix stripped
> +target-stem = $(basename $@)

I'd appreciate if the word "stem" was used in a makefile only for
what make doc uses it for - the part of the target of a pattern
rule that % matches. I.e. here perhaps name the variable
target-basename? (But see below, maybe this isn't needed.)

> --- a/xen/arch/x86/mm/Makefile
> +++ b/xen/arch/x86/mm/Makefile
> @@ -11,11 +11,14 @@ obj-y += p2m.o p2m-pt.o
>  obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o
>  obj-y += paging.o
>  
> -guest_walk_%.o: guest_walk.c Makefile
> -     $(CC) $(c_flags) -DGUEST_PAGING_LEVELS=$* -c $< -o $@
> +$(foreach gw,$(filter guest_walk_%.o,$(obj-y)),\
> +    $(eval CFLAGS_$(gw) = -DGUEST_PAGING_LEVELS=$$*))

So the $$* here matches ...

> -guest_walk_%.i: guest_walk.c Makefile
> -     $(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) -DGUEST_PAGING_LEVELS=$* 
> -c $< -o $@
> +guest_walk_%.o: guest_walk.c FORCE
> +     $(call if_changed_rule,cc_o_c)

... the stem of the target of this rule. This is not good. Can't
you have something like

guest_walk_%.o guest_walk_%.i guest_walk_%.s: CFLAGS_$(target-stem).o = 
-DGUEST_PAGING_LEVELS=$*

on a line immediately ahead of the rule, so that them having to
match up will be very obvious, and breakage of the connection
very noticable?

(Of course this also demonstrates that tying the CFLAGS modifier
to the object file name may be slightly confusing. But I don't
have a better suggestion. Question is whether here use of an
object [or whatever else] file specific variable is helpful at
all, when make already offers per-target variable customization.
Is there a specific reason the above couldn't e.g. be

guest_walk_%.o guest_walk_%.i guest_walk_%.s: CFLAGS-y += 
-DGUEST_PAGING_LEVELS=$*

?)

If this alternative worked, there'd be the positive side effect
of us avoiding the use of $(eval ) here - ISTR it not working
very reliably in make 3.80, which we still document as acceptable
for building.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.