From nobody Mon Feb 9 20:10:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1587485579; cv=none; d=zohomail.com; s=zohoarc; b=PwoADQT56D1D4MSsW6gPWHEx1EnFd5xwIRb66kuAdLJ+G+Vej4FLlCbwk+a6rN6es739nzl+ARC6GIj/nkbwUpjj/4z9nnKnvlcoCOQ/9LEztDmF6Sf8uEjUA99tHtxYtv92ZPN+2gCO/B9alqpo+WkVIFhIGWiB2M4PIrxtr0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587485579; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9LR0Ph7zsD0edH6XjWLHUTGYTJScMjRJKUyxlT8Ub8w=; b=Ztio3skXL6N0eOoAHnsBPOv3SCQFA9FiXLGwRx2tje4qezLw3rU0Y0cO2zbFgZCco9bb42OwbJpm6wUw3/QO7HhyucVk5xSeH2ojgcHRs6QyhsL7hOy9WjTkGGgNKo/7KoIGBau7okki4kAsGV3+uZFaE9u9v7oJ0ElItCLUCm8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1587485579061140.0243671930558; Tue, 21 Apr 2020 09:12:59 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jQvVt-0005Zf-TR; Tue, 21 Apr 2020 16:12:45 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jQvVs-0005YK-Gl for xen-devel@lists.xenproject.org; Tue, 21 Apr 2020 16:12:44 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ea4d0d60-83ea-11ea-9160-12813bfff9fa; Tue, 21 Apr 2020 16:12:36 +0000 (UTC) X-Inumbo-ID: ea4d0d60-83ea-11ea-9160-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1587485556; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IcWJ0C78z4awOosEvnLnoGUS16QfXFVHleO3sXQ7AYw=; b=BFs+G6LjlNlkHb0KgtWDVbIDiu0TzqpwGK5X/0EWodQx9a/2aLe8rS1r /gv1nYMPn9droDlNxYg6dH0pzImHOL6RbOGtNbGeKzxtXTmNyKaOWPK4r cO4nl7kGxc40M8usRqimyCdtAJVhPAnhDZnVSZcmkd5m3m+xEzjGqnx4P I=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: f/O9gcAXfrvfhD1I2LQQwBHJh+GjMWaJbVdq1ODda8g/jQty3UaSbP+N1tD7dvwzR4gg240XoU em8EtILsb1wpph+7wRBlY6SganCnbIATvhpwWHexQPmkjSP7+NwuoIFs3t4YIjk9sV3s3N+XFb caf88OoM4EzDtY+vsCA4HCD7PAetUSS8dqNI4/GGK1TcJHFHFFu9jCKlpv9SLmOPf97g4Rfnjf XknrTO89IH9Hp54hLNSdzrwYPWBo2iwQEh8KFmd56lkOvZ6lQTxkY34B8rgwwhnZ9V0b/YazXL K2Y= X-SBRS: 2.7 X-MesageID: 16414428 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,410,1580792400"; d="scan'208";a="16414428" From: Anthony PERARD To: Subject: [XEN PATCH v5 07/16] xen/build: Start using if_changed Date: Tue, 21 Apr 2020 17:11:59 +0100 Message-ID: <20200421161208.2429539-8-anthony.perard@citrix.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200421161208.2429539-1-anthony.perard@citrix.com> References: <20200421161208.2429539-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich , Anthony PERARD , Daniel De Graaf , Volodymyr Babchuk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 has changed, so the macro $(real-prereqs) must be used 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 generate .*.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 Reviewed-by: Roger Pau Monn=C3=A9 Acked-by: Jan Beulich Acked-by: Julien Grall --- Notes: v4: - typos - fix missing FORCE in libfdt/Makefile - typo flask vs flash in xsm - in xsm, use *_H_DEPEND in command lines of mkaccess and mkflask instead of $(real-prereq) to avoid including the script as argument of itself. 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 | 11 +++--- xen/xsm/flask/Makefile | 17 +++++++--- 7 files changed, 85 insertions(+), 35 deletions(-) diff --git a/xen/Rules.mk b/xen/Rules.mk index 21cac7f5f51a..2e28c572305a 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -56,6 +56,18 @@ SPECIAL_DATA_SECTIONS :=3D rodata $(foreach a,1 2 4 8 16= , \ =20 include Makefile =20 +# Linking +# ------------------------------------------------------------------------= --- + +quiet_cmd_ld =3D LD $@ +cmd_ld =3D $(LD) $(XEN_LDFLAGS) -r -o $@ $(real-prereqs) + +# Objcopy +# ------------------------------------------------------------------------= --- + +quiet_cmd_objcopy =3D OBJCOPY $@ +cmd_objcopy =3D $(OBJCOPY) $(OBJCOPYFLAGS) $< $@ + define gendep ifneq ($(1),$(subst /,:,$(1))) DEPS +=3D $(dir $(1)).$(notdir $(1)).d @@ -164,29 +176,47 @@ else $(CC) $(c_flags) -c $< -o $@ endif =20 -%.o: %.S Makefile - $(CC) $(a_flags) -c $< -o $@ +quiet_cmd_cc_o_S =3D CC $@ +cmd_cc_o_S =3D $(CC) $(a_flags) -c $< -o $@ + +%.o: %.S FORCE + $(call if_changed,cc_o_S) + + +quiet_cmd_obj_init_o =3D INIT_O $@ +define cmd_obj_init_o + $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | while read idx nam= e sz rest; do \ + case "$$name" in \ + .*.local) ;; \ + .text|.text.*|.data|.data.*|.bss) \ + test $$sz !=3D 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)= =3D.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 =3D CPP $@ +cmd_cpp_i_c =3D $(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) $< -o $@ + +quiet_cmd_cc_s_c =3D CC $@ +cmd_cc_s_c =3D $(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -S $< -o $@ =20 -$(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 s= z rest; do \ - case "$$name" in \ - .*.local) ;; \ - .text|.text.*|.data|.data.*|.bss) \ - test $$sz !=3D 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)=3D= .init.$(s)) $< $@ +quiet_cmd_s_S =3D CPP $@ +cmd_s_S =3D $(CPP) $(filter-out -Wa$(comma)%,$(a_flags)) $< -o $@ =20 -%.i: %.c Makefile - $(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) $< -o $@ +%.i: %.c FORCE + $(call if_changed,cpp_i_c) =20 -%.s: %.c Makefile - $(CC) $(filter-out -Wa$(comma)%,$(c_flags)) -S $< -o $@ +%.s: %.c FORCE + $(call if_changed,cc_s_c) =20 -%.s: %.S Makefile - $(CPP) $(filter-out -Wa$(comma)%,$(a_flags)) $< -o $@ +%.s: %.S FORCE + $(call if_changed,cpp_s_S) =20 # 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 9f1ab2335756..b79ad55646bd 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -97,8 +97,8 @@ prelink_lto.o: $(ALL_OBJS) prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_l= to.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 =20 $(TARGET)-syms: prelink.o xen.lds diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index a805e9982e85..44137d919b66 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -71,6 +71,7 @@ obj-$(CONFIG_TBOOT) +=3D tboot.o obj-y +=3D hpet.o obj-y +=3D vm_event.o obj-y +=3D xstate.o +extra-y +=3D asm-macros.i =20 x86_emulate.o: x86_emulate/x86_emulate.c x86_emulate/x86_emulate.h =20 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 +=3D -fshort-wchar =20 -%.o: %.ihex - $(OBJCOPY) -I ihex -O binary $< $@ +quiet_cmd_objcopy_o_ihex =3D OBJCOPY $@ +cmd_objcopy_o_ihex =3D $(OBJCOPY) -I ihex -O binary $< $@ + +%.o: %.ihex FORCE + $(call if_changed,objcopy_o_ihex) =20 boot.init.o: buildid.o =20 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 :=3D libelf.o nocov-y +=3D libelf.o +libelf-objs :=3D libelf-tools.o libelf-loader.o libelf-dominfo.o =20 SECTIONS :=3D text data $(SPECIAL_DATA_SECTIONS) +OBJCOPYFLAGS :=3D $(foreach s,$(SECTIONS),--rename-section .$(s)=3D.init.$= (s)) =20 CFLAGS-y +=3D -Wno-pointer-sign =20 -libelf.o: libelf-temp.o Makefile - $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=3D.init.$(s)) $= < $@ +libelf.o: libelf-temp.o FORCE + $(call if_changed,objcopy) =20 -libelf-temp.o: libelf-tools.o libelf-loader.o libelf-dominfo.o #libelf-rel= ocate.o - $(LD) $(XEN_LDFLAGS) -r -o $@ $^ +libelf-temp.o: $(libelf-objs) FORCE + $(call if_changed,ld) + +extra-y +=3D libelf-temp.o $(libelf-objs) diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile index e2a5e59380a0..6bd207cf8ffa 100644 --- a/xen/common/libfdt/Makefile +++ b/xen/common/libfdt/Makefile @@ -1,14 +1,17 @@ include Makefile.libfdt =20 SECTIONS :=3D text data $(SPECIAL_DATA_SECTIONS) +OBJCOPYFLAGS :=3D $(foreach s,$(SECTIONS),--rename-section .$(s)=3D.init.$= (s)) =20 obj-y +=3D libfdt.o nocov-y +=3D libfdt.o =20 CFLAGS-y +=3D -I$(BASEDIR)/include/xen/libfdt/ =20 -libfdt.o: libfdt-temp.o Makefile - $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=3D.init.$(s)) $= < $@ +libfdt.o: libfdt-temp.o FORCE + $(call if_changed,objcopy) =20 -libfdt-temp.o: $(LIBFDT_OBJS) - $(LD) $(XEN_LDFLAGS) -r -o $@ $^ +libfdt-temp.o: $(LIBFDT_OBJS) FORCE + $(call if_changed,ld) + +extra-y +=3D libfdt-temp.o $(LIBFDT_OBJS) diff --git a/xen/xsm/flask/Makefile b/xen/xsm/flask/Makefile index 6db396347b1f..eebfceecc5fb 100644 --- a/xen/xsm/flask/Makefile +++ b/xen/xsm/flask/Makefile @@ -20,12 +20,21 @@ AV_H_FILES =3D include/av_perm_to_string.h include/av_p= ermissions.h ALL_H_FILES =3D $(FLASK_H_FILES) $(AV_H_FILES) =20 $(obj-y) ss/built_in.o: $(ALL_H_FILES) +extra-y +=3D $(ALL_H_FILES) =20 -$(subst include/,%/,$(FLASK_H_FILES)): $(FLASK_H_DEPEND) - $(CONFIG_SHELL) policy/mkflask.sh $(AWK) include $(FLASK_H_DEPEND) +mkflask :=3D policy/mkflask.sh +quiet_cmd_mkflask =3D MKFLASK $@ +cmd_mkflask =3D $(CONFIG_SHELL) $(mkflask) $(AWK) include $(FLASK_H_DEPEND) =20 -$(subst include/,%/,$(AV_H_FILES)): $(AV_H_DEPEND) - $(CONFIG_SHELL) policy/mkaccess_vector.sh $(AWK) $(AV_H_DEPEND) +$(subst include/,%/,$(FLASK_H_FILES)): $(FLASK_H_DEPEND) $(mkflask) FORCE + $(call if_changed,mkflask) + +mkaccess :=3D policy/mkaccess_vector.sh +quiet_cmd_mkaccess =3D MKACCESS VECTOR $@ +cmd_mkaccess =3D $(CONFIG_SHELL) $(mkaccess) $(AWK) $(AV_H_DEPEND) + +$(subst include/,%/,$(AV_H_FILES)): $(AV_H_DEPEND) $(mkaccess) FORCE + $(call if_changed,mkaccess) =20 obj-bin-$(CONFIG_XSM_FLASK_POLICY) +=3D flask-policy.o flask-policy.o: policy.bin --=20 Anthony PERARD