Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2576264ybe; Thu, 12 Sep 2019 11:31:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqykiKfbo7A9WyzRykQ43JKQAi6ybukidjs8Z7T6DSNMTSfB9Au4ZeKFTkPMWLJ2thHm1vRn X-Received: by 2002:a17:906:7e52:: with SMTP id z18mr35100850ejr.114.1568313110321; Thu, 12 Sep 2019 11:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568313110; cv=none; d=google.com; s=arc-20160816; b=GeJ62rYYfOwEdkM9rfym52w2+tDr5/S2KaTyQEUEITzeeLWW6AqYc4fMljMV4vGW/4 gElx8UHpPjXiJ8bSbZa4ptHavZ1A8Up18yLElU0p8RvxJXv/EqI1oETOwulUZPcJViTP RrVW1DH5ZdxxvPb4siBgSGObs0qCKV1JoOlXswsXpjp/GxlBp3OUzIFRxwnjHJRrlsxL 2EKfJgxtqEmouKgzuoOsZyeLO46rwGNseKteFDIqEucf5PMSXdVKC4ZDxM0RlHQf4aRp 5AKyPJn5X45NiDanJz6OeKT7sk1ZRpYXSe9auGnhxXVtCMaOJtZUeDI25LTP6SM3S2hI 6m3g== 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=BmLOVqV59Vde6VCUiKEZh8rSQkSRAqH6r3P6Fy5+ico=; b=FPiZZsHnaaq9SCBnPQrLtEzUJNBUi1WEx8JedWZptTdeXdP4Mje5mvWqskbHJ0AuHm mBrbeCU6TN2vyTkcu93KNqG+K0KCz3kd1Wh/zBnwL53ob/KpDUWolh3gFPliwD3vNMH8 e/I35pKaqsGY0/5G2xof3kOsgI0ugWzy20Hgf1ROG+jCLd5EcV/sOIISen60A/YvgSbG f2BE3tTAktFjrfM6r2UNM6uHQhudbMTTqk2eivRXv1dEf45QDHeNKZsmYXWAI2Z7YKV2 VLunBoGNUMXVGqdtxKHXYbT1Y2CU3nVr6yp1pYldZDTxYGnQoddSXUX9oEw1rCc45eLf NZ9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=GnQyqTru; 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 a16si9927639edx.150.2019.09.12.11.31.25; Thu, 12 Sep 2019 11:31:50 -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=GnQyqTru; 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 S1733168AbfILQXK (ORCPT + 99 others); Thu, 12 Sep 2019 12:23:10 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:42379 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725775AbfILQXJ (ORCPT ); Thu, 12 Sep 2019 12:23:09 -0400 Received: from grover.flets-west.jp (softbank126125143222.bbtec.net [126.125.143.222]) (authenticated) by conuserg-07.nifty.com with ESMTP id x8CGMu1a021030; Fri, 13 Sep 2019 01:22:56 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x8CGMu1a021030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1568305377; bh=BmLOVqV59Vde6VCUiKEZh8rSQkSRAqH6r3P6Fy5+ico=; h=From:To:Cc:Subject:Date:From; b=GnQyqTruc2er6tX9zm3L1Y8mJnaZMNKoOWR/d2UdtM6d2gyz+Pau5nORNcdL02lRv 4k/JzXU3PCw05eKfBmeIca8gG+UyhW8NbP0vjSaiMgPDTk05pp5hhsJ1zu9RAc3U9a 4747NrEfj8fvjq/pF7rJuc50NtedlcNgZUohOGvWFNqLBmt9wEAag4P8a7PLxcfXCW +WvYTw7Hr9k+vRSVcdg+wgtXuutPKe/cQVBTNH2GBLuDNErcl+jIcKUPMfAH65Pjck y8B/+PP7wz3s/UNrTCjzj0MekA112JwcvbJysyZiCPAC7PMGOfsYZ2Zqpjgxxi+9w7 drF3nnfsDCz1A== X-Nifty-SrcIP: [126.125.143.222] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] kbuild: do not create built-in.a that is never linked to vmlinux Date: Fri, 13 Sep 2019 01:22:51 +0900 Message-Id: <20190912162254.9603-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, useless orphan built-in.a files are generated. Signed-off-by: Masahiro Yamada --- Changes in v2: None 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 f72aba64d611..6c3e6cb0c0af 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 4a0cdd6f5909..26ac638525cb 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