From patchwork Tue Nov 7 16:31:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 118195 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4189985qgn; Tue, 7 Nov 2017 08:34:13 -0800 (PST) X-Google-Smtp-Source: ABhQp+QYorHyx28FL1rhu0+FTawLH6ovnmKs936jW53CfkulmBV8NhgrbKRNBLcLFdborhSaraWj X-Received: by 10.84.236.12 with SMTP id q12mr18495775plk.314.1510072453606; Tue, 07 Nov 2017 08:34:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510072453; cv=none; d=google.com; s=arc-20160816; b=IE8rf6vkQOvIlxF0yQUhKn3ieBIdPxYPXGoIlyagFR6RGAQFDpgIb+QntincqmG6xn gFC00c5HlXEJ+JnQ0KgTufmr1CI7mb3+QTn6kcakCYa/v3iDSKDQgX7YroMeZ45S7uAI ivGdIZ5dXlRxn2E4C1P4L86RB4hXw8tK6FWCg7tB55hul8NJKRcfD0IP1NVF3T4VdGVg m4MBtCwfC3jBnGVLuPeco1SgXdkixZZA1Mrh2ar8HAAgk1aMdHl5wqTIWuA3K5G0nTco 4/NbT7Ph+Cfe483exTMrMRir2J1dy46XfxbaIOZKcfw7ZNwB4zIN9oW1fPmxS1s/bl5G jmVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=vsamA0lxCZuqmejqmOwIvXGViwaLdFje50JepwwrXE8=; b=ziq2EjyL2DaIAGl9vayOyXLOajKH0/4cXckyjKJuIx7qv9dWEYNixjzGgK7SyHJLCM QanlhXizl7JoCdTxrIX+Rb3OBmjjqXoBoawKKWp8BRqcQnkwZgt5AL+PZj+TI5KgqFwu bbZfXu781cXuwxLoPqF76Pg1GjUfLUbhDVSgnoRst3J3btAaiPQcAjcX66A2NZfefaxw pXRsJ+UkPGWLyaSIopBzWL8wjFQAwwRm+bDEmINbRyslCwpCcVgclbXVfWHbfQyJlIFT NMcBjJ3MG3EfIzJ0HUpc60WSzDSZc2a4pPXzfytQKfXrtzQxa2iJqVY2aQUxJWR+LGS+ Q03g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ICBHYmqk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n15si1687506pfj.278.2017.11.07.08.34.13; Tue, 07 Nov 2017 08:34:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ICBHYmqk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965411AbdKGQeL (ORCPT + 26 others); Tue, 7 Nov 2017 11:34:11 -0500 Received: from conuserg-09.nifty.com ([210.131.2.76]:19281 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752330AbdKGQeG (ORCPT ); Tue, 7 Nov 2017 11:34:06 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-09.nifty.com with ESMTP id vA7GVppM022965; Wed, 8 Nov 2017 01:31:53 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com vA7GVppM022965 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1510072313; bh=vsamA0lxCZuqmejqmOwIvXGViwaLdFje50JepwwrXE8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ICBHYmqkQz2WIy8WBjCk7/DNjCx+miHLuR9hgBOrf97n5MeVMqNEaKAWP4ssjWMjL GsO0La6Qw7kJbmMKpxthIAT+S0YNUFbGgUYKGQTuOvfAWIShbx2QhI3hHIr0lxBF4D olNpMDQCmuOXWWTT+Vh3I79UPXO8vm3tX521vt6bTvnO3nD8ERCUSQsZyJZljo37j6 P4zZMJW6BjKbJgyMu5LPOuUDwrEFC+baE2TiZMvtCu7igOVQ++l3mxTrpZkZuvfefV q8MsIlPStoNcfYpVJQ234sQHxuQV5tSMR02oelh7i/ktLS+NQbBZBTbkJ41bwgf7N7 JygO0fUJf7MiA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Sam Ravnborg Cc: Rob Herring , Mark Rutland , Pantelis Antoniou , devicetree@vger.kernel.org, Arnd Bergmann , linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, Michal Marek , Masahiro Yamada , Michal Marek Subject: [PATCH 1/2] kbuild: create built-in.o automatically if parent directory wants it Date: Wed, 8 Nov 2017 01:31:46 +0900 Message-Id: <1510072307-16819-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510072307-16819-1-git-send-email-yamada.masahiro@socionext.com> References: <1510072307-16819-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "obj-y += foo/" syntax requires Kbuild to visit the "foo" subdirectory and link built-in.o from that directory. This means foo/Makefile is responsible for creating built-in.o even if there is no object to link (in this case, built-in.o is an empty archive). We have had several fixups like commit 4b024242e8a4 ("kbuild: Fix linking error built-in.o no such file or directory"), then ended up with a complex condition as follows: ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) builtin-target := $(obj)/built-in.o endif We still have more cases not covered by the above, so we need to add obj- := dummy.o in several places just for creating empty built-in.o. A key point is, the parent Makefile knows whether built-in.o is needed or not. If a subdirectory needs to create built-in.o, its parent can tell the fact when Kbuild descends into it. If non-empty $(need-builtin) flag is passed from the parent, built-in.o should be created. $(obj-y) should be still checked to support the single target "%/". All of ugly tricks will go away. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- scripts/Makefile.build | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 008a4e5..cc0b618 100644 --- a/Makefile +++ b/Makefile @@ -1003,7 +1003,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ; PHONY += $(vmlinux-dirs) $(vmlinux-dirs): prepare scripts - $(Q)$(MAKE) $(build)=$@ + $(Q)$(MAKE) $(build)=$@ need-builtin=1 define filechk_kernel.release echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 061d0c3..e1c6efd 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -84,7 +84,7 @@ lib-target := $(obj)/lib.a obj-y += $(obj)/lib-ksyms.o endif -ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) +ifneq ($(strip $(obj-y) $(need-builtin)),) builtin-target := $(obj)/built-in.o endif @@ -569,7 +569,7 @@ targets += $(multi-used-y) $(multi-used-m) PHONY += $(subdir-ym) $(subdir-ym): - $(Q)$(MAKE) $(build)=$@ + $(Q)$(MAKE) $(build)=$@ need-builtin=$(if $(findstring $@,$(subdir-obj-y)),1) # Add FORCE to the prequisites of a target to force it to be always rebuilt. # ---------------------------------------------------------------------------