From nobody Tue Apr 14 15:42:11 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 78E52C0502A for ; Sun, 28 Aug 2022 02:40:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231578AbiH1Cki (ORCPT ); Sat, 27 Aug 2022 22:40:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiH1Ck0 (ORCPT ); Sat, 27 Aug 2022 22:40:26 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E1F419C01; Sat, 27 Aug 2022 19:40:23 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gj030639; Sun, 28 Aug 2022 11:40:07 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gj030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654407; bh=GBayUjw41o8Ha0J4vO9A3wCOvGjxHrTwsRhpPXXTmuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ByT6NL1vCaRIYM1STLowZiUmlIgG7PkN+6+lGPAn8L/R2Cr7XzQruqQd2MVCCKMtU vbFLivYm+qeSFa65gBldUTzt7dKj/u4XsGdq+1tgZ2fCLnQjg0fRaQ1llfvhrzt639 HPfW585oZ0YgeVqmpliddnnW+XQ5eOM8KHJW1ZUFtfYV/+23Iiam8BfcF4vduFDAPl 2LKRGxtoL3D2FW5vwFrMjgMp3SLhwcWfyIk0S53RMYEtCbY8cZn++Gz5twlzs47sey xAXaBQDKHW1z5lgLtZiipdCn07Ec3SIdEHQXW/Jl8faI0ObNbvB6tluAUWr9+00LtZ yPwMEFKL/00ow== 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 01/15] kbuild: remove duplicated dependency between modules and modules_check Date: Sun, 28 Aug 2022 11:39:49 +0900 Message-Id: <20220828024003.28873-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" The dependency, "modules: modules_check" is specified twice. Commit 1a998be620a1 ("kbuild: check module name conflict for external modules as well") missed to clean it up. 'PHONY +=3D modules' also appears twice. Signed-off-by: Masahiro Yamada --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7c955e906445..f04126181885 100644 --- a/Makefile +++ b/Makefile @@ -1436,8 +1436,7 @@ endif # Build modules # =20 -PHONY +=3D modules -modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare +modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_prepare =20 cmd_modules_order =3D cat $(real-prereqs) > $@ =20 --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 C6E95ECAAD1 for ; Sun, 28 Aug 2022 02:41:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232038AbiH1Clq (ORCPT ); Sat, 27 Aug 2022 22:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231889AbiH1Cku (ORCPT ); Sat, 27 Aug 2022 22:40:50 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 408EC2559E; Sat, 27 Aug 2022 19:40:44 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gk030639; Sun, 28 Aug 2022 11:40:07 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gk030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654408; bh=4CXgD6J2sGYGkI4a6Qbuk/WA0nBqfddOH+RIg6LYLPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aco7HsG21juUhVCgTkK8JTONguRPkeqX2Y5Kx5TTv79lflwr0pJpmtYWNLT4R2gDb Chx/yk01xM/UPTSxzazlz3GL1fLZyYFT69VGJd+c2MqFy2wNjvlLLCHOXGHvrFGZ3O rPjSOAr+/iiSf/Q772QlEANOi9rPoyNSIlCp9fxjRB3Jz+vS6sd7C0Ez+iencIdxD/ cVdQ5o3bDUhC7VzVA6gt6LUQPvFwDR2ttRJU/1EmjCQ4BjKUF98f8g79YIXA48ekSs jEtjCch8hJezLHXFcymWdFP+altXIfEcoaLsF5Z1pD22Ct+xY+ii+Vg35rBNg9acW/ ayUBbUe9+qOKg== 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 02/15] kbuild: refactor single builds of *.ko Date: Sun, 28 Aug 2022 11:39:50 +0900 Message-Id: <20220828024003.28873-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" Remove the potentially invalid modules.order instead of using the temporary file. Also, KBUILD_MODULES is don't care for single builds. No need to cancel it. Signed-off-by: Masahiro Yamada --- Makefile | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index f04126181885..badd318c5524 100644 --- a/Makefile +++ b/Makefile @@ -1787,6 +1787,8 @@ modules modules_install: @echo >&2 '***' @exit 1 =20 +KBUILD_MODULES :=3D + endif # CONFIG_MODULES =20 # Single targets @@ -1813,18 +1815,12 @@ $(single-ko): single_modpost $(single-no-ko): descend @: =20 -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 :=3D .modules.tmp -endif - +# Remove MODORDER when done because it is not the real one. PHONY +=3D single_modpost single_modpost: $(single-no-ko) modules_prepare $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$m;) } > $(MODORDER) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost - -KBUILD_MODULES :=3D 1 + $(Q)rm -f $(MODORDER) =20 export KBUILD_SINGLE_TARGETS :=3D $(addprefix $(extmod_prefix), $(single-n= o-ko)) =20 @@ -1834,10 +1830,6 @@ build-dirs :=3D $(foreach d, $(build-dirs), \ =20 endif =20 -ifndef CONFIG_MODULES -KBUILD_MODULES :=3D -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 --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 6D69AC3DA6B for ; Sun, 28 Aug 2022 02:40:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231887AbiH1Cku (ORCPT ); Sat, 27 Aug 2022 22:40:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231658AbiH1Ckr (ORCPT ); Sat, 27 Aug 2022 22:40:47 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85347252B6; Sat, 27 Aug 2022 19:40:39 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gl030639; Sun, 28 Aug 2022 11:40:08 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gl030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654408; bh=hTZUP847fbfef2g9ezPupjBY2vTehYAAacc76rjXEUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h319PIKxEJK4MmGGaPn1m3V4uTzXrMiFG9A/+f/7U31jg2yX7r3rrIQa1hTGfYU3I MsO3VXgZTD6yN0xFYMOjmrnTbvzsFULe6KYawVrNpV+F0tuLjp0Rizk5kpncwtoz44 5uSDnYxHG4VvPE69hy8AQiriS+q7G+KKmeq8/8R9YPvQTT/P3SE+vM783waQ4WoUy1 sazHtjbEAQHd/thm/IC8rRfFXgz+Ztc2Ryy5Oac7/Xwuh4mUY3x00ll+6yVV68P+N2 eiEELw9wMEJWWdLhNbpyTbzajXd6ApryypiMmAvJgj1QqXBMumV7xQrIWfej4/na07 n+pmczSJdju8Q== 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 03/15] kbuild: move 'PHONY += modules_prepare' to the common part Date: Sun, 28 Aug 2022 11:39:51 +0900 Message-Id: <20220828024003.28873-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" Unify the code between in-tree builds and external module builds. Signed-off-by: Masahiro Yamada --- Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Makefile b/Makefile index badd318c5524..54e481162608 100644 --- a/Makefile +++ b/Makefile @@ -1446,7 +1446,6 @@ modules.order: $(subdir-modorder) FORCE targets +=3D modules.order =20 # Target to prepare building external modules -PHONY +=3D modules_prepare modules_prepare: prepare $(Q)$(MAKE) $(build)=3Dscripts scripts/module.lds =20 @@ -1747,15 +1746,12 @@ help: @echo ' clean - remove generated files in module directory on= ly' @echo '' =20 -# no-op for external module builds -PHONY +=3D modules_prepare - endif # KBUILD_EXTMOD =20 # ------------------------------------------------------------------------= --- # Modules =20 -PHONY +=3D modules modules_install +PHONY +=3D modules modules_install modules_prepare =20 ifdef CONFIG_MODULES =20 --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 1003DC0502E for ; Sun, 28 Aug 2022 02:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229524AbiH1Ck7 (ORCPT ); Sat, 27 Aug 2022 22:40:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231735AbiH1Ckr (ORCPT ); Sat, 27 Aug 2022 22:40:47 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 484F3275D5; Sat, 27 Aug 2022 19:40:41 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gm030639; Sun, 28 Aug 2022 11:40:08 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gm030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654409; bh=nmi4TuCe4/ZAlGow19MAlTrGk9A2EH+pzmZGuA/W3Iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qMLJ5SQP1vKLWoZ0ax+e9zBVS7as01zWNxNsoj/LMTHa6jdioGqsniKe0Ku6K90Tf 2RnrOwiABHIT3eExKjZ2FjseWXMgqa/3VB9AAg0AyoFwcSuiZYxT2bRdg+njRkanN6 d/4EXT6tk+PBFSUTeB85J927zauUO6E7Ju0o+AeFtLNJ4uqz1igz0e78tamixkU3Yt UJTKiH4BRFhztYsWBLo0xVA0DvdIzg5CO8EVzG8bymkH67h1B5JYvcFtGVTDwcivrK OCHamCDi9u+sauMx+MwtPM8h69hV9NtKF1IxxSGh9IxskcHLLqFuzc0vYoPHT+bZPt 6ywSI9ETb0POA== 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 04/15] init/version.c: remove #include Date: Sun, 28 Aug 2022 11:39:52 +0900 Message-Id: <20220828024003.28873-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" This is unneeded since commit 073a9ecb3a73 ("init/version.c: remove Version_ symbol"). Signed-off-by: Masahiro Yamada --- init/version.c | 1 - 1 file changed, 1 deletion(-) diff --git a/init/version.c b/init/version.c index b7f9559d417c..3391c4051bf3 100644 --- a/init/version.c +++ b/init/version.c @@ -16,7 +16,6 @@ #include #include #include -#include #include =20 struct uts_namespace init_uts_ns =3D { --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 24A57C0502A for ; Sun, 28 Aug 2022 02:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232743AbiH1Cl6 (ORCPT ); Sat, 27 Aug 2022 22:41:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231979AbiH1Cku (ORCPT ); Sat, 27 Aug 2022 22:40:50 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9361D29831; Sat, 27 Aug 2022 19:40:44 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gn030639; Sun, 28 Aug 2022 11:40:09 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gn030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654409; bh=h8cc33O5fH+ce9OkOOKqDFD3WxGfcUP5sv1a7xwgUbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1gwWnJi8Qpng30JrLNAtQrbyQ8EU1cCiyLkux/mqCpsPh1VAJImiy1Q8+d2NchtyV rdt2z59XWfUq/SS6jBAp6+k00PxEF7rwZ8C8thh4VNR8n3+ZVPcZ9HKlqPbNSc/VNl +0jf4woFvBdWtfSafmzLxyChncrT/YThici123riMU/4qDc1TOQSLwopAtnnWdH4Kj QximtMwxODid7gUo3PhNW/PdVXSB4A83IlII+YknaWmYkD4Be+BbjZgCVaMeidimlm ET2dhr/C3KchLdOQxxxTxFEOfDTNuIVnytHRSyucBUQ3LTB9+L4KWpR4CrfbNqnpEi UIrHR9h3yd+vQ== 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 05/15] kbuild: build init/built-in.a just once Date: Sun, 28 Aug 2022 11:39:53 +0900 Message-Id: <20220828024003.28873-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" Kbuild builds init/built-in.a twice; first during the ordinary directory descending, second from scripts/link-vmlinux.sh. We do this because UTS_VERSION contains the build version and the timestamp. We cannot update it during the normal directory traversal since we do not yet know if we need to update vmlinux. UTS_VERSION is temporarily calculated, but omitted from the update check. Otherwise, vmlinux would be rebuilt every time. When Kbuild results in running link-vmlinux.sh, it increments the version number in the .version file and takes the timestamp at that time to really fix UTS_VERSION. However, updating the same file twice is a footgun. To avoid nasty timestamp issues, all build artifacts that depend on init/built-in.a must be atomically generated in link-vmlinux.sh, where some of them do not need rebuilding. To fix this issue, this commit changes as follows: [1] Split UTS_VERSION out to include/generated/utsversion.h from include/generated/compile.h include/generated/utsversion.h is generated just before the vmlinux link. It is generated under include/generated/ because some decompressors (s390, x86) use UTS_VERSION. [2] Split init_uts_ns and linux_banner out to init/version-timestamp.c from init/version.c init_uts_ns and linux_banner contain UTS_VERSION. During the ordinary directory descending, they are compiled with __weak and used to determine if vmlinux needs relinking. Just before the vmlinux link, they are compiled without __weak to embed the real version and timestamp. Signed-off-by: Masahiro Yamada --- arch/s390/boot/version.c | 1 + arch/x86/boot/compressed/kaslr.c | 1 + arch/x86/boot/version.c | 1 + init/Makefile | 53 ++++++++++++++----- init/build-version | 10 ++++ init/version-timestamp.c | 31 +++++++++++ init/version.c | 36 +++++-------- scripts/link-vmlinux.sh | 17 ++---- scripts/mkcompile_h | 89 ++++---------------------------- 9 files changed, 112 insertions(+), 127 deletions(-) create mode 100755 init/build-version create mode 100644 init/version-timestamp.c diff --git a/arch/s390/boot/version.c b/arch/s390/boot/version.c index d32e58bdda6a..fd32f038777f 100644 --- a/arch/s390/boot/version.c +++ b/arch/s390/boot/version.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include #include #include "boot.h" diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/ka= slr.c index 4a3f223973f4..e476bcbd9b42 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -29,6 +29,7 @@ #include #include #include +#include #include =20 #define _SETUP diff --git a/arch/x86/boot/version.c b/arch/x86/boot/version.c index a1aaaf6c06a6..945383f0f606 100644 --- a/arch/x86/boot/version.c +++ b/arch/x86/boot/version.c @@ -11,6 +11,7 @@ */ =20 #include "boot.h" +#include #include #include =20 diff --git a/init/Makefile b/init/Makefile index d82623d7fc8e..63f53d210cad 100644 --- a/init/Makefile +++ b/init/Makefile @@ -19,20 +19,47 @@ mounts-y :=3D do_mounts.o mounts-$(CONFIG_BLK_DEV_RAM) +=3D do_mounts_rd.o mounts-$(CONFIG_BLK_DEV_INITRD) +=3D do_mounts_initrd.o =20 -# dependencies on generated files need to be listed explicitly -$(obj)/version.o: include/generated/compile.h +# +# UTS_VERSION +# + +smp-flag-$(CONFIG_SMP) :=3D SMP +preempt-flag-$(CONFIG_PREEMPT_BUILD) :=3D PREEMPT +preempt-flag-$(CONFIG_PREEMPT_DYNAMIC) :=3D PREEMPT_DYNAMIC +preempt-flag-$(CONFIG_PREEMPT_RT) :=3D PREEMPT_RT + +build-version =3D $(or $(KBUILD_BUILD_VERSION), $(build-version-auto)) +build-timestamp =3D $(or $(KBUILD_BUILD_TIMESTAMP), $(build-timestamp-auto= )) + +# Maximum length of UTS_VERSION is 64 chars +filechk_uts_version =3D \ + utsver=3D$$(echo '$(pound)'"$(build-version)" $(smp-flag-y) $(preempt-fla= g-y) "$(build-timestamp)" | cut -b -64); \ + echo '$(pound)'define UTS_VERSION \""$${utsver}"\" + +# +# Build version.c with temporary UTS_VERSION +# + +$(obj)/utsversion-tmp.h: FORCE + $(call filechk,uts_version) =20 -# compile.h changes depending on hostname, generation number, etc, -# so we regenerate it always. -# mkcompile_h will make sure to only update the -# actual file if its content has changed. +$(obj)/version.o: include/generated/compile.h $(obj)/utsversion-tmp.h +CFLAGS_version.o :=3D -include $(obj)/utsversion-tmp.h =20 -quiet_cmd_compile.h =3D CHK $@ - cmd_compile.h =3D \ - $(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \ - "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT_BUILD)" \ - "$(CONFIG_PREEMPT_DYNAMIC)" "$(CONFIG_PREEMPT_RT)" \ - "$(CONFIG_CC_VERSION_TEXT)" "$(LD)" +filechk_compile.h =3D $(srctree)/scripts/mkcompile_h \ + "$(UTS_MACHINE)" "$(CONFIG_CC_VERSION_TEXT)" "$(LD)" =20 include/generated/compile.h: FORCE - $(call cmd,compile.h) + $(call filechk,compile.h) + +# +# Build version-timestamp.c with final UTS_VERSION +# + +include/generated/utsversion.h: build-version-auto =3D $(shell $(srctree)/= $(src)/build-version) +include/generated/utsversion.h: build-timestamp-auto =3D $(shell LC_ALL=3D= C date) +include/generated/utsversion.h: FORCE + $(call filechk,uts_version) + +$(obj)/version-timestamp.o: include/generated/utsversion.h +CFLAGS_version-timestamp.o :=3D -include include/generated/utsversion.h diff --git a/init/build-version b/init/build-version new file mode 100755 index 000000000000..39225104f14d --- /dev/null +++ b/init/build-version @@ -0,0 +1,10 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only + +VERSION=3D$(cat .version) 2>/dev/null && +VERSION=3D$(expr $VERSION + 1) 2>/dev/null || +VERSION=3D1 + +echo ${VERSION} > .version + +echo ${VERSION} diff --git a/init/version-timestamp.c b/init/version-timestamp.c new file mode 100644 index 000000000000..179e93bae539 --- /dev/null +++ b/init/version-timestamp.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include + +struct uts_namespace init_uts_ns =3D { + .ns.count =3D REFCOUNT_INIT(2), + .name =3D { + .sysname =3D UTS_SYSNAME, + .nodename =3D UTS_NODENAME, + .release =3D UTS_RELEASE, + .version =3D UTS_VERSION, + .machine =3D UTS_MACHINE, + .domainname =3D UTS_DOMAINNAME, + }, + .user_ns =3D &init_user_ns, + .ns.inum =3D PROC_UTS_INIT_INO, +#ifdef CONFIG_UTS_NS + .ns.ops =3D &utsns_operations, +#endif +}; + +/* FIXED STRINGS! Don't touch! */ +const char linux_banner[] =3D + "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@" + LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n"; diff --git a/init/version.c b/init/version.c index 3391c4051bf3..01d4ab05f0ba 100644 --- a/init/version.c +++ b/init/version.c @@ -18,24 +18,6 @@ #include #include =20 -struct uts_namespace init_uts_ns =3D { - .ns.count =3D REFCOUNT_INIT(2), - .name =3D { - .sysname =3D UTS_SYSNAME, - .nodename =3D UTS_NODENAME, - .release =3D UTS_RELEASE, - .version =3D UTS_VERSION, - .machine =3D UTS_MACHINE, - .domainname =3D UTS_DOMAINNAME, - }, - .user_ns =3D &init_user_ns, - .ns.inum =3D PROC_UTS_INIT_INO, -#ifdef CONFIG_UTS_NS - .ns.ops =3D &utsns_operations, -#endif -}; -EXPORT_SYMBOL_GPL(init_uts_ns); - static int __init early_hostname(char *arg) { size_t bufsize =3D sizeof(init_uts_ns.name.nodename); @@ -51,11 +33,6 @@ static int __init early_hostname(char *arg) } early_param("hostname", early_hostname); =20 -/* FIXED STRINGS! Don't touch! */ -const char linux_banner[] =3D - "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@" - LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n"; - const char linux_proc_banner[] =3D "%s version %s" " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" @@ -63,3 +40,16 @@ const char linux_proc_banner[] =3D =20 BUILD_SALT; BUILD_LTO_INFO; + +/* + * init_uts_ns and linux_banner contain the build version and timestamp, + * which are really fixed at the very last step of build process. + * They are compiled with __weak first, and without __weak later. + */ + +struct uts_namespace init_uts_ns __weak; +const char linux_banner[] __weak; + +#include "version-timestamp.c" + +EXPORT_SYMBOL_GPL(init_uts_ns); diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index eecc1863e556..8d982574145a 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -75,6 +75,8 @@ vmlinux_link() objs=3D"${objs} .vmlinux.export.o" fi =20 + objs=3D"${objs} init/version-timestamp.o" + if [ "${SRCARCH}" =3D "um" ]; then wl=3D-Wl, ld=3D"${CC}" @@ -213,19 +215,6 @@ if [ "$1" =3D "clean" ]; then exit 0 fi =20 -# Update version -info GEN .version -if [ -r .version ]; then - VERSION=3D$(expr 0$(cat .version) + 1) - echo $VERSION > .version -else - rm -f .version - echo 1 > .version -fi; - -# final build of init/ -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=3Dinit need-builtin=3D1 - #link vmlinux.o ${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o" =20 @@ -260,6 +249,8 @@ if is_enabled CONFIG_MODULES; then ${MAKE} -f "${srctree}/scripts/Makefile.vmlinux" .vmlinux.export.o fi =20 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=3Dinit init/version-tim= estamp.o + btf_vmlinux_bin_o=3D"" if is_enabled CONFIG_DEBUG_INFO_BTF; then btf_vmlinux_bin_o=3D.btf.vmlinux.bin.o diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index ca40a5258c87..f1a820d49e53 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -1,14 +1,9 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 =20 -TARGET=3D$1 -ARCH=3D$2 -SMP=3D$3 -PREEMPT=3D$4 -PREEMPT_DYNAMIC=3D$5 -PREEMPT_RT=3D$6 -CC_VERSION=3D"$7" -LD=3D$8 +UTS_MACHINE=3D$1 +CC_VERSION=3D"$2" +LD=3D$3 =20 # Do not expand names set -f @@ -17,17 +12,6 @@ set -f LC_ALL=3DC export LC_ALL =20 -if [ -z "$KBUILD_BUILD_VERSION" ]; then - VERSION=3D$(cat .version 2>/dev/null || echo 1) -else - VERSION=3D$KBUILD_BUILD_VERSION -fi - -if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then - TIMESTAMP=3D`date` -else - TIMESTAMP=3D$KBUILD_BUILD_TIMESTAMP -fi if test -z "$KBUILD_BUILD_USER"; then LINUX_COMPILE_BY=3D$(whoami | sed 's/\\/\\\\/') else @@ -39,63 +23,12 @@ else LINUX_COMPILE_HOST=3D$KBUILD_BUILD_HOST fi =20 -UTS_VERSION=3D"#$VERSION" -CONFIG_FLAGS=3D"" -if [ -n "$SMP" ] ; then CONFIG_FLAGS=3D"SMP"; fi - -if [ -n "$PREEMPT_RT" ] ; then - CONFIG_FLAGS=3D"$CONFIG_FLAGS PREEMPT_RT" -elif [ -n "$PREEMPT_DYNAMIC" ] ; then - CONFIG_FLAGS=3D"$CONFIG_FLAGS PREEMPT_DYNAMIC" -elif [ -n "$PREEMPT" ] ; then - CONFIG_FLAGS=3D"$CONFIG_FLAGS PREEMPT" -fi - -# Truncate to maximum length -UTS_LEN=3D64 -UTS_VERSION=3D"$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS= _LEN)" - -# Generate a temporary compile.h - -{ echo /\* This file is auto generated, version $VERSION \*/ - if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi +LD_VERSION=3D$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \ + | sed 's/[[:space:]]*$//') =20 - echo \#define UTS_MACHINE \"$ARCH\" - - echo \#define UTS_VERSION \"$UTS_VERSION\" - - printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY" - echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\" - - LD_VERSION=3D$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \ - | sed 's/[[:space:]]*$//') - printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION" -} > .tmpcompile - -# Only replace the real compile.h if the new one is different, -# in order to preserve the timestamp and avoid unnecessary -# recompilations. -# We don't consider the file changed if only the date/time changed, -# unless KBUILD_BUILD_TIMESTAMP was explicitly set (e.g. for -# reproducible builds with that value referring to a commit timestamp). -# A kernel config change will increase the generation number, thus -# causing compile.h to be updated (including date/time) due to the -# changed comment in the -# first line. - -if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then - IGNORE_PATTERN=3D"UTS_VERSION" -else - IGNORE_PATTERN=3D"NOT_A_PATTERN_TO_BE_MATCHED" -fi - -if [ -r $TARGET ] && \ - grep -v $IGNORE_PATTERN $TARGET > .tmpver.1 && \ - grep -v $IGNORE_PATTERN .tmpcompile > .tmpver.2 && \ - cmp -s .tmpver.1 .tmpver.2; then - rm -f .tmpcompile -else - echo " UPD $TARGET" - mv -f .tmpcompile $TARGET -fi -rm -f .tmpver.1 .tmpver.2 +cat < 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 C7F3FC54EE9 for ; Sun, 28 Aug 2022 02:40:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231784AbiH1Ckx (ORCPT ); Sat, 27 Aug 2022 22:40:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229773AbiH1Ckq (ORCPT ); Sat, 27 Aug 2022 22:40:46 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84D40252B2; Sat, 27 Aug 2022 19:40:39 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Go030639; Sun, 28 Aug 2022 11:40:09 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Go030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654410; bh=Ojdr7OFV9j1YbpIO3D6oC+XaFmz7/7hOYyO9OvHgWLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OtnOEL7NYfqPML6WGIODFpxvrHhE1Vb5thmq2pIjeo6n6TyyzterPeYzP8wcNWqjR 2AxpqlcLBSkWH4k3WVPmjjlpu83dto74nipV1UdPm4QNRqsKQj0oaOItt3pMTeC69K a37QwTQgL72zcJvu1Jv7yfHAMDCXVqj2F+2izOIQS6TbzBniwlZB8DCXe6uKAAraoq eUuVPYIqI7adLqgh6TCo68V2lWLf+9CLZpr16Mzina2VSZk4XTCzFLX553SUT/+vXK oXHCIYssoBKDCqDK6WXi7K+qvYk2Uxp/PEJvNPAeodiln5aNZ7+/gQJAuE7VymDaAZ vVRUuWOhNGwCA== 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 06/15] kbuild: generate include/generated/compile.h in top Makefile Date: Sun, 28 Aug 2022 11:39:54 +0900 Message-Id: <20220828024003.28873-7-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" Now that UTS_VERSION was separated out, this header can be generated much earlier, and probably the top Makefile is a better place to do it than init/Makefile. Signed-off-by: Masahiro Yamada --- Makefile | 8 +++++++- init/Makefile | 8 +------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 54e481162608..d933c0acab12 100644 --- a/Makefile +++ b/Makefile @@ -1198,7 +1198,7 @@ PHONY +=3D prepare archprepare =20 archprepare: outputmakefile archheaders archscripts scripts include/config= /kernel.release \ asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \ - include/generated/autoconf.h remove-stale-files + include/generated/compile.h include/generated/autoconf.h remove-stale-fil= es =20 prepare0: archprepare $(Q)$(MAKE) $(build)=3Dscripts/mod @@ -1260,6 +1260,12 @@ $(version_h): FORCE include/generated/utsrelease.h: include/config/kernel.release FORCE $(call filechk,utsrelease.h) =20 +filechk_compile.h =3D $(srctree)/scripts/mkcompile_h \ + "$(UTS_MACHINE)" "$(CONFIG_CC_VERSION_TEXT)" "$(LD)" + +include/generated/compile.h: FORCE + $(call filechk,compile.h) + PHONY +=3D headerdep headerdep: $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \ diff --git a/init/Makefile b/init/Makefile index 63f53d210cad..31c17a8e314b 100644 --- a/init/Makefile +++ b/init/Makefile @@ -43,15 +43,9 @@ filechk_uts_version =3D \ $(obj)/utsversion-tmp.h: FORCE $(call filechk,uts_version) =20 -$(obj)/version.o: include/generated/compile.h $(obj)/utsversion-tmp.h +$(obj)/version.o: $(obj)/utsversion-tmp.h CFLAGS_version.o :=3D -include $(obj)/utsversion-tmp.h =20 -filechk_compile.h =3D $(srctree)/scripts/mkcompile_h \ - "$(UTS_MACHINE)" "$(CONFIG_CC_VERSION_TEXT)" "$(LD)" - -include/generated/compile.h: FORCE - $(call filechk,compile.h) - # # Build version-timestamp.c with final UTS_VERSION # --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 D2E59ECAAD1 for ; Sun, 28 Aug 2022 02:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232706AbiH1Clw (ORCPT ); Sat, 27 Aug 2022 22:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231981AbiH1Cku (ORCPT ); Sat, 27 Aug 2022 22:40:50 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E76129827; Sat, 27 Aug 2022 19:40:43 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gp030639; Sun, 28 Aug 2022 11:40:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gp030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654410; bh=eGfR+SEQRQYMntHzRLQYF+Hwh8rbACwjelshdo+fzFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=02rQo8JopEgajO2tQ0CfaQYKeP+AOJ1x2LJhfrlPaUH2VP89Zn2bLl9/p74m2Zo7a sStaPDtSO/et6rxaxVF6p2LuLm4YTDUlnjw5lZIZR5Dw1pJpgE+pmSpYuOUBg7A6ty FeKHkj0SC/Zmx0sp28YQPQMFPpaeva0rzdT21T00I3ctEnpwmD40HpYe/ztcZk+Jwj /eP1xpRKm9cg3gi/hNhQUaluiK7Jrc8pmBN8+jBAVIsfuFSVl6P5Q39ANbz557FPI1 en/boef0CrQwIsuC85HDHiDeNnjmO4lXQd7b12bWTmBGjz5MqEgtt80Igkdi2EF+2J y1/J/OP06sDxA== 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 07/15] scripts/mkcompile_h: move LC_ALL=C to '$LD -v' Date: Sun, 28 Aug 2022 11:39:55 +0900 Message-Id: <20220828024003.28873-8-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" Minimize the scope of LC_ALL=3DC like before commit 87c94bfb8ad3 ("kbuild: override build timestamp & version"). Give LC_ALL=3DC to '$LD -v' to get the consistent version output, as commit bcbcf50f5218 ("kbuild: fix ld-version.sh to not be affected by locale") mentioned the LD version is affected by locale. While I was here, I merged two sed invocations. Signed-off-by: Masahiro Yamada --- scripts/mkcompile_h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index f1a820d49e53..b76ccbbc094b 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -8,10 +8,6 @@ LD=3D$3 # Do not expand names set -f =20 -# Fix the language to get consistent output -LC_ALL=3DC -export LC_ALL - if test -z "$KBUILD_BUILD_USER"; then LINUX_COMPILE_BY=3D$(whoami | sed 's/\\/\\\\/') else @@ -23,8 +19,8 @@ else LINUX_COMPILE_HOST=3D$KBUILD_BUILD_HOST fi =20 -LD_VERSION=3D$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \ - | sed 's/[[:space:]]*$//') +LD_VERSION=3D$(LC_ALL=3DC $LD -v | head -n1 | + sed -e 's/(compatible with [^)]*)//' -e 's/[[:space:]]*$//') =20 cat < 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 1FD83ECAAD1 for ; Sun, 28 Aug 2022 02:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232482AbiH1Cld (ORCPT ); Sat, 27 Aug 2022 22:41:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231721AbiH1Ckt (ORCPT ); Sat, 27 Aug 2022 22:40:49 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF6E128E36; Sat, 27 Aug 2022 19:40:43 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gq030639; Sun, 28 Aug 2022 11:40:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gq030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654411; bh=pcMhDiiIpuG9IA8eOqVr1JYW01owykoWnir+g7tldYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jo1j2k/N+uaWBpzCO54Kz2cFlciKFXqxfEn0CjcUzR14SbWmQTc8i++Y6WlwjAn65 cosm6dj73cNrg4DQtkr5C/yI9RRGoAXj1Z9CxJ1x4whDqmcLH5rQUoUX7fPkaMmjzk 1QSmNsrqFjfTaam3WY484+K6ugzgwig4t1xCjfEgZ94O3XlAinJ57KxqqY6+i5LU2X ieMjy28nzCMjtf5iH7zSGEtomAcbDRtqap89dL+oOUngojV7EC8jy0nmlhKdum8WiW d1ONiErX360qwSNwY87ySwQGnZREiIj9R3De1Ay+tqlA5mcpVjvgrVR4NSft1aI0Hx kEh1TmAqzvFlw== 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 08/15] Revert "kbuild: Make scripts/compile.h when sh != bash" Date: Sun, 28 Aug 2022 11:39:56 +0900 Message-Id: <20220828024003.28873-9-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" This reverts commit [1] in the pre-git era. I do not know what problem happened in the script when sh !=3D bash because there is no commit message. Now that this script is much simpler than it used to be, let's revert it, and let' see. (If this turns out to be problematic, fix the code with proper commit description.) [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/co= mmit/?id=3D11acbbbb8a50f4de7dbe4bc1b5acc440dfe81810 Signed-off-by: Masahiro Yamada --- scripts/mkcompile_h | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index b76ccbbc094b..2596f78e52ef 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -5,9 +5,6 @@ UTS_MACHINE=3D$1 CC_VERSION=3D"$2" LD=3D$3 =20 -# Do not expand names -set -f - if test -z "$KBUILD_BUILD_USER"; then LINUX_COMPILE_BY=3D$(whoami | sed 's/\\/\\\\/') else --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 E7BDFECAAD1 for ; Sun, 28 Aug 2022 02:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231906AbiH1ClD (ORCPT ); Sat, 27 Aug 2022 22:41:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbiH1Cks (ORCPT ); Sat, 27 Aug 2022 22:40:48 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 031C2286EC; Sat, 27 Aug 2022 19:40:42 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gr030639; Sun, 28 Aug 2022 11:40:11 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gr030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654411; bh=4G1Mu07321fm2z01H8+kEda+iEOQov2qO2fvcpQnyz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S4zzK74VlVTiLeCWtjNYG1zKCrJZPjcQQQPE3UtKw1dZLver+EIP94VcV+gVMVX5s Y8RQg1U+tgs64m66Uefw+bWA6NKjv8GQho5lq6UEOa3OVAckEmYAGg5liaHcxQusku ero8cjvJ1ySCZveVHsrv7UxwAn8FPwNfLok4j1T2Yf5BfhqwcR6wxv5Yn1dKesYA18 FfjOUVJVRfKTLM3xoCdYtLOGzqvn2awl2QChfOKb2+3h7V11n8BB1/T90t2ioVOwGz Cj2aoPF0UhDTPPR/Hry8wUZLpgNqBxJoF5yJOYlmRpREOhr0hCTj85xvLYZGnNvkXx Qmk8LkAw9GM3A== 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 09/15] kbuild: rename modules.order in sub-directories to .modules.order Date: Sun, 28 Aug 2022 11:39:57 +0900 Message-Id: <20220828024003.28873-10-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" The next commit will move core-y from the top Makefile to ./Kbuild to use obj-y to list sub-directories. With that, both ./Makefile and ./Kbuild would create modules.order in the top directory. To avoid the conflict, rename the per-directory modules.order to .modules.order. Signed-off-by: Masahiro Yamada --- Makefile | 27 +++++++++++++-------------- scripts/Makefile.build | 18 +++++++++--------- scripts/Makefile.lib | 8 ++++---- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index d933c0acab12..89aba2c69be8 100644 --- a/Makefile +++ b/Makefile @@ -1116,8 +1116,6 @@ vmlinux-alldirs :=3D $(sort $(vmlinux-dirs) Documenta= tion . \ build-dirs :=3D $(vmlinux-dirs) clean-dirs :=3D $(vmlinux-alldirs) =20 -subdir-modorder :=3D $(addsuffix /modules.order, $(build-dirs)) - # Externally visible symbols (used by link-vmlinux.sh) KBUILD_VMLINUX_OBJS :=3D $(head-y) $(patsubst %/,%/built-in.a, $(core-y)) KBUILD_VMLINUX_OBJS +=3D $(addsuffix built-in.a, $(filter %/, $(libs-y))) @@ -1172,7 +1170,7 @@ targets :=3D vmlinux =20 # The actual objects are generated when descending, # make sure no implicit rule kicks in -$(sort $(vmlinux-deps) $(subdir-modorder)): descend ; +$(sort $(vmlinux-deps)): descend ; =20 filechk_kernel.release =3D \ echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversi= on $(srctree))" @@ -1444,13 +1442,6 @@ endif =20 modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_prepare =20 -cmd_modules_order =3D cat $(real-prereqs) > $@ - -modules.order: $(subdir-modorder) FORCE - $(call if_changed,modules_order) - -targets +=3D modules.order - # Target to prepare building external modules modules_prepare: prepare $(Q)$(MAKE) $(build)=3Dscripts scripts/module.lds @@ -1722,8 +1713,6 @@ KBUILD_BUILTIN :=3D KBUILD_MODULES :=3D 1 =20 build-dirs :=3D $(KBUILD_EXTMOD) -$(MODORDER): descend - @: =20 compile_commands.json: $(extmod_prefix)compile_commands.json PHONY +=3D compile_commands.json @@ -1755,12 +1744,22 @@ help: endif # KBUILD_EXTMOD =20 # ------------------------------------------------------------------------= --- -# Modules +# Modules (common for in-tree modules and external modules) =20 PHONY +=3D modules modules_install modules_prepare =20 ifdef CONFIG_MODULES =20 +subdir-modorder :=3D $(addsuffix /.modules.order, $(build-dirs)) + +$(sort $(subdir-modorder)): %/.modules.order: % ; + +cmd_modules_order =3D cat $(real-prereqs) > $@ + +targets +=3D $(MODORDER) +$(MODORDER): $(subdir-modorder) FORCE + $(call if_changed,modules_order) + modules: modules_check $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost =20 @@ -1860,7 +1859,7 @@ clean: $(clean-dirs) -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '*.lex.c' -o -name '*.tab.[ch]' \ -o -name '*.asn1.[ch]' \ - -o -name '*.symtypes' -o -name 'modules.order' \ + -o -name '*.symtypes' -o -name '*modules.order' \ -o -name '.tmp_*' \ -o -name '*.c.[012]*.*' \ -o -name '*.ll' \ diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 0df488d0bbb0..c96c3c0ab228 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -73,7 +73,7 @@ endif =20 # subdir-builtin and subdir-modorder may contain duplications. Use $(sort = ...) subdir-builtin :=3D $(sort $(filter %/built-in.a, $(real-obj-y))) -subdir-modorder :=3D $(sort $(filter %/modules.order, $(obj-m))) +subdir-modorder :=3D $(sort $(filter %/.modules.order, $(obj-m))) =20 targets-for-builtin :=3D $(extra-y) =20 @@ -89,7 +89,7 @@ targets-for-modules :=3D $(foreach x, o mod $(if $(CONFIG= _TRIM_UNUSED_KSYMS), usym $(patsubst %.o, %.$x, $(filter %.o, $(obj-m)))) =20 ifdef need-modorder -targets-for-modules +=3D $(obj)/modules.order +targets-for-modules +=3D $(obj)/.modules.order endif =20 targets +=3D $(targets-for-builtin) $(targets-for-modules) @@ -348,7 +348,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtre= e)/scripts/asn1_compiler =20 # To build objects in subdirs, we need to descend into the directories $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ; -$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ; +$(subdir-modorder): $(obj)/%/.modules.order: $(obj)/% ; =20 # # Rule to compile a set of .o files into one .a file (without symbol table) @@ -365,18 +365,18 @@ $(obj)/built-in.a: $(real-obj-y) FORCE $(call if_changed,ar_builtin) =20 # -# Rule to create modules.order file +# Rule to create .modules.order file # -# Create commands to either record .ko file or cat modules.order from +# Create commands to either record .ko file or cat .modules.order from # a subdirectory # Add $(obj-m) as the prerequisite to avoid updating the timestamp of -# modules.order unless contained modules are updated. +# .modules.order unless contained modules are updated. =20 cmd_modules_order =3D { $(foreach m, $(real-prereqs), \ - $(if $(filter %/modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m))= ;) :; } \ + $(if $(filter %/.modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m)= );) :; } \ > $@ =20 -$(obj)/modules.order: $(obj-m) FORCE +$(obj)/.modules.order: $(obj-m) FORCE $(call if_changed,modules_order) =20 # @@ -465,7 +465,7 @@ $(subdir-ym): $(Q)$(MAKE) $(build)=3D$@ \ $(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=3D) \ need-builtin=3D$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \ - need-modorder=3D$(if $(filter $@/modules.order, $(subdir-modorder)),1) + need-modorder=3D$(if $(filter $@/.modules.order, $(subdir-modorder)),1) =20 # Add FORCE to the prequisites of a target to force it to be always rebuil= t. # ------------------------------------------------------------------------= --- diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 3fb6a99e78c4..b594705d571a 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -26,14 +26,14 @@ subdir-ym :=3D $(sort $(subdir-y) $(subdir-m) \ =20 # Handle objects in subdirs: # - If we encounter foo/ in $(obj-y), replace it by foo/built-in.a and -# foo/modules.order -# - If we encounter foo/ in $(obj-m), replace it by foo/modules.order +# foo/.modules.order +# - If we encounter foo/ in $(obj-m), replace it by foo/.modules.order # -# Generate modules.order to determine modorder. Unfortunately, we don't ha= ve +# Generate .modules.order to determine modorder. Unfortunately, we don't h= ave # information about ordering between -y and -m subdirs. Just put -y's firs= t. =20 ifdef need-modorder -obj-m :=3D $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m)) +obj-m :=3D $(patsubst %/,%/.modules.order, $(filter %/, $(obj-y)) $(obj-m)) else obj-m :=3D $(filter-out %/, $(obj-m)) endif --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 5C742C0502E for ; Sun, 28 Aug 2022 02:41:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbiH1ClO (ORCPT ); Sat, 27 Aug 2022 22:41:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231785AbiH1Cks (ORCPT ); Sat, 27 Aug 2022 22:40:48 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9996827CC7; Sat, 27 Aug 2022 19:40:42 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gs030639; Sun, 28 Aug 2022 11:40:11 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gs030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654412; bh=YoDXYuJyQEKSSPipp1AABHrm2l3TTVvkj1W/FZ+r+1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f3Hhe1f/JGKAXXcLN36k02+aDrB9yooKVZ0j8s48Bu4w+kg3yZZK3gj4zw5vA9xpv Y1GSMyarZfIbtazosGmzyZMdNGYV7zhzN/gG2kRjh+LJg28hqY6OaA+ppXAuRVkd3k zSI9ozagTGS0ODlqMhk9PDuqsfk61pg+HFJYjqHDdZLZz163GSKaN3l0Y+YdsFgIxe GZYS8v3z0Ye8rMnHKUvoi2uxQGScm8GJhU+ee0VR7ZrBhL29OAUv12x7+3IPUkHRIf 10YyzsNS0wlxYo4soBfOBAk7FQgJFDubiqWkZMv/eMTnqdvNudJ3eQBzkVGku6x9vw qlF/UVt7gWLUA== 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 10/15] kbuild: move core-y in top Makefile to ./Kbuild Date: Sun, 28 Aug 2022 11:39:58 +0900 Message-Id: <20220828024003.28873-11-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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. There are some core-y entries remaining in arch/*/Makefile. They will be moved after io_uring/built-in.a. Note: 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] [1]: https://lists.gnu.org/archive/html/bug-make/2022-08/msg00059.html Signed-off-by: Masahiro Yamada --- Kbuild | 16 ++++++++++++++++ Makefile | 10 +++++----- scripts/Makefile.build | 4 ++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Kbuild b/Kbuild index 0b9e8a16a621..c8661cfc49a3 100644 --- a/Kbuild +++ b/Kbuild @@ -72,3 +72,19 @@ $(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 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/ diff --git a/Makefile b/Makefile index 89aba2c69be8..1bc44bb4be1f 100644 --- a/Makefile +++ b/Makefile @@ -676,7 +676,7 @@ endif =20 ifeq ($(KBUILD_EXTMOD),) # Objects we will link into vmlinux / subdirs we need to visit -core-y :=3D init/ usr/ arch/$(SRCARCH)/ +core-y :=3D ./ drivers-y :=3D drivers/ sound/ drivers-$(CONFIG_SAMPLES) +=3D samples/ drivers-$(CONFIG_NET) +=3D net/ @@ -1101,9 +1101,6 @@ 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) \ @@ -1752,7 +1749,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 diff --git a/scripts/Makefile.build b/scripts/Makefile.build index c96c3c0ab228..098c811667d3 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -464,8 +464,8 @@ PHONY +=3D $(subdir-ym) $(subdir-ym): $(Q)$(MAKE) $(build)=3D$@ \ $(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=3D) \ - need-builtin=3D$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \ - need-modorder=3D$(if $(filter $@/.modules.order, $(subdir-modorder)),1) + need-builtin=3D$(if $(filter $@/built-in.a, $(subdir-builtin:./%=3D%)),1)= \ + need-modorder=3D$(if $(filter $@/.modules.order, $(subdir-modorder:./%=3D= %)),1) =20 # Add FORCE to the prequisites of a target to force it to be always rebuil= t. # ------------------------------------------------------------------------= --- --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 DAC0FECAAD1 for ; Sun, 28 Aug 2022 02:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbiH1ClS (ORCPT ); Sat, 27 Aug 2022 22:41:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231793AbiH1Cks (ORCPT ); Sat, 27 Aug 2022 22:40:48 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7379A286F2; Sat, 27 Aug 2022 19:40:42 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gt030639; Sun, 28 Aug 2022 11:40:12 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gt030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654412; bh=nXICWQfG+jfSFnL44++ZviI0zdn5/yoV/XN9eUiVH8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0/YZ3YcABhWASbdoqlnAW+waVDqyRBCpu4iccRgmUhymhwrrf4nGiyI3i3ueVEhwY nf0YAaHn5L/V2KCYtUNeC0fvF+1brsOgO9lc50hs9Y2Q6CV4rj3KllQojm8LCLv12V 5BKmHW3WVpb3eUJsEYyteOO+wWOvGPv819GiRisrQCkkMD+xLjJZAVKGuOkbqQOAYC HZ47KG3aNiBZ6LESBkRLQPo2P2adRiGcT4I1MHE+TjGxipgZ3tJtc3E4tNfk5f+8Ur tqWoYR2C9VF85EuvABDCQdNkJ26ye0ZKHFIjQixg2TkbBha/wQqxjn7pgsEtFhlWHe Mlu0pLBmGSYTg== 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 11/15] kbuild: move .vmlinux.objs rule to Makefile.modpost Date: Sun, 28 Aug 2022 11:39:59 +0900 Message-Id: <20220828024003.28873-12-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" .vmlinux.objs is used by modpost, so scripts/Makefile.modpost is a better place to generate it. It is used only when CONFIG_MODVERSIONS=3Dy. It should be guarded by "ifdef CONFIG_MODVERSIONS". Signed-off-by: Masahiro Yamada --- Makefile | 2 +- scripts/Makefile.modpost | 30 ++++++++++++++++++++++++++++-- scripts/link-vmlinux.sh | 18 ------------------ 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 1bc44bb4be1f..02724bcf8fdc 100644 --- a/Makefile +++ b/Makefile @@ -1489,7 +1489,7 @@ endif # CONFIG_MODULES # Directories & files removed with 'make clean' CLEAN_FILES +=3D include/ksym vmlinux.symvers modules-only.symvers \ modules.builtin modules.builtin.modinfo modules.nsdeps \ - compile_commands.json .thinlto-cache + compile_commands.json .thinlto-cache .vmlinux.objs =20 # Directories & files removed with 'make mrproper' MRPROPER_FILES +=3D include/config include/generated \ diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 911606496341..04ad00917b2f 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -57,6 +57,32 @@ vmlinux.symvers: vmlinux.o =20 __modpost: vmlinux.symvers =20 +# Generate the list of in-tree objects in vmlinux +# ------------------------------------------------------------------------= --- + +# This is used to retrieve symbol versions generated by genksyms. +ifdef CONFIG_MODVERSIONS +vmlinux.symvers: .vmlinux.objs +endif + +# Ignore libgcc.a +# Some architectures do '$(CC) --print-libgcc-file-name' to borrow libgcc.a +# from the toolchain, but there is no EXPORT_SYMBOL in it. + +quiet_cmd_vmlinux_objs =3D GEN $@ + cmd_vmlinux_objs =3D \ + for f in $(real-prereqs); do \ + case $${f} in \ + *libgcc.a) ;; \ + *.a) $(AR) t $${f} ;; \ + *) echo $${f} ;; \ + esac \ + done > $@ + +targets +=3D .vmlinux.objs +.vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE + $(call if_changed,vmlinux_objs) + else =20 ifeq ($(KBUILD_EXTMOD),) @@ -134,6 +160,8 @@ ifneq ($(KBUILD_MODPOST_NOFINAL),1) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal endif =20 +endif + PHONY +=3D FORCE FORCE: =20 @@ -141,6 +169,4 @@ existing-targets :=3D $(wildcard $(sort $(targets))) =20 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) =20 -endif - .PHONY: $(PHONY) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 8d982574145a..161bca64e8aa 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -199,7 +199,6 @@ cleanup() rm -f System.map rm -f vmlinux rm -f vmlinux.map - rm -f .vmlinux.objs rm -f .vmlinux.export.c } =20 @@ -218,23 +217,6 @@ fi #link vmlinux.o ${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o" =20 -# Generate the list of in-tree objects in vmlinux -# -# This is used to retrieve symbol versions generated by genksyms. -for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do - case ${f} in - *libgcc.a) - # Some architectures do '$(CC) --print-libgcc-file-name' to - # borrow libgcc.a from the toolchain. - # There is no EXPORT_SYMBOL in external objects. Ignore this. - ;; - *.a) - ${AR} t ${f} ;; - *) - echo ${f} ;; - esac -done > .vmlinux.objs - # modpost vmlinux.o to check for section mismatches ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=3D1 =20 --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 CF74CECAAD1 for ; Sun, 28 Aug 2022 02:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232569AbiH1Clj (ORCPT ); Sat, 27 Aug 2022 22:41:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbiH1Cku (ORCPT ); Sat, 27 Aug 2022 22:40:50 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF34628E33; Sat, 27 Aug 2022 19:40:43 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gu030639; Sun, 28 Aug 2022 11:40:12 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gu030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654413; bh=bA4m7Oj/dBBjOfmTbtXEU7Zl9NzP1RzoFwx0p/QmZlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O2dRWT6MQavqXDxUN3pVnGLgUD4HO43Wk2TWKy9LF2Vemr+cDDemDALWxndEmT5by 02DRkaIy9XWLGK6NJ3BIxxBm8AhmMTDqaZP1XpOQDNXoXeryRepwz5obLdTrMlVnr9 78IfjEJ+fcOyaEpeUfZ8BDpqD5RIAeMgNrUiOURg5xi8JmO8wA30J5XXJuOHxVlnKC qUFdBn+CGfujKidnvGE0bhU6gZdNy3YcTQIA7Bnc5wAgxgG6/v/m/EMUjTr2g5cBOS npdKPEfulBLS5mtxfhLrEuxO5nRQdCDQ7y9SwQ1r+MnWMI9A3ZZ0LB8HgfSULuPmt6 lpDwLNC87xBMg== 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 12/15] kbuild: move vmlinux.o rule to the top Makefile Date: Sun, 28 Aug 2022 11:40:00 +0900 Message-Id: <20220828024003.28873-13-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" Move the build rules of vmlinux.o out of scripts/link-vmlinux.sh to clearly separate 1) pre-modpost, 2) modpost, 3) post-modpost stages. This will make furture refactoring possible. Signed-off-by: Masahiro Yamada --- Makefile | 10 ++++++++-- scripts/link-vmlinux.sh | 3 --- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 02724bcf8fdc..d81b7a587b43 100644 --- a/Makefile +++ b/Makefile @@ -645,6 +645,8 @@ else __all: modules endif =20 +targets :=3D + # Decide whether to build built-in, modular, or both. # Normally, just do built-in. =20 @@ -1153,6 +1155,10 @@ quiet_cmd_autoksyms_h =3D GEN $@ $(autoksyms_h): $(call cmd,autoksyms_h) =20 +targets +=3D vmlinux.o +vmlinux.o: autoksyms_recursive $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIB= S) FORCE + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o + ARCH_POSTLINK :=3D $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) =20 # Final link of vmlinux with optional arch pass after final link @@ -1160,10 +1166,10 @@ cmd_link-vmlinux =3D = \ $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) =20 -vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE +vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +$(call if_changed_dep,link-vmlinux) =20 -targets :=3D vmlinux +targets +=3D vmlinux =20 # The actual objects are generated when descending, # make sure no implicit rule kicks in diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 161bca64e8aa..07486f90d5e2 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -214,9 +214,6 @@ if [ "$1" =3D "clean" ]; then exit 0 fi =20 -#link vmlinux.o -${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o" - # modpost vmlinux.o to check for section mismatches ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=3D1 =20 --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 91A0EECAAD1 for ; Sun, 28 Aug 2022 02:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232366AbiH1ClV (ORCPT ); Sat, 27 Aug 2022 22:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbiH1Cks (ORCPT ); Sat, 27 Aug 2022 22:40:48 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C194E28717; Sat, 27 Aug 2022 19:40:42 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gv030639; Sun, 28 Aug 2022 11:40:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gv030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654413; bh=c4JLe00xA9RgTRCfMjXiEpEE/KAsTw3rpMQcsPLh0ZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fbQ2DU6RDyVxBSYcBy2FbYeEEAGZuEyqfiqvnwLbWfwNkmTUIyj8nbPFuEUXwzmPe dckYQCuux3GE6MhbTzQvrFfCZAISinEoMC9JACzSAkwY1x+Kbk7tIEEp/clvGfxFqV 04ed/CVsmu+x958ovmfrARVc5JXjUsWg8lG/0Y30s9tlYjTvJi2OOEoLIVzrxQWgbV to8bjEfLrY8vD1H1YJef8W/k9BRXA6vRwfD80ld2fF2m1bTEYhyd8JABfIdakaTF17 mjWCccCvd2dBaPq6pkiJmMbiY/HP4GS34SC2lZ7R1tvfbj9fSu32UZGX6WYbvr8H1U o9+xrdZXehjng== 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 13/15] kbuild: unify two modpost invocations Date: Sun, 28 Aug 2022 11:40:01 +0900 Message-Id: <20220828024003.28873-14-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" Currently, modpost is executed twice; first for vmlinux, second for modules. This commit unfies them. Current build flow =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 1) build obj-y and obj-m objects 2) link vmlinux.o 3) modpost for vmlinux 4) link vmlinux 5) modpost for modules 6) link modules (*.ko) The build steps 1) through 6) are serialized (that is, modules are built after vmlinux). We do not get benefits of parallel builds when scripts/link-vmlinux.sh is being run. New build flow =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 1) build obj-y and obj-m objects 2) link vmlinux.o 3) modpost for vmlinux and modules 4a) link vmlinux 4b) link modules (*.ko) In the new build flow, modpost is invoked just once. vmlinux and modules are built in parallel. One exception is CONFIG_DEBUG_INFO_BTF_MODULES=3Dy, where modules depend on vmlinux. Signed-off-by: Masahiro Yamada --- Makefile | 30 ++++++++++--- scripts/Makefile.modfinal | 2 +- scripts/Makefile.modpost | 93 ++++++++++++--------------------------- scripts/link-vmlinux.sh | 3 -- 4 files changed, 53 insertions(+), 75 deletions(-) diff --git a/Makefile b/Makefile index d81b7a587b43..292b6e90da20 100644 --- a/Makefile +++ b/Makefile @@ -1166,7 +1166,7 @@ cmd_link-vmlinux =3D = \ $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) =20 -vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) modpost FORCE +$(call if_changed_dep,link-vmlinux) =20 targets +=3D vmlinux @@ -1443,7 +1443,13 @@ endif # Build modules # =20 -modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_prepare +# *.ko are usually independent of vmlinux, but CONFIG_DEBUG_INFOBTF_MODULES +# is an exception. +ifdef CONFIG_DEBUG_INFO_BTF_MODULES +modules: vmlinux +endif + +modules: modules_prepare =20 # Target to prepare building external modules modules_prepare: prepare @@ -1766,8 +1772,12 @@ targets +=3D $(MODORDER) $(MODORDER): $(subdir-modorder) FORCE $(call if_changed,modules_order) =20 -modules: modules_check - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost +# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. +# This is solely useful to speed up test compiles. +modules: modpost +ifneq ($(KBUILD_MODPOST_NOFINAL),1) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal +endif =20 PHONY +=3D modules_check modules_check: $(MODORDER) @@ -1798,6 +1808,11 @@ KBUILD_MODULES :=3D =20 endif # CONFIG_MODULES =20 +PHONY +=3D modpost +modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \ + $(if $(KBUILD_MODULES), modules_check) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost + # Single targets # ------------------------------------------------------------------------= --- # To build individual files in subdirectories, you can do like this: @@ -1817,16 +1832,19 @@ single-ko :=3D $(sort $(filter %.ko, $(MAKECMDGOALS= ))) single-no-ko :=3D $(filter-out $(single-ko), $(MAKECMDGOALS)) \ $(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko))) =20 -$(single-ko): single_modpost +$(single-ko): single_modules @: $(single-no-ko): descend @: =20 # Remove MODORDER when done because it is not the real one. PHONY +=3D single_modpost -single_modpost: $(single-no-ko) modules_prepare +single_modules: $(single-no-ko) modules_prepare $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$m;) } > $(MODORDER) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost +ifneq ($(KBUILD_MODPOST_NOFINAL),1) + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal +endif $(Q)rm -f $(MODORDER) =20 export KBUILD_SINGLE_TARGETS :=3D $(addprefix $(extmod_prefix), $(single-n= o-ko)) diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 35100e981f4a..a3cf9e3647c9 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -55,7 +55,7 @@ if_changed_except =3D $(if $(call newer_prereqs_except,$(= 2))$(cmd-check), \ printf '%s\n' 'cmd_$@ :=3D $(make-cmd)' > $(dot-target).cmd, @:) =20 # Re-generate module BTFs if either module's .ko or vmlinux changed -$(modules): %.ko: %.o %.mod.o scripts/module.lds $(if $(KBUILD_BUILTIN),vm= linux) FORCE +$(modules): %.ko: %.o %.mod.o scripts/module.lds $(and $(CONFIG_DEBUG_INFO= _BTF_MODULES),$(KBUILD_BUILTIN),vmlinux) FORCE +$(call if_changed_except,ld_ko_o,vmlinux) ifdef CONFIG_DEBUG_INFO_BTF_MODULES +$(if $(newer-prereqs),$(call cmd,btf_ko)) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 04ad00917b2f..d7d3138c5ecc 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -32,9 +32,6 @@ # Step 4 is solely used to allow module versioning in external modules, # where the CRC of each module is retrieved from the Module.symvers file. =20 -# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. -# This is solely useful to speed up test compiles - PHONY :=3D __modpost __modpost: =20 @@ -45,24 +42,23 @@ MODPOST =3D scripts/mod/modpost \ $(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ + $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \ + $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N)= \ -o $@ =20 -ifdef MODPOST_VMLINUX - -quiet_cmd_modpost =3D MODPOST $@ - cmd_modpost =3D $(MODPOST) $< - -vmlinux.symvers: vmlinux.o - $(call cmd,modpost) +# 'make -i -k' ignores compile errors, and builds as many modules as possi= ble. +ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) +MODPOST +=3D -n +endif =20 -__modpost: vmlinux.symvers +ifeq ($(KBUILD_EXTMOD),) =20 # Generate the list of in-tree objects in vmlinux # ------------------------------------------------------------------------= --- =20 # This is used to retrieve symbol versions generated by genksyms. ifdef CONFIG_MODVERSIONS -vmlinux.symvers: .vmlinux.objs +vmlinux.symvers Module.symvers: .vmlinux.objs endif =20 # Ignore libgcc.a @@ -83,24 +79,12 @@ targets +=3D .vmlinux.objs .vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE $(call if_changed,vmlinux_objs) =20 -else - -ifeq ($(KBUILD_EXTMOD),) - -input-symdump :=3D vmlinux.symvers -output-symdump :=3D modules-only.symvers - -quiet_cmd_cat =3D GEN $@ - cmd_cat =3D cat $(real-prereqs) > $@ - -ifneq ($(wildcard vmlinux.symvers),) - -__modpost: Module.symvers -Module.symvers: vmlinux.symvers modules-only.symvers FORCE - $(call if_changed,cat) - -targets +=3D Module.symvers +vmlinux.o-if-present :=3D $(wildcard vmlinux.o) +output-symdump :=3D vmlinux.symvers =20 +ifdef KBUILD_MODULES +output-symdump :=3D $(if $(vmlinux.o-if-present), Module.symvers, modules-= only.symvers) +missing-input :=3D $(filter-out $(vmlinux.o-if-present),vmlinux.o) endif =20 else @@ -112,56 +96,35 @@ src :=3D $(obj) # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS include $(or $(wildcard $(src)/Kbuild), $(src)/Makefile) =20 -# modpost option for external modules -MODPOST +=3D -e - -input-symdump :=3D Module.symvers $(KBUILD_EXTRA_SYMBOLS) +module.symvers-if-present :=3D $(wildcard Module.symvers) output-symdump :=3D $(KBUILD_EXTMOD)/Module.symvers +missing-input :=3D $(filter-out $(module.symvers-if-present), Module.symve= rs) =20 -endif - -existing-input-symdump :=3D $(wildcard $(input-symdump)) - -# modpost options for modules (both in-kernel and external) -MODPOST +=3D \ - $(addprefix -i ,$(existing-input-symdump)) \ - $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) \ - $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) - -# 'make -i -k' ignores compile errors, and builds as many modules as possi= ble. -ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) -MODPOST +=3D -n -endif +MODPOST +=3D -e $(addprefix -i ,$(module.symvers-if-present) (KBUILD_EXTRA= _SYMBOLS)) =20 -# Clear VPATH to not search for *.symvers in $(srctree). Check only $(objt= ree). -VPATH :=3D -$(input-symdump): - @echo >&2 'WARNING: Symbol version dump "$@" is missing.' - @echo >&2 ' Modules may not have dependencies or modversions.' - @echo >&2 ' You may get many unresolved symbol warnings.' +endif # ($(KBUILD_EXTMOD),) =20 -# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined s= ymbols -ifneq ($(KBUILD_MODPOST_WARN)$(filter-out $(existing-input-symdump), $(inp= ut-symdump)),) +ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),) MODPOST +=3D -w endif =20 +modorder-if-needed :=3D $(if $(KBUILD_MODULES), $(MODORDER)) + # Read out modules.order to pass in modpost. # Otherwise, allmodconfig would fail with "Argument list too long". quiet_cmd_modpost =3D MODPOST $@ - cmd_modpost =3D sed 's/ko$$/o/' $< | $(MODPOST) -T - - -$(output-symdump): $(MODORDER) $(input-symdump) FORCE - $(call if_changed,modpost) + cmd_modpost =3D \ + $(if $(missing-input), \ + echo >&2 "WARNING: $(missing-input) is missing."; \ + echo >&2 " Modules may not have dependencies or modversions."; \ + echo >&2 " You may get many unresolved symbol warnings.";) \ + sed 's/ko$$/o/' $(or $(modorder-if-needed), /dev/null) | $(MODPOST) $(vml= inux.o-if-present) -T - =20 targets +=3D $(output-symdump) +$(output-symdump): $(modorder-if-needed) $(vmlinux.o-if-present) $(moudle.= symvers-if-present) FORCE + $(call if_changed,modpost) =20 __modpost: $(output-symdump) -ifneq ($(KBUILD_MODPOST_NOFINAL),1) - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal -endif - -endif - PHONY +=3D FORCE FORCE: =20 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 07486f90d5e2..6a197d8a88ac 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -214,9 +214,6 @@ if [ "$1" =3D "clean" ]; then exit 0 fi =20 -# modpost vmlinux.o to check for section mismatches -${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=3D1 - info MODINFO modules.builtin.modinfo ${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo info GEN modules.builtin --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 4D129ECAAD1 for ; Sun, 28 Aug 2022 02:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232670AbiH1Cls (ORCPT ); Sat, 27 Aug 2022 22:41:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231579AbiH1Cku (ORCPT ); Sat, 27 Aug 2022 22:40:50 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3ADB29812; Sat, 27 Aug 2022 19:40:43 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gw030639; Sun, 28 Aug 2022 11:40:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gw030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654414; bh=52aGWZ2ykU/pxw2EaFLBF+3yJYj3J7s7DtOdbPBF/xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EClR+kyIjj0u77/oPTQvHmvs777t8nadrJSgd+Mmy+CXVEZbXfSsG87G8mZAtEZkT ZEsjp4YDd+01L5Y41RjSKdZgmvXaN3FXwIaYcbaF8VapJyU3rrWIc6wZ7bSdsLz9iE DmSuA1uE/0aEx+yvC7Tw7ZmS3ZML8tc6AGhDVjBheXTbO4aZQK0tXENe30vh+1+ipP aosQzywW40phgv3Pke/aemEBGbq9JbXGeWH921VICL7uANXAnA4YYIcFDsDmJn5uI/ cpdeX3NegkCfcX26KqxEw6jZThdmvqKnGXmYzqwhrvYi+XO5ohTKvl9CfZPOBFuS1E y+1EAUG98pD7g== 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 14/15] kbuild: use obj-y instead extra-y for objects placed at the head Date: Sun, 28 Aug 2022 11:40:02 +0900 Message-Id: <20220828024003.28873-15-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" The objects placed at the head of vmlinux need special treatments: - arch/$(SRCARCH)/Makefile adds them to head-y in order to place them before other archives in the linker command line. - arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of obj-y to avoid them going into built-in.a. This commit gets rid of the second one. Create vmlinux.a to collect all the objects that are unconditionally linked to vmlinux. The objects listed in head-y are moved to the head of vmlinux.a by using 'ar m'. With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y for builtin objects. There is no *.o that is directly linked to vmlinux. Drop unneeded code in scripts/clang-tools/gen_compile_commands.py. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.rst | 18 +---------------- Makefile | 18 +++++++++++++---- arch/alpha/kernel/Makefile | 4 ++-- arch/arc/kernel/Makefile | 4 ++-- arch/arm/kernel/Makefile | 4 ++-- arch/arm64/kernel/Makefile | 4 ++-- arch/csky/kernel/Makefile | 4 ++-- arch/hexagon/kernel/Makefile | 3 ++- arch/ia64/kernel/Makefile | 4 ++-- arch/loongarch/kernel/Makefile | 4 ++-- arch/m68k/68000/Makefile | 2 +- arch/m68k/coldfire/Makefile | 2 +- arch/m68k/kernel/Makefile | 21 ++++++++++---------- arch/microblaze/kernel/Makefile | 4 ++-- arch/mips/kernel/Makefile | 4 ++-- arch/nios2/kernel/Makefile | 2 +- arch/openrisc/kernel/Makefile | 4 ++-- arch/parisc/kernel/Makefile | 4 ++-- arch/powerpc/kernel/Makefile | 22 ++++++++++----------- arch/riscv/kernel/Makefile | 2 +- arch/s390/kernel/Makefile | 4 ++-- arch/sh/kernel/Makefile | 4 ++-- arch/sparc/kernel/Makefile | 3 +-- arch/x86/kernel/Makefile | 10 +++++----- arch/xtensa/kernel/Makefile | 4 ++-- scripts/Makefile.modpost | 5 ++--- scripts/Makefile.vmlinux_o | 6 +++--- scripts/clang-tools/gen_compile_commands.py | 19 +----------------- scripts/link-vmlinux.sh | 10 ++++------ 29 files changed, 87 insertions(+), 112 deletions(-) diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/make= files.rst index 11a296e52d68..07c7e5a843c1 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -340,19 +340,7 @@ more details, with real examples. =20 Examples are: =20 - 1) head objects - - Some objects must be placed at the head of vmlinux. They are - directly linked to vmlinux without going through built-in.a - A typical use-case is an object that contains the entry point. - - arch/$(SRCARCH)/Makefile should specify such objects as head-y. - - Discussion: - Given that we can control the section order in the linker script, - why do we need head-y? - - 2) vmlinux linker script + 1) vmlinux linker script =20 The linker script for vmlinux is located at arch/$(SRCARCH)/kernel/vmlinux.lds @@ -360,10 +348,6 @@ more details, with real examples. Example:: =20 # arch/x86/kernel/Makefile - extra-y :=3D head_$(BITS).o - extra-y +=3D head$(BITS).o - extra-y +=3D ebda.o - extra-y +=3D platform-quirks.o extra-y +=3D vmlinux.lds =20 $(extra-y) should only contain targets needed for vmlinux. diff --git a/Makefile b/Makefile index 292b6e90da20..d74aa4552d35 100644 --- a/Makefile +++ b/Makefile @@ -1116,7 +1116,7 @@ build-dirs :=3D $(vmlinux-dirs) clean-dirs :=3D $(vmlinux-alldirs) =20 # Externally visible symbols (used by link-vmlinux.sh) -KBUILD_VMLINUX_OBJS :=3D $(head-y) $(patsubst %/,%/built-in.a, $(core-y)) +KBUILD_VMLINUX_OBJS :=3D $(patsubst %/,%/built-in.a, $(core-y)) KBUILD_VMLINUX_OBJS +=3D $(addsuffix built-in.a, $(filter %/, $(libs-y))) ifdef CONFIG_MODULES KBUILD_VMLINUX_OBJS +=3D $(patsubst %/, %/lib.a, $(filter %/, $(libs-y))) @@ -1126,7 +1126,7 @@ KBUILD_VMLINUX_LIBS :=3D $(patsubst %/,%/lib.a, $(lib= s-y)) endif KBUILD_VMLINUX_OBJS +=3D $(patsubst %/,%/built-in.a, $(drivers-y)) =20 -export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS +export KBUILD_VMLINUX_LIBS export KBUILD_LDS :=3D arch/$(SRCARCH)/kernel/vmlinux.lds # used by scripts/Makefile.package export KBUILD_ALLDIRS :=3D $(sort $(filter-out arch/%,$(vmlinux-alldirs)) = LICENSES arch include scripts tools) @@ -1155,8 +1155,18 @@ quiet_cmd_autoksyms_h =3D GEN $@ $(autoksyms_h): $(call cmd,autoksyms_h) =20 +quiet_cmd_ar_vmlinux.a =3D AR $@ + cmd_ar_vmlinux.a =3D \ + rm -f $@; \ + $(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \ + $(AR) mPi $$($(AR) t $@| head -n1) $@ $(head-y) + +targets +=3D vmlinux.a +vmlinux.a: $(KBUILD_VMLINUX_OBJS) FORCE + $(call if_changed,ar_vmlinux.a) + targets +=3D vmlinux.o -vmlinux.o: autoksyms_recursive $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIB= S) FORCE +vmlinux.o: autoksyms_recursive vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o =20 ARCH_POSTLINK :=3D $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) @@ -1913,7 +1923,7 @@ quiet_cmd_gen_compile_commands =3D GEN $@ cmd_gen_compile_commands =3D $(PYTHON3) $< -a $(AR) -o $@ $(filter-o= ut $<, $(real-prereqs)) =20 $(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_com= mands.py \ - $(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \ + $(if $(KBUILD_EXTMOD),, vmlinux.a $(KBUILD_VMLINUX_LIBS)) \ $(if $(CONFIG_MODULES), $(MODORDER)) FORCE $(call if_changed,gen_compile_commands) =20 diff --git a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile index 5a74581bf0ee..5a5b0a8b7c6a 100644 --- a/arch/alpha/kernel/Makefile +++ b/arch/alpha/kernel/Makefile @@ -3,11 +3,11 @@ # Makefile for the linux kernel. # =20 -extra-y :=3D head.o vmlinux.lds +extra-y :=3D vmlinux.lds asflags-y :=3D $(KBUILD_CFLAGS) ccflags-y :=3D -Wno-sign-compare =20 -obj-y :=3D entry.o traps.o process.o osf_sys.o irq.o \ +obj-y :=3D head.o entry.o traps.o process.o osf_sys.o irq.o \ irq_alpha.o signal.o setup.o ptrace.o time.o \ systbls.o err_common.o io.o bugs.o =20 diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 8c4fc4b54c14..0723d888ac44 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -3,7 +3,7 @@ # Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.co= m) # =20 -obj-y :=3D arcksyms.o setup.o irq.o reset.o ptrace.o process.o devtree.o +obj-y :=3D head.o arcksyms.o setup.o irq.o reset.o ptrace.o process.o devt= ree.o obj-y +=3D signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o obj-$(CONFIG_ISA_ARCOMPACT) +=3D entry-compact.o intc-compact.o obj-$(CONFIG_ISA_ARCV2) +=3D entry-arcv2.o intc-arcv2.o @@ -31,4 +31,4 @@ else obj-y +=3D ctx_sw_asm.o endif =20 -extra-y :=3D vmlinux.lds head.o +extra-y :=3D vmlinux.lds diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 553866751e1a..8feaa3217ec5 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -89,7 +89,7 @@ obj-$(CONFIG_VDSO) +=3D vdso.o obj-$(CONFIG_EFI) +=3D efi.o obj-$(CONFIG_PARAVIRT) +=3D paravirt.o =20 -head-y :=3D head$(MMUEXT).o +obj-y +=3D head$(MMUEXT).o obj-$(CONFIG_DEBUG_LL) +=3D debug.o obj-$(CONFIG_EARLY_PRINTK) +=3D early_printk.o obj-$(CONFIG_ARM_PATCH_PHYS_VIRT) +=3D phys2virt.o @@ -109,4 +109,4 @@ obj-$(CONFIG_HAVE_ARM_SMCCC) +=3D smccc-call.o =20 obj-$(CONFIG_GENERIC_CPU_VULNERABILITIES) +=3D spectre.o =20 -extra-y :=3D $(head-y) vmlinux.lds +extra-y :=3D vmlinux.lds diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 1add7b01efa7..b619ff207a57 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -85,8 +85,8 @@ $(obj)/vdso-wrap.o: $(obj)/vdso/vdso.so $(obj)/vdso32-wrap.o: $(obj)/vdso32/vdso.so =20 obj-y +=3D probes/ -head-y :=3D head.o -extra-y +=3D $(head-y) vmlinux.lds +obj-y +=3D head.o +extra-y +=3D vmlinux.lds =20 ifeq ($(CONFIG_DEBUG_EFI),y) AFLAGS_head.o +=3D -DVMLINUX_PATH=3D"\"$(realpath $(objtree)/vmlinux)\"" diff --git a/arch/csky/kernel/Makefile b/arch/csky/kernel/Makefile index 6f14c924b20d..8a868316b912 100644 --- a/arch/csky/kernel/Makefile +++ b/arch/csky/kernel/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only -extra-y :=3D head.o vmlinux.lds +extra-y :=3D vmlinux.lds =20 -obj-y +=3D entry.o atomic.o signal.o traps.o irq.o time.o vdso.o vdso/ +obj-y +=3D head.o entry.o atomic.o signal.o traps.o irq.o time.o vdso.o vd= so/ obj-y +=3D power.o syscall.o syscall_table.o setup.o io.o obj-y +=3D process.o cpu-probe.o ptrace.o stacktrace.o obj-y +=3D probes/ diff --git a/arch/hexagon/kernel/Makefile b/arch/hexagon/kernel/Makefile index fae3dce32fde..e73cb321630e 100644 --- a/arch/hexagon/kernel/Makefile +++ b/arch/hexagon/kernel/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -extra-y :=3D head.o vmlinux.lds +extra-y :=3D vmlinux.lds =20 +obj-y +=3D head.o obj-$(CONFIG_SMP) +=3D smp.o =20 obj-y +=3D setup.o irq_cpu.o traps.o syscalltab.o signal.o time.o diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile index 08d4a2ba0652..4a1fcb121dda 100644 --- a/arch/ia64/kernel/Makefile +++ b/arch/ia64/kernel/Makefile @@ -7,9 +7,9 @@ ifdef CONFIG_DYNAMIC_FTRACE CFLAGS_REMOVE_ftrace.o =3D -pg endif =20 -extra-y :=3D head.o vmlinux.lds +extra-y :=3D vmlinux.lds =20 -obj-y :=3D entry.o efi.o efi_stub.o gate-data.o fsys.o irq.o irq_ia64.o \ +obj-y :=3D head.o entry.o efi.o efi_stub.o gate-data.o fsys.o irq.o irq_ia= 64.o \ irq_lsapic.o ivt.o pal.o patch.o process.o ptrace.o sal.o \ salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \ unwind.o mca.o mca_asm.o topology.o dma-mapping.o iosapic.o acpi.o \ diff --git a/arch/loongarch/kernel/Makefile b/arch/loongarch/kernel/Makefile index e5be17009fe8..6c33b5c45573 100644 --- a/arch/loongarch/kernel/Makefile +++ b/arch/loongarch/kernel/Makefile @@ -3,9 +3,9 @@ # Makefile for the Linux/LoongArch kernel. # =20 -extra-y :=3D head.o vmlinux.lds +extra-y :=3D vmlinux.lds =20 -obj-y +=3D cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \ +obj-y +=3D head.o cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \ traps.o irq.o idle.o process.o dma.o mem.o io.o reset.o switch.o \ elf.o syscall.o signal.o time.o topology.o inst.o ptrace.o vdso.o =20 diff --git a/arch/m68k/68000/Makefile b/arch/m68k/68000/Makefile index 674541fdf5b8..279560add577 100644 --- a/arch/m68k/68000/Makefile +++ b/arch/m68k/68000/Makefile @@ -17,4 +17,4 @@ obj-$(CONFIG_DRAGEN2) +=3D dragen2.o obj-$(CONFIG_UCSIMM) +=3D ucsimm.o obj-$(CONFIG_UCDIMM) +=3D ucsimm.o =20 -extra-y :=3D head.o +obj-y +=3D head.o diff --git a/arch/m68k/coldfire/Makefile b/arch/m68k/coldfire/Makefile index 9419a6c1f036..c56bc0dc7f2e 100644 --- a/arch/m68k/coldfire/Makefile +++ b/arch/m68k/coldfire/Makefile @@ -45,4 +45,4 @@ obj-$(CONFIG_STMARK2) +=3D stmark2.o obj-$(CONFIG_PCI) +=3D pci.o =20 obj-y +=3D gpio.o -extra-y :=3D head.o +obj-y +=3D head.o diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile index c0833da6a2ca..1755e6cd309f 100644 --- a/arch/m68k/kernel/Makefile +++ b/arch/m68k/kernel/Makefile @@ -3,18 +3,19 @@ # Makefile for the linux kernel. # =20 -extra-$(CONFIG_AMIGA) :=3D head.o -extra-$(CONFIG_ATARI) :=3D head.o -extra-$(CONFIG_MAC) :=3D head.o -extra-$(CONFIG_APOLLO) :=3D head.o -extra-$(CONFIG_VME) :=3D head.o -extra-$(CONFIG_HP300) :=3D head.o -extra-$(CONFIG_Q40) :=3D head.o -extra-$(CONFIG_SUN3X) :=3D head.o -extra-$(CONFIG_VIRT) :=3D head.o -extra-$(CONFIG_SUN3) :=3D sun3-head.o extra-y +=3D vmlinux.lds =20 +obj-$(CONFIG_AMIGA) :=3D head.o +obj-$(CONFIG_ATARI) :=3D head.o +obj-$(CONFIG_MAC) :=3D head.o +obj-$(CONFIG_APOLLO) :=3D head.o +obj-$(CONFIG_VME) :=3D head.o +obj-$(CONFIG_HP300) :=3D head.o +obj-$(CONFIG_Q40) :=3D head.o +obj-$(CONFIG_SUN3X) :=3D head.o +obj-$(CONFIG_VIRT) :=3D head.o +obj-$(CONFIG_SUN3) :=3D sun3-head.o + obj-y :=3D entry.o irq.o module.o process.o ptrace.o obj-y +=3D setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o =20 diff --git a/arch/microblaze/kernel/Makefile b/arch/microblaze/kernel/Makef= ile index 15a20eb814ce..4393bee64eaf 100644 --- a/arch/microblaze/kernel/Makefile +++ b/arch/microblaze/kernel/Makefile @@ -12,9 +12,9 @@ CFLAGS_REMOVE_ftrace.o =3D -pg CFLAGS_REMOVE_process.o =3D -pg endif =20 -extra-y :=3D head.o vmlinux.lds +extra-y :=3D vmlinux.lds =20 -obj-y +=3D dma.o exceptions.o \ +obj-y +=3D head.o dma.o exceptions.o \ hw_exception_handler.o irq.o \ process.o prom.o ptrace.o \ reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile index 7c96282bff2e..5d1addac5e28 100644 --- a/arch/mips/kernel/Makefile +++ b/arch/mips/kernel/Makefile @@ -3,9 +3,9 @@ # Makefile for the Linux/MIPS kernel. # =20 -extra-y :=3D head.o vmlinux.lds +extra-y :=3D vmlinux.lds =20 -obj-y +=3D branch.o cmpxchg.o elf.o entry.o genex.o idle.o irq.o \ +obj-y +=3D head.o branch.o cmpxchg.o elf.o entry.o genex.o idle.o irq.o \ process.o prom.o ptrace.o reset.o setup.o signal.o \ syscall.o time.o topology.o traps.o unaligned.o watch.o \ vdso.o cacheinfo.o diff --git a/arch/nios2/kernel/Makefile b/arch/nios2/kernel/Makefile index 0b645e1e3158..78a913181fa1 100644 --- a/arch/nios2/kernel/Makefile +++ b/arch/nios2/kernel/Makefile @@ -3,9 +3,9 @@ # Makefile for the nios2 linux kernel. # =20 -extra-y +=3D head.o extra-y +=3D vmlinux.lds =20 +obj-y +=3D head.o obj-y +=3D cpuinfo.o obj-y +=3D entry.o obj-y +=3D insnemu.o diff --git a/arch/openrisc/kernel/Makefile b/arch/openrisc/kernel/Makefile index 2d172e79f58d..79129161f3e0 100644 --- a/arch/openrisc/kernel/Makefile +++ b/arch/openrisc/kernel/Makefile @@ -3,9 +3,9 @@ # Makefile for the linux kernel. # =20 -extra-y :=3D head.o vmlinux.lds +extra-y :=3D vmlinux.lds =20 -obj-y :=3D setup.o or32_ksyms.o process.o dma.o \ +obj-y :=3D head.o setup.o or32_ksyms.o process.o dma.o \ traps.o time.o irq.o entry.o ptrace.o signal.o \ sys_call_table.o unwinder.o =20 diff --git a/arch/parisc/kernel/Makefile b/arch/parisc/kernel/Makefile index d0bfac89a842..3d138c9cf9ce 100644 --- a/arch/parisc/kernel/Makefile +++ b/arch/parisc/kernel/Makefile @@ -3,9 +3,9 @@ # Makefile for arch/parisc/kernel # =20 -extra-y :=3D head.o vmlinux.lds +extra-y :=3D vmlinux.lds =20 -obj-y :=3D cache.o pacache.o setup.o pdt.o traps.o time.o irq.o \ +obj-y :=3D head.o cache.o pacache.o setup.o pdt.o traps.o time.o irq.o \ pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \ ptrace.o hardware.o inventory.o drivers.o alternative.o \ signal.o hpmc.o real2.o parisc_ksyms.o unaligned.o \ diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 06d2d1f78f71..f264d9b2cb63 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -118,12 +118,12 @@ obj-$(CONFIG_PPC_FSL_BOOK3E) +=3D cpu_setup_fsl_booke= .o obj-$(CONFIG_PPC_DOORBELL) +=3D dbell.o obj-$(CONFIG_JUMP_LABEL) +=3D jump_label.o =20 -extra-$(CONFIG_PPC64) :=3D head_64.o -extra-$(CONFIG_PPC_BOOK3S_32) :=3D head_book3s_32.o -extra-$(CONFIG_40x) :=3D head_40x.o -extra-$(CONFIG_44x) :=3D head_44x.o -extra-$(CONFIG_FSL_BOOKE) :=3D head_fsl_booke.o -extra-$(CONFIG_PPC_8xx) :=3D head_8xx.o +obj-$(CONFIG_PPC64) +=3D head_64.o +obj-$(CONFIG_PPC_BOOK3S_32) +=3D head_book3s_32.o +obj-$(CONFIG_40x) +=3D head_40x.o +obj-$(CONFIG_44x) +=3D head_44x.o +obj-$(CONFIG_FSL_BOOKE) +=3D head_fsl_booke.o +obj-$(CONFIG_PPC_8xx) +=3D head_8xx.o extra-y +=3D vmlinux.lds =20 obj-$(CONFIG_RELOCATABLE) +=3D reloc_$(BITS).o @@ -198,12 +198,12 @@ KCOV_INSTRUMENT_paca.o :=3D n CFLAGS_setup_64.o +=3D -fno-stack-protector CFLAGS_paca.o +=3D -fno-stack-protector =20 -extra-$(CONFIG_PPC_FPU) +=3D fpu.o -extra-$(CONFIG_ALTIVEC) +=3D vector.o -extra-$(CONFIG_PPC64) +=3D entry_64.o -extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) +=3D prom_init.o +obj-$(CONFIG_PPC_FPU) +=3D fpu.o +obj-$(CONFIG_ALTIVEC) +=3D vector.o +obj-$(CONFIG_PPC64) +=3D entry_64.o +obj-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) +=3D prom_init.o =20 -extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) +=3D prom_init_check +obj-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) +=3D prom_init_check =20 quiet_cmd_prom_init_check =3D PROMCHK $@ cmd_prom_init_check =3D $(CONFIG_SHELL) $< "$(NM)" $(obj)/prom_init.= o; touch $@ diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 33bb60a354cd..db6e4b1294ba 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -28,9 +28,9 @@ KASAN_SANITIZE_cpufeature.o :=3D n endif endif =20 -extra-y +=3D head.o extra-y +=3D vmlinux.lds =20 +obj-y +=3D head.o obj-y +=3D soc.o obj-$(CONFIG_RISCV_ALTERNATIVE) +=3D alternative.o obj-y +=3D cpu.o diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile index 3cbfa9fddd9a..7ce00816b8df 100644 --- a/arch/s390/kernel/Makefile +++ b/arch/s390/kernel/Makefile @@ -33,7 +33,7 @@ CFLAGS_stacktrace.o +=3D -fno-optimize-sibling-calls CFLAGS_dumpstack.o +=3D -fno-optimize-sibling-calls CFLAGS_unwind_bc.o +=3D -fno-optimize-sibling-calls =20 -obj-y :=3D traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtim= e.o +obj-y :=3D head64.o traps.o time.o process.o earlypgm.o early.o setup.o id= le.o vtime.o obj-y +=3D processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o obj-y +=3D debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o obj-y +=3D sysinfo.o lgr.o os_info.o machine_kexec.o @@ -42,7 +42,7 @@ obj-y +=3D entry.o reipl.o relocate_kernel.o kdebugfs.o a= lternative.o obj-y +=3D nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o obj-y +=3D smp.o text_amode31.o stacktrace.o =20 -extra-y +=3D head64.o vmlinux.lds +extra-y +=3D vmlinux.lds =20 obj-$(CONFIG_SYSFS) +=3D nospec-sysfs.o CFLAGS_REMOVE_nospec-branch.o +=3D $(CC_FLAGS_EXPOLINE) diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile index aa0fbc9202b1..69cd9ac4b2ab 100644 --- a/arch/sh/kernel/Makefile +++ b/arch/sh/kernel/Makefile @@ -3,7 +3,7 @@ # Makefile for the Linux/SuperH kernel. # =20 -extra-y :=3D head_32.o vmlinux.lds +extra-y :=3D vmlinux.lds =20 ifdef CONFIG_FUNCTION_TRACER # Do not profile debug and lowlevel utilities @@ -12,7 +12,7 @@ endif =20 CFLAGS_REMOVE_return_address.o =3D -pg =20 -obj-y :=3D debugtraps.o dumpstack.o \ +obj-y :=3D head_32.o debugtraps.o dumpstack.o \ idle.o io.o irq.o irq_32.o kdebugfs.o \ machvec.o nmi_debug.o process.o \ process_32.o ptrace.o ptrace_32.o \ diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile index d3a0e072ebe8..b328e4a0bd57 100644 --- a/arch/sparc/kernel/Makefile +++ b/arch/sparc/kernel/Makefile @@ -7,8 +7,6 @@ asflags-y :=3D -ansi ccflags-y :=3D -Werror =20 -extra-y :=3D head_$(BITS).o - # Undefine sparc when processing vmlinux.lds - it is used # And teach CPP we are doing $(BITS) builds (for this case) CPPFLAGS_vmlinux.lds :=3D -Usparc -m$(BITS) @@ -22,6 +20,7 @@ CFLAGS_REMOVE_perf_event.o :=3D -pg CFLAGS_REMOVE_pcr.o :=3D -pg endif =20 +obj-y :=3D head_$(BITS).o obj-$(CONFIG_SPARC64) +=3D urtt_fill.o obj-$(CONFIG_SPARC32) +=3D entry.o wof.o wuf.o obj-$(CONFIG_SPARC32) +=3D etrap_32.o diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index a20a5ebfacd7..956e50ca06e0 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -3,10 +3,6 @@ # Makefile for the linux kernel. # =20 -extra-y :=3D head_$(BITS).o -extra-y +=3D head$(BITS).o -extra-y +=3D ebda.o -extra-y +=3D platform-quirks.o extra-y +=3D vmlinux.lds =20 CPPFLAGS_vmlinux.lds +=3D -U$(UTS_MACHINE) @@ -42,7 +38,11 @@ KCOV_INSTRUMENT :=3D n =20 CFLAGS_irq.o :=3D -I $(srctree)/$(src)/../include/asm/trace =20 -obj-y :=3D process_$(BITS).o signal.o +obj-y +=3D head_$(BITS).o +obj-y +=3D head$(BITS).o +obj-y +=3D ebda.o +obj-y +=3D platform-quirks.o +obj-y +=3D process_$(BITS).o signal.o obj-$(CONFIG_COMPAT) +=3D signal_compat.o obj-y +=3D traps.o idt.o irq.o irq_$(BITS).o dumpstack_$(BITS).o obj-y +=3D time.o ioport.o dumpstack.o nmi.o diff --git a/arch/xtensa/kernel/Makefile b/arch/xtensa/kernel/Makefile index 897c1c741058..f28b8e3d717e 100644 --- a/arch/xtensa/kernel/Makefile +++ b/arch/xtensa/kernel/Makefile @@ -3,9 +3,9 @@ # Makefile for the Linux/Xtensa kernel. # =20 -extra-y :=3D head.o vmlinux.lds +extra-y :=3D vmlinux.lds =20 -obj-y :=3D align.o coprocessor.o entry.o irq.o platform.o process.o \ +obj-y :=3D head.o align.o coprocessor.o entry.o irq.o platform.o process.o= \ ptrace.o setup.o signal.o stacktrace.o syscall.o time.o traps.o \ vectors.o =20 diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index d7d3138c5ecc..4f74370ad1ee 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -70,13 +70,12 @@ quiet_cmd_vmlinux_objs =3D GEN $@ for f in $(real-prereqs); do \ case $${f} in \ *libgcc.a) ;; \ - *.a) $(AR) t $${f} ;; \ - *) echo $${f} ;; \ + *) $(AR) t $${f} ;; \ esac \ done > $@ =20 targets +=3D .vmlinux.objs -.vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE +.vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE $(call if_changed,vmlinux_objs) =20 vmlinux.o-if-present :=3D $(wildcard vmlinux.o) diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 84019814f33f..81a4e0484457 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -18,7 +18,7 @@ quiet_cmd_gen_initcalls_lds =3D GEN $@ $(PERL) $(real-prereqs) > $@ =20 .tmp_initcalls.lds: $(srctree)/scripts/generate_initcall_order.pl \ - $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE + vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE $(call if_changed,gen_initcalls_lds) =20 targets :=3D .tmp_initcalls.lds @@ -55,7 +55,7 @@ quiet_cmd_ld_vmlinux.o =3D LD $@ cmd_ld_vmlinux.o =3D \ $(LD) ${KBUILD_LDFLAGS} -r -o $@ \ $(addprefix -T , $(initcalls-lds)) \ - --whole-archive $(KBUILD_VMLINUX_OBJS) --no-whole-archive \ + --whole-archive vmlinux.a --no-whole-archive \ --start-group $(KBUILD_VMLINUX_LIBS) --end-group \ $(cmd_objtool) =20 @@ -64,7 +64,7 @@ define rule_ld_vmlinux.o $(call cmd,gen_objtooldep) endef =20 -vmlinux.o: $(initcalls-lds) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) = FORCE +vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE $(call if_changed_rule,ld_vmlinux.o) =20 targets +=3D vmlinux.o diff --git a/scripts/clang-tools/gen_compile_commands.py b/scripts/clang-to= ols/gen_compile_commands.py index 47da25b3ba7d..d800b2c0af97 100755 --- a/scripts/clang-tools/gen_compile_commands.py +++ b/scripts/clang-tools/gen_compile_commands.py @@ -109,20 +109,6 @@ def to_cmdfile(path): return os.path.join(dir, '.' + base + '.cmd') =20 =20 -def cmdfiles_for_o(obj): - """Generate the iterator of .cmd files associated with the object - - Yield the .cmd file used to build the given object - - Args: - obj: The object path - - Yields: - The path to .cmd file - """ - yield to_cmdfile(obj) - - def cmdfiles_for_a(archive, ar): """Generate the iterator of .cmd files associated with the archive. =20 @@ -211,13 +197,10 @@ def main(): for path in paths: # If 'path' is a directory, handle all .cmd files under it. # Otherwise, handle .cmd files associated with the file. - # Most of built-in objects are linked via archives (built-in.a or = lib.a) - # but some objects are linked to vmlinux directly. + # built-in objects are linked via vmlinux.a # Modules are listed in modules.order. if os.path.isdir(path): cmdfiles =3D cmdfiles_in_dir(path) - elif path.endswith('.o'): - cmdfiles =3D cmdfiles_for_o(path) elif path.endswith('.a'): cmdfiles =3D cmdfiles_for_a(path, ar) elif path.endswith('modules.order'): diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 6a197d8a88ac..23ac13fd9d89 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -3,17 +3,15 @@ # # link vmlinux # -# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and -# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directo= ries -# in the kernel tree, others are specified in arch/$(ARCH)/Makefile. +# vmlinux is linked from the objects in vmlinux.a and $(KBUILD_VMLINUX_LIB= S). +# vmlinux.a contains objects that are linked unconditionally. # $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally # (not within --whole-archive), and do not require symbol indexes added. # # vmlinux # ^ # | -# +--< $(KBUILD_VMLINUX_OBJS) -# | +--< init/built-in.a drivers/built-in.a mm/built-in.a + more +# +--< vmlinux.a # | # +--< $(KBUILD_VMLINUX_LIBS) # | +--< lib/lib.a + more @@ -67,7 +65,7 @@ vmlinux_link() objs=3Dvmlinux.o libs=3D else - objs=3D"${KBUILD_VMLINUX_OBJS}" + objs=3Dvmlinux.a libs=3D"${KBUILD_VMLINUX_LIBS}" fi =20 --=20 2.34.1 From nobody Tue Apr 14 15:42:11 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 9EE55C0502A for ; Sun, 28 Aug 2022 02:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231982AbiH1Cl1 (ORCPT ); Sat, 27 Aug 2022 22:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiH1Ckt (ORCPT ); Sat, 27 Aug 2022 22:40:49 -0400 Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 738D7286FE; Sat, 27 Aug 2022 19:40:42 -0700 (PDT) Received: from localhost.localdomain (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-11.nifty.com with ESMTP id 27S2e6Gx030639; Sun, 28 Aug 2022 11:40:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com 27S2e6Gx030639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1661654414; bh=EJuEUsvnLUK5pwpXzsPIse4yy9Ubav5beZtBE0mnRbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CUetq+ov6jTLmtJTAcyWq8rvsI6X0cowG49mt2xyG2gdbvvCrn96MtBEMBg+rwbRi VCu6j/VwYDTwpCmpWoKEKylcvL3B512ikL7AdUdnvMMlnX9rTvPy3Zj1QnKQ1Fi+CH YECmHZ97QgjQJh3JT9KFTQcNWPz3v+7UMTYK+PDAr2tNeBHz6Q7XRseIuNQjKKOXQC oAvjSHGrZSqPzBrM4hzcCEZb0Rtqep8N9cRfpeM5QX3LGIyXVTtkjTy9ZPx6VXnxUb OWqstP2bxvFnt8ix+lL8Y9WYOKAhO3H6WSxLSB2QBNGaZsr0Ot16U0PptQJUF+ie9m vuDf8Wj3NRoRQ== 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 15/15] kbuild: remove head-y syntax Date: Sun, 28 Aug 2022 11:40:03 +0900 Message-Id: <20220828024003.28873-16-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220828024003.28873-1-masahiroy@kernel.org> References: <20220828024003.28873-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" Kbuild puts the objects listed in head-y at the head of vmlinux. Conventionally, we do this for head*.S, which contains the kernel entry point. A counter approach is to control the section order in the linker script. Actually, the code marked as __HEAD goes into the ".head.text" section, which is placed before the normal ".text" section. I do not know if both of them are needed. head-y is not mandatory. If you can achieve the proper code placement by the linker script only, it would be cleaner. I collected the current head-y objects into head-object-list.txt. It is a whitelist. My hope is it will be reduced in the long run. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.rst | 9 ++--- Makefile | 4 +-- arch/alpha/Makefile | 2 -- arch/arc/Makefile | 2 -- arch/arm/Makefile | 3 -- arch/arm64/Makefile | 3 -- arch/csky/Makefile | 2 -- arch/hexagon/Makefile | 2 -- arch/ia64/Makefile | 1 - arch/loongarch/Makefile | 2 -- arch/m68k/Makefile | 9 ----- arch/microblaze/Makefile | 1 - arch/mips/Makefile | 2 -- arch/nios2/Makefile | 1 - arch/openrisc/Makefile | 2 -- arch/parisc/Makefile | 2 -- arch/powerpc/Makefile | 12 ------- arch/riscv/Makefile | 2 -- arch/s390/Makefile | 2 -- arch/sh/Makefile | 2 -- arch/sparc/Makefile | 2 -- arch/x86/Makefile | 5 --- arch/xtensa/Makefile | 2 -- scripts/head-object-list.txt | 53 ++++++++++++++++++++++++++++++ 24 files changed, 60 insertions(+), 67 deletions(-) create mode 100644 scripts/head-object-list.txt diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/make= files.rst index 07c7e5a843c1..528c54d56c09 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -1065,8 +1065,7 @@ When kbuild executes, the following steps are followe= d (roughly): - The values of the above variables are expanded in arch/$(SRCARCH)/Mak= efile. 5) All object files are then linked and the resulting file vmlinux is located at the root of the obj tree. - The very first objects linked are listed in head-y, assigned by - arch/$(SRCARCH)/Makefile. + The very first objects linked are listed in scripts/head-object-list.tx= t. 6) Finally, the architecture-specific part does any required post processi= ng and builds the final bootimage. - This includes building boot records @@ -1214,6 +1213,9 @@ When kbuild executes, the following steps are followe= d (roughly): All object files for vmlinux. They are linked to vmlinux in the same order as listed in KBUILD_VMLINUX_OBJS. =20 + The objects listed in scripts/head-object-list.txt are exceptions; + they are placed before the other objects. + KBUILD_VMLINUX_LIBS =20 All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and @@ -1257,8 +1259,7 @@ When kbuild executes, the following steps are followe= d (roughly): machinery is all architecture-independent. =20 =20 - head-y, core-y, libs-y, drivers-y - $(head-y) lists objects to be linked first in vmlinux. + core-y, libs-y, drivers-y =20 $(libs-y) lists directories where a lib.a archive can be located. =20 diff --git a/Makefile b/Makefile index d74aa4552d35..08e69448caf4 100644 --- a/Makefile +++ b/Makefile @@ -1159,10 +1159,10 @@ quiet_cmd_ar_vmlinux.a =3D AR $@ cmd_ar_vmlinux.a =3D \ rm -f $@; \ $(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \ - $(AR) mPi $$($(AR) t $@| head -n1) $@ $(head-y) + $(AR) mPi $$($(AR) t $@| head -n1) $@ $$($(AR) t $@ | grep -F --file=3D$(= srctree)/scripts/head-object-list.txt) =20 targets +=3D vmlinux.a -vmlinux.a: $(KBUILD_VMLINUX_OBJS) FORCE +vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE $(call if_changed,ar_vmlinux.a) =20 targets +=3D vmlinux.o diff --git a/arch/alpha/Makefile b/arch/alpha/Makefile index 881cb913e23a..45158024085e 100644 --- a/arch/alpha/Makefile +++ b/arch/alpha/Makefile @@ -36,8 +36,6 @@ cflags-y +=3D $(cpuflags-y) # BWX is most important, but we don't really want any emulation ever. KBUILD_CFLAGS +=3D $(cflags-y) -Wa,-mev6 =20 -head-y :=3D arch/alpha/kernel/head.o - libs-y +=3D arch/alpha/lib/ =20 # export what is needed by arch/alpha/boot/Makefile diff --git a/arch/arc/Makefile b/arch/arc/Makefile index efc54f3e35e0..329400a1c355 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -82,8 +82,6 @@ KBUILD_CFLAGS +=3D $(cflags-y) KBUILD_AFLAGS +=3D $(KBUILD_CFLAGS) KBUILD_LDFLAGS +=3D $(ldflags-y) =20 -head-y :=3D arch/arc/kernel/head.o - # w/o this dtb won't embed into kernel binary core-y +=3D arch/arc/boot/dts/ =20 diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 56f655deebb1..29d15c9a433e 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -134,9 +134,6 @@ KBUILD_AFLAGS +=3D$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y)= $(tune-y) -include asm/uni =20 CHECKFLAGS +=3D -D__arm__ =20 -#Default value -head-y :=3D arch/arm/kernel/head$(MMUEXT).o - # Text offset. This list is sorted numerically by address in order to # provide a means to avoid/resolve conflicts in multi-arch kernels. # Note: the 32kB below this value is reserved for use by the kernel diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 6d9d4a58b898..6e03f15bb041 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -133,9 +133,6 @@ ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_REGS),y) CC_FLAGS_FTRACE :=3D -fpatchable-function-entry=3D2 endif =20 -# Default value -head-y :=3D arch/arm64/kernel/head.o - ifeq ($(CONFIG_KASAN_SW_TAGS), y) KASAN_SHADOW_SCALE_SHIFT :=3D 4 else ifeq ($(CONFIG_KASAN_GENERIC), y) diff --git a/arch/csky/Makefile b/arch/csky/Makefile index 4e1d619fd5c6..0e4237e55758 100644 --- a/arch/csky/Makefile +++ b/arch/csky/Makefile @@ -59,8 +59,6 @@ LDFLAGS +=3D -EL =20 KBUILD_AFLAGS +=3D $(KBUILD_CFLAGS) =20 -head-y :=3D arch/csky/kernel/head.o - core-y +=3D arch/csky/$(CSKYABI)/ =20 libs-y +=3D arch/csky/lib/ \ diff --git a/arch/hexagon/Makefile b/arch/hexagon/Makefile index 44312bc147d8..92d005958dfb 100644 --- a/arch/hexagon/Makefile +++ b/arch/hexagon/Makefile @@ -32,5 +32,3 @@ KBUILD_LDFLAGS +=3D $(ldflags-y) TIR_NAME :=3D r19 KBUILD_CFLAGS +=3D -ffixed-$(TIR_NAME) -DTHREADINFO_REG=3D$(TIR_NAME) -D__= linux__ KBUILD_AFLAGS +=3D -DTHREADINFO_REG=3D$(TIR_NAME) - -head-y :=3D arch/hexagon/kernel/head.o diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile index e55c2f138656..56c4bb276b6e 100644 --- a/arch/ia64/Makefile +++ b/arch/ia64/Makefile @@ -44,7 +44,6 @@ quiet_cmd_objcopy =3D OBJCOPY $@ cmd_objcopy =3D $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ =20 KBUILD_CFLAGS +=3D $(cflags-y) -head-y :=3D arch/ia64/kernel/head.o =20 libs-y +=3D arch/ia64/lib/ =20 diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index ec3de6191276..131fc210c2bf 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -72,8 +72,6 @@ CHECKFLAGS +=3D $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x = c /dev/null | \ sed -e "s/^\#define /-D'/" -e "s/ /'=3D'/" -e "s/$$/'/" -e 's/\$$/&&/g') endif =20 -head-y :=3D arch/loongarch/kernel/head.o - libs-y +=3D arch/loongarch/lib/ =20 ifeq ($(KBUILD_EXTMOD),) diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile index e358605b70ba..43e39040d3ac 100644 --- a/arch/m68k/Makefile +++ b/arch/m68k/Makefile @@ -86,15 +86,6 @@ ifdef CONFIG_KGDB KBUILD_CFLAGS :=3D $(subst -fomit-frame-pointer,,$(KBUILD_CFLAGS)) -g endif =20 -# -# Select the assembler head startup code. Order is important. The default -# head code is first, processor specific selections can override it after. -# -head-y :=3D arch/m68k/kernel/head.o -head-$(CONFIG_SUN3) :=3D arch/m68k/kernel/sun3-head.o -head-$(CONFIG_M68000) :=3D arch/m68k/68000/head.o -head-$(CONFIG_COLDFIRE) :=3D arch/m68k/coldfire/head.o - libs-y +=3D arch/m68k/lib/ =20 =20 diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile index 1826d9ce4459..3f8a86c4336a 100644 --- a/arch/microblaze/Makefile +++ b/arch/microblaze/Makefile @@ -48,7 +48,6 @@ CPUFLAGS-1 +=3D $(call cc-option,-mcpu=3Dv$(CPU_VER)) # r31 holds current when in kernel mode KBUILD_CFLAGS +=3D -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2) =20 -head-y :=3D arch/microblaze/kernel/head.o libs-y +=3D arch/microblaze/lib/ =20 boot :=3D arch/microblaze/boot diff --git a/arch/mips/Makefile b/arch/mips/Makefile index 4d2a3e73fc45..b296e33f8e33 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -324,8 +324,6 @@ endif =20 OBJCOPYFLAGS +=3D --remove-section=3D.reginfo =20 -head-y :=3D arch/mips/kernel/head.o - libs-y +=3D arch/mips/lib/ libs-$(CONFIG_MIPS_FP_SUPPORT) +=3D arch/mips/math-emu/ =20 diff --git a/arch/nios2/Makefile b/arch/nios2/Makefile index 3f34e6831863..f1ff4ce0f1a2 100644 --- a/arch/nios2/Makefile +++ b/arch/nios2/Makefile @@ -37,7 +37,6 @@ KBUILD_CFLAGS +=3D -DUTS_SYSNAME=3D\"$(UTS_SYSNAME)\" KBUILD_CFLAGS +=3D -fno-builtin KBUILD_CFLAGS +=3D -G 0 =20 -head-y :=3D arch/nios2/kernel/head.o libs-y +=3D arch/nios2/lib/ $(LIBGCC) =20 INSTALL_PATH ?=3D /tftpboot diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile index b446510173cd..68249521db5a 100644 --- a/arch/openrisc/Makefile +++ b/arch/openrisc/Makefile @@ -55,8 +55,6 @@ ifeq ($(CONFIG_OPENRISC_HAVE_INST_SEXT),y) KBUILD_CFLAGS +=3D $(call cc-option,-msext) endif =20 -head-y :=3D arch/openrisc/kernel/head.o - libs-y +=3D $(LIBGCC) =20 PHONY +=3D vmlinux.bin diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile index e38d993d87f2..a2d8600521f9 100644 --- a/arch/parisc/Makefile +++ b/arch/parisc/Makefile @@ -113,8 +113,6 @@ cflags-$(CONFIG_PA7100LC) +=3D -march=3D1.1 -mschedule= =3D7100LC cflags-$(CONFIG_PA7300LC) +=3D -march=3D1.1 -mschedule=3D7300 cflags-$(CONFIG_PA8X00) +=3D -march=3D2.0 -mschedule=3D8000 =20 -head-y :=3D arch/parisc/kernel/head.o=20 - KBUILD_CFLAGS +=3D $(cflags-y) LIBGCC :=3D $(shell $(CC) -print-libgcc-file-name) export LIBGCC diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index fb607758eeca..491cdeed9a72 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -220,18 +220,6 @@ KBUILD_CFLAGS +=3D $(cpu-as-y) KBUILD_AFLAGS +=3D $(aflags-y) KBUILD_CFLAGS +=3D $(cflags-y) =20 -head-$(CONFIG_PPC64) :=3D arch/powerpc/kernel/head_64.o -head-$(CONFIG_PPC_BOOK3S_32) :=3D arch/powerpc/kernel/head_book3s_32.o -head-$(CONFIG_PPC_8xx) :=3D arch/powerpc/kernel/head_8xx.o -head-$(CONFIG_40x) :=3D arch/powerpc/kernel/head_40x.o -head-$(CONFIG_44x) :=3D arch/powerpc/kernel/head_44x.o -head-$(CONFIG_FSL_BOOKE) :=3D arch/powerpc/kernel/head_fsl_booke.o - -head-$(CONFIG_PPC64) +=3D arch/powerpc/kernel/entry_64.o -head-$(CONFIG_PPC_FPU) +=3D arch/powerpc/kernel/fpu.o -head-$(CONFIG_ALTIVEC) +=3D arch/powerpc/kernel/vector.o -head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) +=3D arch/powerpc/kernel/prom_init.o - # Default to zImage, override when needed all: zImage =20 diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 3fa8ef336822..e013df8e7b8b 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -110,8 +110,6 @@ else KBUILD_IMAGE :=3D $(boot)/Image.gz endif =20 -head-y :=3D arch/riscv/kernel/head.o - libs-y +=3D arch/riscv/lib/ libs-$(CONFIG_EFI_STUB) +=3D $(objtree)/drivers/firmware/efi/libstub/lib.a =20 diff --git a/arch/s390/Makefile b/arch/s390/Makefile index 4cb5d17e7ead..de6d8b2ea4d8 100644 --- a/arch/s390/Makefile +++ b/arch/s390/Makefile @@ -119,8 +119,6 @@ export KBUILD_CFLAGS_DECOMPRESSOR =20 OBJCOPYFLAGS :=3D -O binary =20 -head-y :=3D arch/s390/kernel/head64.o - libs-y +=3D arch/s390/lib/ drivers-y +=3D drivers/s390/ =20 diff --git a/arch/sh/Makefile b/arch/sh/Makefile index b39412bf91fb..5c8776482530 100644 --- a/arch/sh/Makefile +++ b/arch/sh/Makefile @@ -114,8 +114,6 @@ endif =20 export ld-bfd =20 -head-y :=3D arch/sh/kernel/head_32.o - # Mach groups machdir-$(CONFIG_SOLUTION_ENGINE) +=3D mach-se machdir-$(CONFIG_SH_HP6XX) +=3D mach-hp6xx diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile index fe58a410b4ce..a4ea5b05f288 100644 --- a/arch/sparc/Makefile +++ b/arch/sparc/Makefile @@ -56,8 +56,6 @@ endif =20 endif =20 -head-y :=3D arch/sparc/kernel/head_$(BITS).o - libs-y +=3D arch/sparc/prom/ libs-y +=3D arch/sparc/lib/ =20 diff --git a/arch/x86/Makefile b/arch/x86/Makefile index bafbd905e6e7..9afd323c6916 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -234,11 +234,6 @@ archheaders: ### # Kernel objects =20 -head-y :=3D arch/x86/kernel/head_$(BITS).o -head-y +=3D arch/x86/kernel/head$(BITS).o -head-y +=3D arch/x86/kernel/ebda.o -head-y +=3D arch/x86/kernel/platform-quirks.o - libs-y +=3D arch/x86/lib/ =20 # drivers-y are linked after core-y diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile index 5097caa7bf0c..bfd8e433ed62 100644 --- a/arch/xtensa/Makefile +++ b/arch/xtensa/Makefile @@ -55,8 +55,6 @@ KBUILD_CPPFLAGS +=3D $(patsubst %,-I$(srctree)/%include,$= (vardirs) $(plfdirs)) =20 KBUILD_DEFCONFIG :=3D iss_defconfig =20 -head-y :=3D arch/xtensa/kernel/head.o - libs-y +=3D arch/xtensa/lib/ =20 boot :=3D arch/xtensa/boot diff --git a/scripts/head-object-list.txt b/scripts/head-object-list.txt new file mode 100644 index 000000000000..6610e19d0247 --- /dev/null +++ b/scripts/head-object-list.txt @@ -0,0 +1,53 @@ +# Head objects +# +# The objects listed here are placed at the head of vmlinux. A typical use= -case +# is an object that contains the entry point. This is kept for compatibili= ty +# with head-y, Kbuild used to support. +# +# A counter approach is to control the section placement in the linker scr= ipt. +# The code marked as __HEAD goes into the ".head.text" section, which is p= laced +# before the normal ".text" section. +# +# If you can achieve the correct code ordering by linker script, please de= lete +# the entry from this file. +# +arch/alpha/kernel/head.o +arch/arc/kernel/head.o +arch/arm/kernel/head-nommu.o +arch/arm/kernel/head.o +arch/arm64/kernel/head.o +arch/csky/kernel/head.o +arch/hexagon/kernel/head.o +arch/ia64/kernel/head.o +arch/loongarch/kernel/head.o +arch/m68k/68000/head.o +arch/m68k/coldfire/head.o +arch/m68k/kernel/head.o +arch/m68k/kernel/sun3-head.o +arch/microblaze/kernel/head.o +arch/mips/kernel/head.o +arch/nios2/kernel/head.o +arch/openrisc/kernel/head.o +arch/parisc/kernel/head.o +arch/powerpc/kernel/head_40x.o +arch/powerpc/kernel/head_44x.o +arch/powerpc/kernel/head_64.o +arch/powerpc/kernel/head_8xx.o +arch/powerpc/kernel/head_book3s_32.o +arch/powerpc/kernel/head_fsl_booke.o +arch/powerpc/kernel/entry_64.o +arch/powerpc/kernel/fpu.o +arch/powerpc/kernel/vector.o +arch/powerpc/kernel/prom_init.o +arch/riscv/kernel/head.o +arch/s390/kernel/head64.o +arch/sh/kernel/head_32.o +arch/sparc/kernel/head_32.o +arch/sparc/kernel/head_64.o +arch/x86/kernel/head_32.o +arch/x86/kernel/head_64.o +arch/x86/kernel/head32.o +arch/x86/kernel/head64.o +arch/x86/kernel/ebda.o +arch/x86/kernel/platform-quirks.o +arch/xtensa/kernel/head.o --=20 2.34.1