From nobody Sat Apr 11 14:43:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4CA5ECAAA1 for ; Tue, 6 Sep 2022 06:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233049AbiIFGO0 (ORCPT ); Tue, 6 Sep 2022 02:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233242AbiIFGOJ (ORCPT ); Tue, 6 Sep 2022 02:14:09 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E0B56F277; Mon, 5 Sep 2022 23:14:06 -0700 (PDT) Received: from zoe.. (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 2866DVI9023845; Tue, 6 Sep 2022 15:13:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 2866DVI9023845 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1662444813; bh=UjBwyRKQ+sMHIW/laWlK/4o3VWWE5pOimk6yZyootxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jujvUSKNt01rIN+WMvWWqz9Fu/F+b6LMHDTSEookeDo+voWKdyhRs9bPSG68u0RPG 98fbPC+l6eid8jQ7vPUQ8zYebZBNDblIBTtCaU/HwkC43rpEDixebnwc+/qn9n0oaF g0XK1L7yZnGXjUd5tqfGuuMDoVhAb141EYdNIttGoJyTVAHMVBsdt9hOH3YM2/6Jkc Hy4GOmxWolvd21/jRf/tGQoNo66LdAXjVMDsgdYWNluAOYm/vbgGuytgC6ZpzNYv7Y bjT06K3ehoLU56JhX/AqrNoPoHwKDRSfOE4TbpG2Npd3aP1l4xyBKc0pvHVOVSKY0I djWJve9W8AeOg== X-Nifty-SrcIP: [133.32.182.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Masahiro Yamada Subject: [PATCH v2 3/8] kbuild: move core-y and drivers-y to ./Kbuild Date: Tue, 6 Sep 2022 15:13:08 +0900 Message-Id: <20220906061313.1445810-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906061313.1445810-1-masahiroy@kernel.org> References: <20220906061313.1445810-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use the ordinary obj-y to list subdirectories. Note1: GNU Make seems to transform './.modules.order' to '.modules.order' before matching it against the target pattern. Split ./.modules.order to a dedicated rule to avoid "doesn't match the target pattern" warning. [1] Note2: Previously, the link order of lib-y depended on CONFIG_MODULES; lib-y was linked before drivers-y when CONFIG_MODULES=3Dy, otherwise after drivers-y. This was a bug of commit 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=3Dy"), but it was not a big deal after all. Now, libs-y (all objects that come from lib/ and arch/*/lib/) is linked last, irrespective of CONFIG_MODULES. Note3: Now, the single target build in arch/*/lib/ works correctly. There was a bug report about this. [2] $ make ARCH=3Darm arch/arm/lib/findbit.o CALL scripts/checksyscalls.sh AS arch/arm/lib/findbit.o [1]: https://lists.gnu.org/archive/html/bug-make/2022-08/msg00059.html [2]: https://lore.kernel.org/linux-kbuild/YvUQOwL6lD4%2F5%2FU6@shell.armlin= ux.org.uk/ Signed-off-by: Masahiro Yamada --- Changes in v2: - Move all core-y and drivers-y - Fix single target build Kbuild | 23 +++++++++++++++++++++++ Makefile | 29 +++++++++++++---------------- scripts/Makefile.lib | 2 ++ 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/Kbuild b/Kbuild index 0b9e8a16a621..8854e88e0619 100644 --- a/Kbuild +++ b/Kbuild @@ -72,3 +72,26 @@ $(atomic-checks): $(obj)/.checked-%: include/linux/atomi= c/% FORCE PHONY +=3D prepare prepare: $(offsets-file) missing-syscalls $(atomic-checks) @: + +# Ordinary directory descending +# ------------------------------------------------------------------------= --- + +obj-y +=3D init/ +obj-y +=3D usr/ +obj-y +=3D arch/$(SRCARCH)/ +obj-y +=3D $(ARCH_CORE) +obj-y +=3D kernel/ +obj-y +=3D certs/ +obj-y +=3D mm/ +obj-y +=3D fs/ +obj-y +=3D ipc/ +obj-y +=3D security/ +obj-y +=3D crypto/ +obj-$(CONFIG_BLOCK) +=3D block/ +obj-$(CONFIG_IO_URING) +=3D io_uring/ +obj-y +=3D drivers/ +obj-y +=3D sound/ +obj-$(CONFIG_SAMPLES) +=3D samples/ +obj-$(CONFIG_NET) +=3D net/ +obj-y +=3D virt/ +obj-y +=3D $(ARCH_DRIVERS) diff --git a/Makefile b/Makefile index 552ade93ca1d..ef0621d55ebb 100644 --- a/Makefile +++ b/Makefile @@ -676,11 +676,8 @@ endif =20 ifeq ($(KBUILD_EXTMOD),) # Objects we will link into vmlinux / subdirs we need to visit -core-y :=3D init/ usr/ arch/$(SRCARCH)/ -drivers-y :=3D drivers/ sound/ -drivers-$(CONFIG_SAMPLES) +=3D samples/ -drivers-$(CONFIG_NET) +=3D net/ -drivers-y +=3D virt/ +core-y :=3D +drivers-y :=3D libs-y :=3D lib/ endif # KBUILD_EXTMOD =20 @@ -1101,23 +1098,20 @@ export MODORDER :=3D $(extmod_prefix)modules.order export MODULES_NSDEPS :=3D $(extmod_prefix)modules.nsdeps =20 ifeq ($(KBUILD_EXTMOD),) -core-y +=3D kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ -core-$(CONFIG_BLOCK) +=3D block/ -core-$(CONFIG_IO_URING) +=3D io_uring/ =20 -vmlinux-dirs :=3D $(patsubst %/,%,$(filter %/, \ - $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ - $(libs-y) $(libs-m))) +vmlinux-dirs :=3D . $(patsubst %/,%,$(filter %/, $(libs-y) $(libs-m))) =20 -vmlinux-alldirs :=3D $(sort $(vmlinux-dirs) Documentation . \ +vmlinux-alldirs :=3D $(sort $(vmlinux-dirs) Documentation \ $(patsubst %/,%,$(filter %/, $(core-) \ $(drivers-) $(libs-)))) =20 build-dirs :=3D $(vmlinux-dirs) clean-dirs :=3D $(vmlinux-alldirs) =20 +export ARCH_CORE :=3D $(core-y) +export ARCH_DRIVERS :=3D $(drivers-y) # Externally visible symbols (used by link-vmlinux.sh) -KBUILD_VMLINUX_OBJS :=3D $(head-y) $(patsubst %/,%/built-in.a, $(core-y)) +KBUILD_VMLINUX_OBJS :=3D $(head-y) ./built-in.a KBUILD_VMLINUX_OBJS +=3D $(addsuffix built-in.a, $(filter %/, $(libs-y))) ifdef CONFIG_MODULES KBUILD_VMLINUX_OBJS +=3D $(patsubst %/, %/lib.a, $(filter %/, $(libs-y))) @@ -1125,7 +1119,6 @@ KBUILD_VMLINUX_LIBS :=3D $(filter-out %/, $(libs-y)) else KBUILD_VMLINUX_LIBS :=3D $(patsubst %/,%/lib.a, $(libs-y)) endif -KBUILD_VMLINUX_OBJS +=3D $(patsubst %/,%/built-in.a, $(drivers-y)) =20 export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS export KBUILD_LDS :=3D arch/$(SRCARCH)/kernel/vmlinux.lds @@ -1752,7 +1745,10 @@ ifdef CONFIG_MODULES =20 subdir-modorder :=3D $(addsuffix /.modules.order, $(build-dirs)) =20 -$(sort $(subdir-modorder)): %/.modules.order: % ; +# Split ./.modules.order into a dedicate target to avoid +# "doesn't match the target pattern" warning +./.modules.order: . ; +$(sort $(filter-out ./.modules.order, $(subdir-modorder))): %/.modules.ord= er: % ; =20 cmd_modules_order =3D cat $(real-prereqs) > $@ =20 @@ -1823,7 +1819,8 @@ single_modpost: $(single-no-ko) modules_prepare $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $(Q)rm -f $(MODORDER) =20 -single-goals :=3D $(addprefix $(extmod_prefix), $(single-no-ko)) +single-goals :=3D $(foreach x, $(addprefix $(extmod_prefix), $(single-no-k= o)), \ + $(if $(filter $(addsuffix /%, $(build-dirs)), $x),,./)$x) =20 # trim unrelated directories build-dirs :=3D $(foreach d, $(build-dirs), \ diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index b594705d571a..9bdc9ed37f49 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -89,6 +89,7 @@ always-y +=3D $(dtb-y) =20 # Add subdir path =20 +ifneq ($(obj),.) extra-y :=3D $(addprefix $(obj)/,$(extra-y)) always-y :=3D $(addprefix $(obj)/,$(always-y)) targets :=3D $(addprefix $(obj)/,$(targets)) @@ -100,6 +101,7 @@ multi-obj-m :=3D $(addprefix $(obj)/, $(multi-obj-m)) multi-dtb-y :=3D $(addprefix $(obj)/, $(multi-dtb-y)) real-dtb-y :=3D $(addprefix $(obj)/, $(real-dtb-y)) subdir-ym :=3D $(addprefix $(obj)/,$(subdir-ym)) +endif =20 # Finds the multi-part object the current object will be linked into. # If the object belongs to two or more multi-part objects, list them all. --=20 2.34.1