Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp3960077pjo; Tue, 3 Mar 2020 10:07:23 -0800 (PST) X-Google-Smtp-Source: ADFU+vspsGz4KiI1fyThZ2ENARMq3ys3BSk1Y9yYz3a9LkEwrBhZOZVErREcP8o/oQLDm59/iCla X-Received: by 2002:a9d:369:: with SMTP id 96mr498218otv.174.1583258843381; Tue, 03 Mar 2020 10:07:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583258843; cv=none; d=google.com; s=arc-20160816; b=aP5uU0Qcp2D0MYBLU4v2+Pveqm85dqg5WrmurVJLfS71MYvCro4WNYrATv8Rkgitjn 7kz7zo4YQQ0/mlN8D7dTMoVXg57RzxM5b1VyVn5lvN7cYfgwtRhqVno9LB6+cD4JFvM9 1lxcdLbI/yPy+ORPGvtI257OjwR1MmjbcTX1obcPmuZOxQVyM95MfLugJH3+wXL4zSWA 5Xv1X25besxhAu9/E5yDU5hyaSvR2NJDuon7koH+fCnqRfHLGVKWcz1SJXJxn1DOC7WW hAJtKh763eU9+CFj0rgcf+G93f5niOG2mOqfWWBnOE7C6X+CO3wBLIwKmsgXWYdPtDBZ YFtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LEjludbBnel3SpRWPE/c81Zr5Qi25O5dNFJxnvekJF4=; b=AHiZgg3ERAfyJfk+brYH9I9voL5iatgOzdsv0URP2WrFe2fc7uP9wKcVKpI0JhPDPA Br993WovWrJXCMui/UBhgdYBqX9rODm8rPS7FcMI6+XtQ51UdqsNygk91uB0T4rq4VrM d6OfK+xjycp7RkuCvShjW6fAXBlCZgPu+uQZj1tNVZIBZaDf5Ksldu6SaiMbFp0+/Biw FGrjaCab3AJDHz634m+wiZxqi5bLr2+jM+hTcRUqeQ5bu6U8bnciMJtMOTrZaNHDrrWE bgTuRvkxqXnTVRBsqi5LGzkb6aXaCrAbqbklWwlEy5Mb4LVd2f3GQgSxzV0rqxEQcw5x TwBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pG97AJxZ; 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 g35si1670282otg.32.2020.03.03.10.07.10; Tue, 03 Mar 2020 10:07:23 -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=@kernel.org header.s=default header.b=pG97AJxZ; 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 S2387943AbgCCSGX (ORCPT + 99 others); Tue, 3 Mar 2020 13:06:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:39362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732660AbgCCR47 (ORCPT ); Tue, 3 Mar 2020 12:56:59 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2449F20656; Tue, 3 Mar 2020 17:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583258217; bh=BjvBwR9wfIQkcbw6f/vc4ogNDAmbRZYRGuqdD7B4jQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pG97AJxZLDpxRrQpbjb27IseD00tLyLUkQ4Shxw6Ziu3O+xJI5tTVXsuR4PVmUqno WevRxOXlAOEqS8nQ73xzUsAjTQltISCtpkP/pZtIUnYs00+DXbxDJEthyMNQzqhoLi L9cmztVHV4zwYdpVOPqla0NsDarVHBneMZMyevDM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Jens Axboe Subject: [PATCH 5.4 116/152] kbuild: make single target builds even faster Date: Tue, 3 Mar 2020 18:43:34 +0100 Message-Id: <20200303174315.952250016@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174302.523080016@linuxfoundation.org> References: <20200303174302.523080016@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada commit b1fbfcb4a20949df08dd995927cdc5ad220c128d upstream. Commit 2dffd23f81a3 ("kbuild: make single target builds much faster") made the situation much better. To improve it even more, apply the similar idea to the top Makefile. Trim unrelated directories from build-dirs. The single build code must be moved above the 'descend' target. Signed-off-by: Masahiro Yamada Tested-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- Makefile | 90 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 43 deletions(-) --- a/Makefile +++ b/Makefile @@ -1635,6 +1635,50 @@ help: PHONY += prepare endif # KBUILD_EXTMOD +# Single targets +# --------------------------------------------------------------------------- +# To build individual files in subdirectories, you can do like this: +# +# make foo/bar/baz.s +# +# The supported suffixes for single-target are listed in 'single-targets' +# +# To build only under specific subdirectories, you can do like this: +# +# make foo/bar/baz/ + +ifdef single-build + +# .ko is special because modpost is needed +single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS))) +single-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS))) + +$(single-ko): single_modpost + @: +$(single-no-ko): descend + @: + +ifeq ($(KBUILD_EXTMOD),) +# For the single build of in-tree modules, use a temporary file to avoid +# the situation of modules_install installing an invalid modules.order. +MODORDER := .modules.tmp +endif + +PHONY += single_modpost +single_modpost: $(single-no-ko) + $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + +KBUILD_MODULES := 1 + +export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko)) + +# trim unrelated directories +build-dirs := $(foreach d, $(build-dirs), \ + $(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d))) + +endif + # Handle descending into subdirectories listed in $(build-dirs) # Preset locale variables to speed up the build process. Limit locale # tweaks to this spot to avoid wrong language settings when running @@ -1643,7 +1687,9 @@ endif # KBUILD_EXTMOD PHONY += descend $(build-dirs) descend: $(build-dirs) $(build-dirs): prepare - $(Q)$(MAKE) $(build)=$@ single-build=$(single-build) need-builtin=1 need-modorder=1 + $(Q)$(MAKE) $(build)=$@ \ + single-build=$(if $(filter-out $@/, $(single-no-ko)),1) \ + need-builtin=1 need-modorder=1 clean-dirs := $(addprefix _clean_, $(clean-dirs)) PHONY += $(clean-dirs) clean @@ -1747,48 +1793,6 @@ tools/%: FORCE $(Q)mkdir -p $(objtree)/tools $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $* -# Single targets -# --------------------------------------------------------------------------- -# To build individual files in subdirectories, you can do like this: -# -# make foo/bar/baz.s -# -# The supported suffixes for single-target are listed in 'single-targets' -# -# To build only under specific subdirectories, you can do like this: -# -# make foo/bar/baz/ - -ifdef single-build - -# .ko is special because modpost is needed -single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS))) -single-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS))) - -$(single-ko): single_modpost - @: -$(single-no-ko): descend - @: - -ifeq ($(KBUILD_EXTMOD),) -# For the single build of in-tree modules, use a temporary file to avoid -# the situation of modules_install installing an invalid modules.order. -MODORDER := .modules.tmp -endif - -PHONY += single_modpost -single_modpost: $(single-no-ko) - $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER) - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost - -KBUILD_MODULES := 1 - -export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko)) - -single-build = $(if $(filter-out $@/, $(single-no-ko)),1) - -endif - # FIXME Should go into a make.lib or something # ===========================================================================