From patchwork Tue Oct 17 10:37:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13424981 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 15F84CDB474 for ; Tue, 17 Oct 2023 10:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234846AbjJQKiK (ORCPT ); Tue, 17 Oct 2023 06:38:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234594AbjJQKiJ (ORCPT ); Tue, 17 Oct 2023 06:38:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83CA7A2; Tue, 17 Oct 2023 03:38:08 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB2D4C433C7; Tue, 17 Oct 2023 10:38:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697539088; bh=eKMGcZsMQDmh2XIngoO27ap1DpB5rplaSJR1DYg/pc8=; h=From:To:Cc:Subject:Date:From; b=QaRapYwkwmCacW8HwqsxWXC31f2QMHrz+w7jsl7pBJeh3K1VQZVYvfufrilHhTjXd 0EIVa98dnYgBaBrqDHc7TADhJhFHjiXu7JSD1PqXI4coxWuxLdi0D7xwC/PyneKGa4 uSuOVuIxzN0xP8r/KD1DWUcu0mS5vKmwrFFO20/dDsJtbFszzO26DLqZnKguMDRqVn JO5cl1x5GwyOfcEivSoIZUk33J1YlsXTFWde/19Todb+P0Ac2JSqx710uBa/yVKUVH kBOa9m8ejE3dLKufSJAgZJho+OKWZk/ZIFllJ+qZ0x1igUTuAekdovLlkbfN8psEua B8DHWxdhlylww== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Albert Ou , Borislav Petkov , Christophe Leroy , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Michael Ellerman , Nathan Chancellor , Nicholas Piggin , Nick Desaulniers , Nicolas Schier , Palmer Dabbelt , Paul Walmsley , Thomas Bogendoerfer , Thomas Gleixner , linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: [PATCH 1/4] kbuild: remove ARCH_POSTLINK from module builds Date: Tue, 17 Oct 2023 19:37:39 +0900 Message-Id: <20231017103742.130927-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The '%.ko' rule in arch/*/Makefile.postlink does nothing but call the 'true' command. Remove the meaningless code. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- arch/mips/Makefile.postlink | 3 --- arch/powerpc/Makefile.postlink | 3 --- arch/riscv/Makefile.postlink | 3 --- arch/x86/Makefile.postlink | 3 --- scripts/Makefile.modfinal | 5 +---- 5 files changed, 1 insertion(+), 16 deletions(-) diff --git a/arch/mips/Makefile.postlink b/arch/mips/Makefile.postlink index 34e3bd71f3b0..6cfdc149d3bc 100644 --- a/arch/mips/Makefile.postlink +++ b/arch/mips/Makefile.postlink @@ -31,9 +31,6 @@ ifeq ($(CONFIG_RELOCATABLE),y) $(call if_changed,relocs) endif -%.ko: FORCE - @true - clean: @true diff --git a/arch/powerpc/Makefile.postlink b/arch/powerpc/Makefile.postlink index 1f860b3c9bec..ae5a4256b03d 100644 --- a/arch/powerpc/Makefile.postlink +++ b/arch/powerpc/Makefile.postlink @@ -35,9 +35,6 @@ ifdef CONFIG_RELOCATABLE $(call if_changed,relocs_check) endif -%.ko: FORCE - @true - clean: rm -f .tmp_symbols.txt diff --git a/arch/riscv/Makefile.postlink b/arch/riscv/Makefile.postlink index a46fc578b30b..829b9abc91f6 100644 --- a/arch/riscv/Makefile.postlink +++ b/arch/riscv/Makefile.postlink @@ -36,9 +36,6 @@ ifdef CONFIG_RELOCATABLE $(call if_changed,relocs_strip) endif -%.ko: FORCE - @true - clean: @true diff --git a/arch/x86/Makefile.postlink b/arch/x86/Makefile.postlink index 936093d29160..fef2e977cc7d 100644 --- a/arch/x86/Makefile.postlink +++ b/arch/x86/Makefile.postlink @@ -34,9 +34,6 @@ ifeq ($(CONFIG_X86_NEED_RELOCS),y) $(call cmd,strip_relocs) endif -%.ko: FORCE - @true - clean: @rm -f $(OUT_RELOCS)/vmlinux.relocs diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index b3a6aa8fbe8c..8568d256d6fb 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -28,14 +28,11 @@ quiet_cmd_cc_o_c = CC [M] $@ %.mod.o: %.mod.c FORCE $(call if_changed_dep,cc_o_c) -ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) - quiet_cmd_ld_ko_o = LD [M] $@ cmd_ld_ko_o += \ $(LD) -r $(KBUILD_LDFLAGS) \ $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ - -T scripts/module.lds -o $@ $(filter %.o, $^); \ - $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) + -T scripts/module.lds -o $@ $(filter %.o, $^) quiet_cmd_btf_ko = BTF [M] $@ cmd_btf_ko = \ From patchwork Tue Oct 17 10:37:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13424982 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 CC992CDB482 for ; Tue, 17 Oct 2023 10:38:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234911AbjJQKiR (ORCPT ); Tue, 17 Oct 2023 06:38:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234594AbjJQKiQ (ORCPT ); Tue, 17 Oct 2023 06:38:16 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F6EBA2; Tue, 17 Oct 2023 03:38:15 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71C4EC433CA; Tue, 17 Oct 2023 10:38:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697539094; bh=A6qLcCYxkwgWjCL+CxEKfQPWGv0e7JNIKXIZW89MeuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2ytQAQi1GJKjYWyS2S00/+UNBIvCCyZOAFkCE9TFt+3ZueDC4OLAjybipTBO++p7 lSznrtrnBtPgpvlmBNt6OM2fAUeOwQxj4dQNjqNvWKTX+DMCwS4qNiSkTiXcgF7iXX IVWyV/5vgO1OM9YzlILfH8VzLtz/pCA9hqXZrvwDjhxZ+F6gUUJP9/OIEhYH1ElMue dFHIhx2GPCHJTtAQeuqceZ02h0gP8+H7GgB8vFa1SINkFD1W4N0B3HEMOSRPXrmsYA 6ACuJiALmbS0dKkNEiRZKjV1i4jhjjf/Y7/5bJXdH8bcAESPGvcIcVX73YsDJgg5gO Wsuoqa5OLtQBQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Alex Gaynor , Alexei Starovoitov , Alice Ryhl , Andreas Hindborg , Andrii Nakryiko , Benno Lossin , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Boqun Feng , Daniel Borkmann , Gary Guo , Hao Luo , Jiri Olsa , John Fastabend , KP Singh , Martin KaFai Lau , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Song Liu , Stanislav Fomichev , Wedson Almeida Filho , Yonghong Song , bpf@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: [PATCH 2/4] kbuild: avoid too many execution of scripts/pahole-flags.sh Date: Tue, 17 Oct 2023 19:37:40 +0900 Message-Id: <20231017103742.130927-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231017103742.130927-1-masahiroy@kernel.org> References: <20231017103742.130927-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org scripts/pahole-flags.sh is executed so many times. You can check how many times it is invoked during the build, as follows: $ cat <> scripts/pahole-flags.sh > echo "scripts/pahole-flags.sh was executed" >&2 > EOF $ make -s scripts/pahole-flags.sh was executed scripts/pahole-flags.sh was executed scripts/pahole-flags.sh was executed scripts/pahole-flags.sh was executed scripts/pahole-flags.sh was executed [ lots of repeated lines suppressed... ] This scripts is exectuted more than 20 times during the kernel build because PAHOLE_FLAGS is a recursively expanded variable and exported to sub-processes. With the GNU Make >= 4.4, it is executed more than 60 times because exported variables are also passed to other $(shell ) invocations. Without careful coding, it is known to cause an exponential fork explosion. [1] The use of $(shell ) in an exported recursive variable is likely wrong because $(shell ) is always evaluated due to the 'export' keyword, and the evaluation can occur multiple times by the nature of recursive variables. Convert the shell script to a Makefile, which is included only when CONFIG_DEBUG_INFO_BTF=y. [1]: https://savannah.gnu.org/bugs/index.php?64746 Signed-off-by: Masahiro Yamada Reviewed-by: Alan Maguire Tested-by: Alan Maguire Reviewed-by: Nicolas Schier Tested-by: Miguel Ojeda Acked-by: Miguel Ojeda Reviewed-by: Martin Rodriguez Reboredo --- Makefile | 4 +--- scripts/Makefile.btf | 19 +++++++++++++++++++ scripts/pahole-flags.sh | 30 ------------------------------ 3 files changed, 20 insertions(+), 33 deletions(-) create mode 100644 scripts/Makefile.btf delete mode 100755 scripts/pahole-flags.sh diff --git a/Makefile b/Makefile index fed9a6cc3665..eaddec67e5e1 100644 --- a/Makefile +++ b/Makefile @@ -513,8 +513,6 @@ LZ4 = lz4c XZ = xz ZSTD = zstd -PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh) - CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) NOSTDINC_FLAGS := @@ -605,7 +603,6 @@ export KBUILD_RUSTFLAGS RUSTFLAGS_KERNEL RUSTFLAGS_MODULE export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_RUSTFLAGS_MODULE KBUILD_LDFLAGS_MODULE export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL KBUILD_RUSTFLAGS_KERNEL -export PAHOLE_FLAGS # Files to ignore in find ... statements @@ -1002,6 +999,7 @@ KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) # include additional Makefiles when needed include-y := scripts/Makefile.extrawarn include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug +include-$(CONFIG_DEBUG_INFO_BTF)+= scripts/Makefile.btf include-$(CONFIG_KASAN) += scripts/Makefile.kasan include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf new file mode 100644 index 000000000000..82377e470aed --- /dev/null +++ b/scripts/Makefile.btf @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0 + +pahole-ver := $(CONFIG_PAHOLE_VERSION) +pahole-flags-y := + +# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars +ifeq ($(call test-le, $(pahole-ver), 121),y) +pahole-flags-$(call test-ge, $(pahole-ver), 118) += --skip_encoding_btf_vars +endif + +pahole-flags-$(call test-ge, $(pahole-ver), 121) += --btf_gen_floats + +pahole-flags-$(call test-ge, $(pahole-ver), 122) += -j + +pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE) += --lang_exclude=rust + +pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsistent_proto --btf_gen_optimized + +export PAHOLE_FLAGS := $(pahole-flags-y) diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh deleted file mode 100755 index 728d55190d97..000000000000 --- a/scripts/pahole-flags.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-2.0 - -extra_paholeopt= - -if ! [ -x "$(command -v ${PAHOLE})" ]; then - exit 0 -fi - -pahole_ver=$($(dirname $0)/pahole-version.sh ${PAHOLE}) - -if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then - # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars - extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars" -fi -if [ "${pahole_ver}" -ge "121" ]; then - extra_paholeopt="${extra_paholeopt} --btf_gen_floats" -fi -if [ "${pahole_ver}" -ge "122" ]; then - extra_paholeopt="${extra_paholeopt} -j" -fi -if [ "${pahole_ver}" -ge "124" ]; then - # see PAHOLE_HAS_LANG_EXCLUDE - extra_paholeopt="${extra_paholeopt} --lang_exclude=rust" -fi -if [ "${pahole_ver}" -ge "125" ]; then - extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_inconsistent_proto --btf_gen_optimized" -fi - -echo ${extra_paholeopt} From patchwork Tue Oct 17 10:37:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13424983 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 1175BCDB474 for ; Tue, 17 Oct 2023 10:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343686AbjJQKiS (ORCPT ); Tue, 17 Oct 2023 06:38:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343548AbjJQKiS (ORCPT ); Tue, 17 Oct 2023 06:38:18 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 849AAA2; Tue, 17 Oct 2023 03:38:16 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23DDCC433C8; Tue, 17 Oct 2023 10:38:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697539096; bh=waFeOWzoowEXA/GGZGLjVsE0MWpxTTUslAmqc2q+E5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=USa0Dj7IBbk3ONmbe6o+cZSZlTH0OD99mqtxWorNSzHyZZzpt1oTDK7PtaXoILlBh 4QXfEPc9h6tLJHHOtLmZPJt/+Q7eEOpe5eUJfaHRdzAIEO1okzvPitXyHR+ZBqB6c5 AmjlW/jjH2V1D5CVgt938CcUGJNb+ImtWyotSjKl1+uSYi97C25PRlSHYEJnt10Aya mpzBko3H4mtuqni0/otbiZul77lDtDvt3ZAdKWKk9pRmI5p4K/HbOlyK4DoLIPsncu pHdjm6Tq/aSI6VL31dh4bYOES1mrs6WwX1nHNEoTpuUjfOh72nczyNWgBaSJphi8s6 c98gpJG0vV4dg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 3/4] kbuild: skip module BTF with one-time check for vmlinux Date: Tue, 17 Oct 2023 19:37:41 +0900 Message-Id: <20231017103742.130927-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231017103742.130927-1-masahiroy@kernel.org> References: <20231017103742.130927-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org When CONFIG_DEBUG_INFO_BTF_MODULES is enabled, vmlinux presence is checked in every module build, resulting in repetitive warning messages if vmlinux is missing. Check vmlinux and print a warning just once. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- scripts/Makefile.modfinal | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 8568d256d6fb..9fd7a26e4fe9 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -14,6 +14,15 @@ include $(srctree)/scripts/Makefile.lib # find all modules listed in modules.order modules := $(call read-file, $(MODORDER)) +vmlinux := + +ifdef CONFIG_DEBUG_INFO_BTF_MODULES +ifneq ($(wildcard vmlinux),) +vmlinux := vmlinux +else +$(warning Skipping BTF generation due to unavailability of vmlinux) +endif +endif __modfinal: $(modules:%.o=%.ko) @: @@ -36,12 +45,8 @@ quiet_cmd_ld_ko_o = LD [M] $@ quiet_cmd_btf_ko = BTF [M] $@ cmd_btf_ko = \ - if [ ! -f vmlinux ]; then \ - printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \ - else \ LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \ - $(RESOLVE_BTFIDS) -b vmlinux $@; \ - fi; + $(RESOLVE_BTFIDS) -b vmlinux $@ # Same as newer-prereqs, but allows to exclude specified extra dependencies newer_prereqs_except = $(filter-out $(PHONY) $(1),$?) @@ -52,9 +57,9 @@ if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check), \ printf '%s\n' 'savedcmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) # Re-generate module BTFs if either module's .ko or vmlinux changed -%.ko: %.o %.mod.o scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),vmlinux) FORCE +%.ko: %.o %.mod.o scripts/module.lds $(vmlinux) FORCE +$(call if_changed_except,ld_ko_o,vmlinux) -ifdef CONFIG_DEBUG_INFO_BTF_MODULES +ifdef vmlinux +$(if $(newer-prereqs),$(call cmd,btf_ko)) endif From patchwork Tue Oct 17 10:37:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13424984 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 9ACDECDB482 for ; Tue, 17 Oct 2023 10:38:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343696AbjJQKiU (ORCPT ); Tue, 17 Oct 2023 06:38:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343685AbjJQKiT (ORCPT ); Tue, 17 Oct 2023 06:38:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0868BFF; Tue, 17 Oct 2023 03:38:18 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95C7CC433CA; Tue, 17 Oct 2023 10:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697539097; bh=RUBKVlsGzVBXGtjDnQ7Enr6nWmXXOHg87V2AX3JQHyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GBbWpDWRQqxCKAh8ALF7WRA18h7wWeqp0dama8SsxwSVZ0Qata3wtLLrNjItPEsXX uWKKGnMYDHGyiTMthJys+FRlJvBWsTlF/dL3hJC09E6G7N+SiujmzH7JBJoHzDj+Zu DsBpdUomgRKbBrSknU7UNuM91a1oUi/WITbpfoQ5i9uLZRUbub25ILQHLNik1SMY6W ckOp9eVScbOkTqe3MJgfCL9tsuJAZO6sJApVmyNq1/W3gRgBY8sOCsmqfOOSgUUrvk BUvmPH1ko+HOs7YOh9+SDZfst0PBLNNb8ZkjpYO3iGvn9Q95Xg2mUgP4KEs4l+3Gwi 5vPMdu/FLYGfQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 4/4] kbuild: refactor module BTF rule Date: Tue, 17 Oct 2023 19:37:42 +0900 Message-Id: <20231017103742.130927-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231017103742.130927-1-masahiroy@kernel.org> References: <20231017103742.130927-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org newer_prereqs_except and if_changed_except are ugly hacks of the newer_prereqs and if_changed in scripts/Kbuild.include. Remove. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modfinal | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 9fd7a26e4fe9..6ab10dba05c7 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -19,6 +19,9 @@ vmlinux := ifdef CONFIG_DEBUG_INFO_BTF_MODULES ifneq ($(wildcard vmlinux),) vmlinux := vmlinux +cmd_btf = ; \ + LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \ + $(RESOLVE_BTFIDS) -b vmlinux $@ else $(warning Skipping BTF generation due to unavailability of vmlinux) endif @@ -41,27 +44,11 @@ quiet_cmd_ld_ko_o = LD [M] $@ cmd_ld_ko_o += \ $(LD) -r $(KBUILD_LDFLAGS) \ $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ - -T scripts/module.lds -o $@ $(filter %.o, $^) + -T scripts/module.lds -o $@ $(filter %.o, $^) \ + $(cmd_btf) -quiet_cmd_btf_ko = BTF [M] $@ - cmd_btf_ko = \ - LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \ - $(RESOLVE_BTFIDS) -b vmlinux $@ - -# Same as newer-prereqs, but allows to exclude specified extra dependencies -newer_prereqs_except = $(filter-out $(PHONY) $(1),$?) - -# Same as if_changed, but allows to exclude specified extra dependencies -if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check), \ - $(cmd); \ - printf '%s\n' 'savedcmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) - -# Re-generate module BTFs if either module's .ko or vmlinux changed %.ko: %.o %.mod.o scripts/module.lds $(vmlinux) FORCE +$(call if_changed_except,ld_ko_o,vmlinux) -ifdef vmlinux - +$(if $(newer-prereqs),$(call cmd,btf_ko)) -endif targets += $(modules:%.o=%.ko) $(modules:%.o=%.mod.o)