Message ID | 20210824105038.1257926-40-anthony.perard@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | xen: Build system improvements, now with out-of-tree build! | expand |
On 24.08.2021 12:50, Anthony PERARD wrote: > When assigning a value a target-specific variable, that also affect > prerequisite of the target. This is mostly fine, but there is one case > where we will not want the COV_FLAGS added to the CFLAGS. > > In arch/x86/boot, we have "head.o" with "cmdline.S" as prerequisite > and ultimately "cmdline.o", we don't want COV_FLAGS to that last one. > > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> I think I understand what's going on, so Reviewed-by: Jan Beulich <jbeulich@suse.com> It would seem to me though that ... > --- a/xen/Rules.mk > +++ b/xen/Rules.mk > @@ -131,19 +131,31 @@ targets += $(targets-for-builtin) > > $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS-y += -DINIT_SECTIONS_ONLY > > +non-init-objects = $(filter-out %.init.o, $(obj-y) $(obj-bin-y) $(extra-y)) > + > ifeq ($(CONFIG_COVERAGE),y) > ifeq ($(CONFIG_CC_IS_CLANG),y) > COV_FLAGS := -fprofile-instr-generate -fcoverage-mapping > else > COV_FLAGS := -fprofile-arcs -ftest-coverage > endif > -$(filter-out %.init.o $(nocov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS-y += $(COV_FLAGS) > + > +$(non-init-objects): _c_flags += $(COV_FLAGS) > + > +# Reset COV_FLAGS in cases where an objects as another one as prerequisite > +$(nocov-y) $(filter %.init.o, $(obj-y) $(obj-bin-y) $(extra-y)): \ > + COV_FLAGS := ... pulling this and ... > endif > > ifeq ($(CONFIG_UBSAN),y) > # Any -fno-sanitize= options need to come after any -fsanitize= options > -$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): \ > -CFLAGS-y += $(filter-out -fno-%,$(CFLAGS_UBSAN)) $(filter -fno-%,$(CFLAGS_UBSAN)) > +UBSAN_FLAGS := $(filter-out -fno-%,$(CFLAGS_UBSAN)) $(filter -fno-%,$(CFLAGS_UBSAN)) > + > +$(non-init-objects): _c_flags += $(UBSAN_FLAGS) > + > +# Reset UBSAN_FLAGS in cases where an objects as another one as prerequisite > +$(noubsan-y) $(filter %.init.o, $(obj-y) $(obj-bin-y) $(extra-y)): \ > + UBSAN_FLAGS := ... this up ahead of their respective _c_flags assignments would be easier to follow, for being more logical (produce, then consume). Also, as a nit: In the comments do you mean "... where an object has ..."? Jan
diff --git a/xen/Rules.mk b/xen/Rules.mk index 1e1839c4b629..6877fcc2d6d8 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -131,19 +131,31 @@ targets += $(targets-for-builtin) $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS-y += -DINIT_SECTIONS_ONLY +non-init-objects = $(filter-out %.init.o, $(obj-y) $(obj-bin-y) $(extra-y)) + ifeq ($(CONFIG_COVERAGE),y) ifeq ($(CONFIG_CC_IS_CLANG),y) COV_FLAGS := -fprofile-instr-generate -fcoverage-mapping else COV_FLAGS := -fprofile-arcs -ftest-coverage endif -$(filter-out %.init.o $(nocov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS-y += $(COV_FLAGS) + +$(non-init-objects): _c_flags += $(COV_FLAGS) + +# Reset COV_FLAGS in cases where an objects as another one as prerequisite +$(nocov-y) $(filter %.init.o, $(obj-y) $(obj-bin-y) $(extra-y)): \ + COV_FLAGS := endif ifeq ($(CONFIG_UBSAN),y) # Any -fno-sanitize= options need to come after any -fsanitize= options -$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): \ -CFLAGS-y += $(filter-out -fno-%,$(CFLAGS_UBSAN)) $(filter -fno-%,$(CFLAGS_UBSAN)) +UBSAN_FLAGS := $(filter-out -fno-%,$(CFLAGS_UBSAN)) $(filter -fno-%,$(CFLAGS_UBSAN)) + +$(non-init-objects): _c_flags += $(UBSAN_FLAGS) + +# Reset UBSAN_FLAGS in cases where an objects as another one as prerequisite +$(noubsan-y) $(filter %.init.o, $(obj-y) $(obj-bin-y) $(extra-y)): \ + UBSAN_FLAGS := endif ifeq ($(CONFIG_LTO),y) @@ -172,6 +184,9 @@ a_flags = -MMD -MP -MF $(depfile) $(XEN_AFLAGS) include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk +c_flags += $(_c_flags) +a_flags += $(_c_flags) + c_flags += $(CFLAGS-y) a_flags += $(CFLAGS-y) $(AFLAGS-y)
When assigning a value a target-specific variable, that also affect prerequisite of the target. This is mostly fine, but there is one case where we will not want the COV_FLAGS added to the CFLAGS. In arch/x86/boot, we have "head.o" with "cmdline.S" as prerequisite and ultimately "cmdline.o", we don't want COV_FLAGS to that last one. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- xen/Rules.mk | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)