Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1878368ybe; Thu, 12 Sep 2019 00:37:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqytc5FI0//ixRMaon9NaXzwtRA3QHxeabvbTvyUi/oWZD1BH/YncnaHln4lO0D0Xvo0JVuJ X-Received: by 2002:aa7:cd73:: with SMTP id ca19mr40511831edb.266.1568273823235; Thu, 12 Sep 2019 00:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568273823; cv=none; d=google.com; s=arc-20160816; b=Do+7yb+eI4d9yL27iEMa5vv9bNYfzt2yH4OJUfVwvH4382AC8W5+pf2L+qLvquD2bf bl8SWsWvkc5UKZ31YYqhwsiAr4BY/7FNNL7QBLqoEhPeCgoVZvEzKJmzFLiNRN0MBbQY h2OBlED5tMHOeAHvElcxyIlUuHIPtrrb/2q8awc/lV4PclWialOl0OiFF3M7L6i0MpqK NeYm5CayXsZ3I+EwYDgti3k5HqudIy/V2ZxBcc5OaShkxtgVomvGYeZZrV/2rFUn/LyT CalBnL4XRIUGA11++P8ySaMgqI5ZSJV5zkLF5Se/htOQExxwFNNZv8340BOQCAoUJJ75 t0bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=LqEDIT/B2atU2BjPW+NBM34K9nUbTM8vvHn1AoCzsCs=; b=Kgf0y2cjcPqBOfgD8ouB2Ncnl5ulq3fhjL60KF9VG8QgAQh/A3rq4DLupmzrDDxenr yVPIVySREuEmZaBSekMHf83kTs4/RcFoukq1ead/LyrFgOouktkKgd/0cEyqU9+9vfZG kMKkMAVQ8ZAGwcnY2e1YAG7JsN0Vozs1vS/AkrmNnTO6hqoFPc/YBhIUTxaE7wEwB5Wc ffrpFfO858Ls3sJW52pZd8vy62wN/Wl1XzOcLyyqzCCGnHUVg23bL7p97I5+jRfe3DtT fcilBCNH3OEh3glxg9G8uNSg+KvsvXYYfOAfI+PCz8NrZ6J+zmdXOzjcyVHPEjrauLjJ 4j1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=M3Ei2vzu; 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 x22si13494347edi.382.2019.09.12.00.36.39; Thu, 12 Sep 2019 00:37:03 -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=M3Ei2vzu; 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 S1729599AbfILHds (ORCPT + 99 others); Thu, 12 Sep 2019 03:33:48 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:43159 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725765AbfILHdr (ORCPT ); Thu, 12 Sep 2019 03:33:47 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id x8C7Xbg8018895; Thu, 12 Sep 2019 16:33:38 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com x8C7Xbg8018895 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1568273618; bh=LqEDIT/B2atU2BjPW+NBM34K9nUbTM8vvHn1AoCzsCs=; h=From:To:Cc:Subject:Date:From; b=M3Ei2vzubTb8BRzMbZ3SsNAr7MzewSzAZZg0zDVPpLcsU8giwNoH2pPXhZb3KqHue odD+Ces3Hh+ja/8ryuQfAxx1dm9VKVYFKm2SByyrtwz0WJUu1IUGHfSDkyst4JMQyx zzGci76Sxf8fB9rO6hk+bnSzZy9c3JEq489y20fYE4i+pn7LPLgZx+ZphHznPEdT4X TaLjDemlz8XN5cKSX8rMLnt82dQtUMzg+Yjd279m+1nU276+HRem16ZglaC4LNhgVI wfiOlQVAlIKDrGDQw75+lpNPws1lFswTughJxWK85A1iovkzB1P2+R+OxCZ7Hmax3R H3FC736G/j2HQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] kbuild: do not create built-in.a that is never linked to vmlinux Date: Thu, 12 Sep 2019 16:33:33 +0900 Message-Id: <20190912073336.7036-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Both 'obj-y += foo/' and 'obj-m += foo/' requrest Kbuild to visit the sub-directory foo/, but the difference is that only the former combines foo/built-in.a into the built-in.a of the current directory because everything in sub-directories visited by obj-m is supposed to be modular. So, it makes sense to create built-in.a only if that sub-directory is reachable by the chain of obj-y. Otherwise, built-in.a will not be linked into vmlinux anyway. If an orphan built-in.a is created, it is very likely a Makefile bug. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 2 +- scripts/Makefile.lib | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 9fa09361aa5d..54fc68168686 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -66,7 +66,7 @@ lib-target := $(obj)/lib.a real-obj-y += $(obj)/lib-ksyms.o endif -ifneq ($(strip $(real-obj-y) $(need-builtin)),) +ifdef need-builtin builtin-target := $(obj)/built-in.a endif diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 264611972c4a..07095d3789a1 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -35,7 +35,11 @@ __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) subdir-y += $(__subdir-y) __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) subdir-m += $(__subdir-m) +ifdef need-builtin obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) +else +obj-y := $(filter-out %/, $(obj-y)) +endif obj-m := $(filter-out %/, $(obj-m)) # Subdirectories we need to descend into -- 2.17.1