From patchwork Wed Dec 7 14:13:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Pratt X-Patchwork-Id: 1713330 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=dYl5up0r; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NRzqx5Ywpz23yq for ; Thu, 8 Dec 2022 01:17:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:List-Help: Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:From:List-Post:List-Id: Message-ID:MIME-Version:Subject:To:Date:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=j+ajmyiEFclRHxCJEcVLa4qtG2bE75Gg69nxx5UWnA8=; b=dYl5up0rJLfW24FjYdDJCnJ991 nJjCWlMVxl7cjrjpp2IbfTwfqbJHjgm1o/o9c5OfC3WHAUVJ8C6dcSjm8mxqYUdNd8Epqcj//ryRp iw4uX6tooG8txpj3e8QU28X2KBs8i9AX2pEPofaYGHSfapxbjRNEtD6BHr2LYP0fr4Xy2kDkVyP4X 94UB2OsXdOrCKhRxqpzONlgBrEv2MqWbk3AeAQJ4R8Dp/AInREqQdc5/AE4lEkZNBJLTdQF5d+HB8 ErDGLzXa0Ex8hHNLCQSYSDqFJ6R5UAVwpZfj1ig978w1xqyxOeGL9GHxT7oE7FOzDigUYcOLfVpmC r482E1zw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2vB0-004c38-OW; Wed, 07 Dec 2022 14:13:34 +0000 Date: Wed, 07 Dec 2022 14:13:22 +0000 To: openwrt-devel@lists.openwrt.org Subject: [PATCH v2] image: fix device profile specific COMPILE targets MIME-Version: 1.0 Message-ID: List-Id: OpenWrt Development List List-Post: X-Patchwork-Original-From: Michael Pratt via openwrt-devel From: Michael Pratt Precedence: list X-Mailman-Version: 2.1.34 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Michael Pratt List-Help: Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. Commit a01d23e75 ("image: always rebuild kernel loaders") is a step in the right direction, but exposed some issues and regressions in the makefile. 1. Some of the files made by device specific COMPILE targets start with an "append" command (i.e. >> instead of > redirection) and if the file already exists, the target file is an input to itself before the first recipe input to the file. 2. Some of the device specific COMPILE targets, like the lzma-loader have multiple steps and the uImage target requires the bin or ELF target first, so the two COMPILE targets cannot be run in parallel. 3. A side-effect of FORCE, is that all COMPILE targets will be built, even for devices in a build that are not selected, causing for example, the lzma-loader for some devices to be built when the image for that device is not built. 4. By making the COMPILE targets a prerequisite of the "target/compile" phase of the build, it is being built again in the "target/install" phase of the build, since the compile phase is a prerequisite of the install phase and the FORCE target is used on each file in each submake, but COMPILE targets are not needed before "target/install". This commit resolves these issues by calling COMPILE targets only in "target/install", using pattern substitution to list prerequisites between COMPILE targets in order, deleting the target before building it, and using device profile selection to determine if the COMPILE targets are FORCE built. Because of the nature of defining prerequisites in Make, (reverse dependency before dependency) the entire list of COMPILE targets is reversed in order to list prerequisites between them without having to work with individual words. Fixes: a01d23e75 ("image: always rebuild kernel loaders") Fixes: a7fb589e8 ("image: always rebuild kernel loaders") Signed-off-by: Michael Pratt --- include/image.mk | 8 ++++++-- rules.mk | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/image.mk b/include/image.mk index e9dc53f82e..c09dba3f2c 100644 --- a/include/image.mk +++ b/include/image.mk @@ -517,9 +517,13 @@ endef endif define Device/Build/compile - $$(_COMPILE_TARGET): $(KDIR)/$(1) + $$(_TARGET): $(KDIR)/$(1) $(eval $(call Device/Export,$(KDIR)/$(1))) - $(KDIR)/$(1): FORCE + + $(patsubst %$(1),%$(1):,$(call reverse,$(foreach compile,$(COMPILE),$(KDIR)/$(compile)))) + + $(KDIR)/$(1): $(if $(_PROFILE_SET),FORCE) + rm -f $(KDIR)/$(1) $$(call concat_cmd,$(COMPILE/$(1))) endef diff --git a/rules.mk b/rules.mk index 2de43d490d..782f84d625 100644 --- a/rules.mk +++ b/rules.mk @@ -53,6 +53,8 @@ __tr_template = $(__tr_head)$$(1)$(__tr_tail) $(eval toupper = $(call __tr_template,$(chars_lower),$(chars_upper))) $(eval tolower = $(call __tr_template,$(chars_upper),$(chars_lower))) +reverse = $(if $(word 2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1))) $(firstword $(1)),$(1)) + version_abbrev = $(if $(if $(CHECK),,$(DUMP)),$(1),$(shell printf '%.8s' $(1))) _SINGLE=export MAKEFLAGS=$(space);