From patchwork Sun Aug 28 02:39:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12957138 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 069D9C0502A for ; Sun, 28 Aug 2022 02:40:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229694AbiH1Ckw (ORCPT ); Sat, 27 Aug 2022 22:40:52 -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 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org .vmlinux.objs is used by modpost, so scripts/Makefile.modpost is a better place to generate it. It is used only when CONFIG_MODVERSIONS=y. 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 += 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 # Directories & files removed with 'make mrproper' MRPROPER_FILES += 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 __modpost: vmlinux.symvers +# 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 = GEN $@ + cmd_vmlinux_objs = \ + for f in $(real-prereqs); do \ + case $${f} in \ + *libgcc.a) ;; \ + *.a) $(AR) t $${f} ;; \ + *) echo $${f} ;; \ + esac \ + done > $@ + +targets += .vmlinux.objs +.vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE + $(call if_changed,vmlinux_objs) + else ifeq ($(KBUILD_EXTMOD),) @@ -134,6 +160,8 @@ ifneq ($(KBUILD_MODPOST_NOFINAL),1) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal endif +endif + PHONY += FORCE FORCE: @@ -141,6 +169,4 @@ existing-targets := $(wildcard $(sort $(targets))) -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) -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 } @@ -218,23 +217,6 @@ fi #link vmlinux.o ${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o" -# 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=1