Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10063245ybi; Wed, 10 Jul 2019 22:48:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqx24177k5EXyNQvdyE0HfKiwLMGXb1E5cGkyCp7CvDDG8GXch5G0pSJBlz6YDlsl29mMHKH X-Received: by 2002:a17:902:7c05:: with SMTP id x5mr2555819pll.321.1562824124933; Wed, 10 Jul 2019 22:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562824124; cv=none; d=google.com; s=arc-20160816; b=zhoF2wgQ191w4mGfnLAryUul9VijUx/IfzB56xu4FCtN3lIOXZERkE+7m+ObjNH9dL f3JZCOnwupN9QnU7gqs56c59ZioQ8JS2gfiZpUlkqgalyElGAoSCBgByr6/gzRHEt6TE /AMt9Z31oH454njthn4w5vZpEMnp7Q419Jv2+gydwPiKZqhJIu5rhLCXXkZPLfQXGfer dU+IR1MPj6MxyKkMnqp+W74FUlEztQTIJmWpSBvSeh/4LXJjCViqPqfg2qyBDG/DjARl 1Uuv7ESWo1QQjlbTSG61MM2G0Ru+Z15anadOUF6tcHX/j1p3bMQ4XNnD/izCLrEhGk0w Jqpg== 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; bh=iRp9Du8hIMlIwOLhJe7rDNMn7P7N/4zadqD4+iwRwl8=; b=cC50qu2WUbZh5RteTYzQhiiSttzTiYN5jBdIVUe0Hxfkxy4X4uV62lutUWfkfE0E4P ko4sONFA5p/0iM51Ffqtx5fVc/TmJ+u2o6/Y5JOIvbBI6hW0vRz44ngIWCuQ73XdJwi/ KYBGHAhidtVaFS8abgCFhK31n4KHfV/KPsPbCoIMABGXyNOAd1XZH5oFHEDyKXxcOSMr pRoXThXr1DlnSiKglTZMFta96hsedv5SVvhw6v+TaCRhxK4AkFDrojVEk1QCKZ/5lGdJ WLYm0BTyQkV6gYZoce8lODDHzxZcEXIUhblSv5rexg2zqh5r3MTHxHgBg26DvR3Rh4wU ZzYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=kHHROSX5; 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 p17si4132471plq.138.2019.07.10.22.48.29; Wed, 10 Jul 2019 22:48:44 -0700 (PDT) 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=kHHROSX5; 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 S1728018AbfGKFpx (ORCPT + 99 others); Thu, 11 Jul 2019 01:45:53 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:59472 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727960AbfGKFpx (ORCPT ); Thu, 11 Jul 2019 01:45:53 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id x6B5ip8V031345; Thu, 11 Jul 2019 14:44:59 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com x6B5ip8V031345 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1562823900; bh=iRp9Du8hIMlIwOLhJe7rDNMn7P7N/4zadqD4+iwRwl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kHHROSX5oyo66/pfhCsF+TrfXLXku+LACPJkW0iet8erC7xG/EvN4XWYSx5tsRd/W lsFYztWkgGnh31I5CogAYVE1AD20ywUkiqdw7T2a/L9KKpjZ4e74xRXA4Peqey4nJ6 gowGCHXn/8v2uBm8G8bJdnfXKUn+mxBVNKfl4K7VKH6BOatc6BPFpwQWENIIJzddyh ge9KxtwnrpMCyjXJRLm6OcUmdxeD2bEk99+ybLty2fZrElUbLtSesyNB+eHNlsaTnc utDi+WeMxMGD4ZFlOGRLEAsSuC7BAGg7lUtPXje6fX8D/iDN7fK2xvGm5nMS3+DGR6 sQfWX0otXw6Jw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Nicolas Pitre , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 11/11] kbuild: split out *.mod out of {single,multi}-used-m rules Date: Thu, 11 Jul 2019 14:44:34 +0900 Message-Id: <20190711054434.1177-12-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190711054434.1177-1-yamada.masahiro@socionext.com> References: <20190711054434.1177-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, *.mod is created as a side-effect of obj-m. Split out *.mod as a dedicated build rule, which allows to unify the %.c -> %.o rule, and remove the single-used-m rule. This also makes the incremental build of allmodconfig faster because it saves $(NM) invocation when there is no change in the module. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/Makefile.build | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 2709646b1a5d..63fc266b4985 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -67,8 +67,10 @@ ifeq ($(CONFIG_MODULES)$(need-modorder),y1) modorder-target := $(obj)/modules.order endif +mod-targets := $(patsubst %.o, %.mod, $(obj-m)) + __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ - $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \ + $(if $(KBUILD_MODULES),$(obj-m) $(mod-targets) $(modorder-target)) \ $(subdir-ym) $(always) @: @@ -266,7 +268,7 @@ endef # List module undefined symbols (or empty line if not enabled) ifdef CONFIG_TRIM_UNUSED_KSYMS -cmd_undef_syms = $(NM) $@ | sed -n 's/^ *U //p' | xargs echo +cmd_undef_syms = $(NM) $< | sed -n 's/^ *U //p' | xargs echo else cmd_undef_syms = echo endif @@ -276,11 +278,15 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) -$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE - $(call cmd,force_checksrc) - $(call if_changed_rule,cc_o_c) - @{ echo $@; \ - $(cmd_undef_syms); } > $(patsubst %.o,%.mod,$@) +cmd_mod = { \ + echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \ + $(cmd_undef_syms); \ + } > $@ + +$(obj)/%.mod: $(obj)/%.o FORCE + $(call if_changed,mod) + +targets += $(mod-targets) quiet_cmd_cc_lst_c = MKLST $@ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ @@ -461,8 +467,6 @@ cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis $(multi-used-m): FORCE $(call if_changed,link_multi-m) - @{ echo $(filter %.o,$^); \ - $(cmd_undef_syms); } > $(patsubst %.o,%.mod,$@) $(call multi_depend, $(multi-used-m), .o, -objs -y -m) targets += $(multi-used-m) -- 2.17.1