From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>, "Wei Liu" <wl@xen.org>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"George Dunlap" <George.Dunlap@eu.citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Anthony PERARD" <anthony.perard@citrix.com>,
"Daniel De Graaf" <dgdegra@tycho.nsa.gov>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [XEN PATCH v3 17/23] xen/build: Start using if_changed
Date: Wed, 26 Feb 2020 11:33:49 +0000 [thread overview]
Message-ID: <20200226113355.2532224-18-anthony.perard@citrix.com> (raw)
In-Reply-To: <20200226113355.2532224-1-anthony.perard@citrix.com>
This patch start to use if_changed introduced in a previous commit.
Whenever if_changed is called, the target must have FORCE as
dependency so that if_changed can check if the command line to be
run as changed, so the macro $(real-prereqs) must be use to
discover the dependencies without "FORCE".
Whenever a target isn't in obj-y, it should be added to extra-y so the
.*.cmd dependency file associated with the target can be loaded. This
is done for xsm/flask/ and both common/lib{elf,fdt}/ and
arch/x86/Makefile.
For the targets that generates .*.d dependency files, there's going to
be two dependency files (.*.d and .*.cmd) until we can merge them
together in a later patch via fixdep from Linux.
One cleanup, libelf-relocate.o doesn't exist anymore.
We import cmd_ld and cmd_objcopy from Linux v5.4.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
xen/Rules.mk | 68 +++++++++++++++++++++++++++-----------
xen/arch/arm/Makefile | 4 +--
xen/arch/x86/Makefile | 1 +
xen/arch/x86/efi/Makefile | 7 ++--
xen/common/libelf/Makefile | 12 ++++---
xen/common/libfdt/Makefile | 9 +++--
xen/xsm/flask/Makefile | 17 +++++++---
7 files changed, 84 insertions(+), 34 deletions(-)
diff --git a/xen/Rules.mk b/xen/Rules.mk
index 8807a2e21c94..bb4ced5f0dd4 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -52,6 +52,18 @@ SPECIAL_DATA_SECTIONS := rodata $(foreach a,1 2 4 8 16, \
include Makefile
+# Linking
+# ---------------------------------------------------------------------------
+
+quiet_cmd_ld = LD $@
+cmd_ld = $(LD) $(XEN_LDFLAGS) -r -o $@ $(real-prereqs)
+
+# Objcopy
+# ---------------------------------------------------------------------------
+
+quiet_cmd_objcopy = OBJCOPY $@
+cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $< $@
+
define gendep
ifneq ($(1),$(subst /,:,$(1)))
DEPS += $(dir $(1)).$(notdir $(1)).d
@@ -161,29 +173,47 @@ else
$(CC) $(c_flags) -c $< -o $@
endif
-%.o: %.S Makefile
- $(CC) $(a_flags) -c $< -o $@
+quiet_cmd_cc_o_S = CC $@
+cmd_cc_o_S = $(CC) $(a_flags) -c $< -o $@
+
+%.o: %.S FORCE
+ $(call if_changed,cc_o_S)
+
+
+quiet_cmd_obj_init_o = INIT_O $@
+define cmd_obj_init_o
+ $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | while read idx name sz rest; do \
+ case "$$name" in \
+ .*.local) ;; \
+ .text|.text.*|.data|.data.*|.bss) \
+ test $$sz != 0 || continue; \
+ echo "Error: size of $<:$$name is 0x$$sz" >&2; \
+ exit $$(expr $$idx + 1);; \
+ esac; \
+ done; \
+ $(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
+endef
+
+$(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): %.init.o: %.o FORCE
+ $(call if_changed,obj_init_o)
+
+quiet_cmd_cpp_i_c = CPP $@
+cmd_cpp_i_c = $(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) $< -o $@
+
+quiet_cmd_cc_s_c = CC $@
+cmd_cc_s_c = $(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -S $< -o $@
-$(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): %.init.o: %.o Makefile
- $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | while read idx name sz rest; do \
- case "$$name" in \
- .*.local) ;; \
- .text|.text.*|.data|.data.*|.bss) \
- test $$sz != 0 || continue; \
- echo "Error: size of $<:$$name is 0x$$sz" >&2; \
- exit $$(expr $$idx + 1);; \
- esac; \
- done
- $(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
+quiet_cmd_s_S = CPP $@
+cmd_s_S = $(CPP) $(filter-out -Wa$(comma)%,$(a_flags)) $< -o $@
-%.i: %.c Makefile
- $(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) $< -o $@
+%.i: %.c FORCE
+ $(call if_changed,cpp_i_c)
-%.s: %.c Makefile
- $(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -S $< -o $@
+%.s: %.c FORCE
+ $(call if_changed,cc_s_c)
-%.s: %.S Makefile
- $(CPP) $(filter-out -Wa$(comma)%,$(a_flags)) $< -o $@
+%.s: %.S FORCE
+ $(call if_changed,cpp_s_S)
# Add intermediate targets:
# When building objects with specific suffix patterns, add intermediate
diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 1599e2ba4058..37ca6d25c08e 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -98,8 +98,8 @@ prelink_lto.o: $(ALL_OBJS)
prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o
$(LD) $(XEN_LDFLAGS) -r -o $@ $^
else
-prelink.o: $(ALL_OBJS)
- $(LD) $(XEN_LDFLAGS) -r -o $@ $^
+prelink.o: $(ALL_OBJS) FORCE
+ $(call if_changed,ld)
endif
$(TARGET)-syms: prelink.o xen.lds
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 5de873cf693e..6fb6cafdf47b 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -74,6 +74,7 @@ obj-$(CONFIG_TBOOT) += tboot.o
obj-y += hpet.o
obj-y += vm_event.o
obj-y += xstate.o
+extra-y += asm-macros.i
x86_emulate.o: x86_emulate/x86_emulate.c x86_emulate/x86_emulate.h
diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile
index 490d791aae2d..3e4c395b7535 100644
--- a/xen/arch/x86/efi/Makefile
+++ b/xen/arch/x86/efi/Makefile
@@ -1,7 +1,10 @@
CFLAGS-y += -fshort-wchar
-%.o: %.ihex
- $(OBJCOPY) -I ihex -O binary $< $@
+quiet_cmd_objcopy_o_ihex = OBJCOPY $@
+cmd_objcopy_o_ihex = $(OBJCOPY) -I ihex -O binary $< $@
+
+%.o: %.ihex FORCE
+ $(call if_changed,objcopy_o_ihex)
boot.init.o: buildid.o
diff --git a/xen/common/libelf/Makefile b/xen/common/libelf/Makefile
index 464c448d9d37..a92326c982e9 100644
--- a/xen/common/libelf/Makefile
+++ b/xen/common/libelf/Makefile
@@ -1,12 +1,16 @@
obj-bin-y := libelf.o
nocov-y += libelf.o
+libelf-objs := libelf-tools.o libelf-loader.o libelf-dominfo.o
SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
+OBJCOPYFLAGS := $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s))
CFLAGS-y += -Wno-pointer-sign
-libelf.o: libelf-temp.o Makefile
- $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
+libelf.o: libelf-temp.o FORCE
+ $(call if_changed,objcopy)
-libelf-temp.o: libelf-tools.o libelf-loader.o libelf-dominfo.o #libelf-relocate.o
- $(LD) $(XEN_LDFLAGS) -r -o $@ $^
+libelf-temp.o: $(libelf-objs) FORCE
+ $(call if_changed,ld)
+
+extra-y += libelf-temp.o $(libelf-objs)
diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile
index e2a5e59380a0..3efa5c5f8ed3 100644
--- a/xen/common/libfdt/Makefile
+++ b/xen/common/libfdt/Makefile
@@ -1,14 +1,17 @@
include Makefile.libfdt
SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
+OBJCOPYFLAGS := $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s))
obj-y += libfdt.o
nocov-y += libfdt.o
CFLAGS-y += -I$(BASEDIR)/include/xen/libfdt/
-libfdt.o: libfdt-temp.o Makefile
- $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
+libfdt.o: libfdt-temp.o FORCE
+ $(call if_changed,objcopy)
libfdt-temp.o: $(LIBFDT_OBJS)
- $(LD) $(XEN_LDFLAGS) -r -o $@ $^
+ $(call if_changed,ld)
+
+extra-y += libfdt-temp.o $(LIBFDT_OBJS)
diff --git a/xen/xsm/flask/Makefile b/xen/xsm/flask/Makefile
index 011ef5ca91f8..789e8fa1e3f9 100644
--- a/xen/xsm/flask/Makefile
+++ b/xen/xsm/flask/Makefile
@@ -20,12 +20,21 @@ AV_H_FILES = include/av_perm_to_string.h include/av_permissions.h
ALL_H_FILES = $(FLASK_H_FILES) $(AV_H_FILES)
$(obj-y) ss/built_in.o: $(ALL_H_FILES)
+extra-y += $(ALL_H_FILES)
-$(FLASK_H_FILES): $(FLASK_H_DEPEND)
- $(CONFIG_SHELL) policy/mkflask.sh $(AWK) include $(FLASK_H_DEPEND)
+mkflask := policy/mkflask.sh
+quiet_cmd_mkflash = MKFLASH $@
+cmd_mkflash = $(CONFIG_SHELL) $(mkflask) $(AWK) include $(real-prereqs)
-$(AV_H_FILES): $(AV_H_DEPEND)
- $(CONFIG_SHELL) policy/mkaccess_vector.sh $(AWK) $(AV_H_DEPEND)
+$(FLASK_H_FILES): $(FLASK_H_DEPEND) $(mkflash) FORCE
+ $(call if_changed,mkflash)
+
+mkaccess_vector := policy/mkaccess_vector.sh
+quiet_cmd_mkaccess_vector = MKACCESS VECTOR $@
+cmd_mkaccess_vector = $(CONFIG_SHELL) $(mkaccess_vector) $(AWK) $(real-prereqs)
+
+$(AV_H_FILES): $(AV_H_DEPEND) $(mkaccess_vector) FORCE
+ $(call if_changed,mkaccess_vector)
obj-bin-$(CONFIG_XSM_FLASK_POLICY) += flask-policy.o
flask-policy.o: policy.bin
--
Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2020-02-26 11:41 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-26 11:33 [Xen-devel] [XEN PATCH v3 00/23] xen: Build system improvements Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 01/23] xen/include: remove include of Config.mk Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 02/23] Makefile: Fix install-tests Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 03/23] xen/build: Remove confusing comment on the %.s:%.S rule Anthony PERARD
2020-02-26 11:53 ` Wei Liu
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 04/23] xen/build: remove use of AFLAGS-y Anthony PERARD
2020-02-26 12:58 ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 05/23] xen/build: Allow to test clang .include without asm symlink Anthony PERARD
2020-02-27 9:05 ` Roger Pau Monné
2020-02-27 9:22 ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 06/23] xen/build: Fix section-renaming of libfdt and libelf Anthony PERARD
2020-02-27 9:38 ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 07/23] xen/build: Use obj-y += subdir/ instead of subdir-y Anthony PERARD
2020-02-27 9:22 ` Roger Pau Monné
2020-02-27 9:43 ` Jan Beulich
2020-03-04 14:14 ` Jan Beulich
2020-03-05 9:24 ` Jan Beulich
2020-03-05 13:42 ` Andrew Cooper
2020-03-05 15:02 ` Julien Grall
2020-03-05 15:59 ` Anthony PERARD
2020-03-05 16:31 ` Julien Grall
2020-03-09 6:46 ` Tian, Kevin
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 08/23] xen/build: use $(clean) shorthand for clean targets Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 09/23] xen/build: extract clean target from Rules.mk Anthony PERARD
2020-03-04 14:13 ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 10/23] xen/build: run targets csopes, tags, .. without Rules.mk Anthony PERARD
2020-03-04 14:17 ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 11/23] xen/build: make tests in test/ directly Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 12/23] xen/build: Move as-option-add to xen/ Anthony PERARD
2020-03-04 14:17 ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 13/23] xen/build: include include/config/auto.conf in main Makefile Anthony PERARD
2020-03-04 14:29 ` Jan Beulich
2020-03-10 17:10 ` Anthony PERARD
2020-03-11 9:26 ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 14/23] xen/build: use new $(c_flags) and $(a_flags) instead of $(CFLAGS) Anthony PERARD
2020-02-27 10:22 ` Roger Pau Monné
2020-03-10 17:55 ` Anthony PERARD
2020-03-04 14:42 ` Jan Beulich
2020-03-10 17:43 ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 15/23] xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-02-27 11:05 ` Roger Pau Monné
2020-03-17 18:05 ` Anthony PERARD
2020-03-19 16:24 ` Anthony PERARD
2020-03-23 15:11 ` Roger Pau Monné
2020-03-24 17:11 ` [Xen-devel] " Anthony PERARD
2020-03-04 15:00 ` Jan Beulich
2020-03-17 18:35 ` Anthony PERARD
2020-03-18 10:20 ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 16/23] xen/build: introduce if_changed and if_changed_rule Anthony PERARD
2020-03-04 15:45 ` Jan Beulich
2020-03-18 10:44 ` Anthony PERARD
2020-03-18 11:14 ` Jan Beulich
2020-02-26 11:33 ` Anthony PERARD [this message]
2020-02-27 13:09 ` [Xen-devel] [XEN PATCH v3 17/23] xen/build: Start using if_changed Roger Pau Monné
2020-03-04 16:00 ` Jan Beulich
2020-03-18 10:52 ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 18/23] xen/build: use if_changed on built_in.o Anthony PERARD
2020-03-04 16:03 ` Jan Beulich
2020-03-18 10:55 ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 19/23] xen/build: Use if_changed_rules with %.o:%.c targets Anthony PERARD
2020-03-04 16:09 ` Jan Beulich
2020-03-18 11:14 ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 20/23] xen/build: factorise generation of the linker scripts Anthony PERARD
2020-02-27 13:14 ` Roger Pau Monné
2020-03-05 11:07 ` Jan Beulich
2020-03-05 11:05 ` Jan Beulich
2020-03-18 11:59 ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 21/23] xen/build: Use if_changed for prelink*.o Anthony PERARD
2020-02-27 13:16 ` Roger Pau Monné
2020-03-04 16:12 ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 22/23] xen, symbols: rework file symbols selection Anthony PERARD
2020-03-05 14:44 ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 23/23] xen/build: use if_changed to build guest_%.o Anthony PERARD
2020-03-05 15:12 ` Jan Beulich
2020-02-27 21:17 ` [Xen-devel] [XEN PATCH v3 00/23] xen: Build system improvements Stewart Hildebrand
2020-03-06 10:12 ` Anthony PERARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200226113355.2532224-18-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=konrad.wilk@oracle.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).