From patchwork Wed Oct 18 15:19:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13427221 X-Patchwork-Delegate: bpf@iogearbox.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7692220307 for ; Wed, 18 Oct 2023 15:20:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fTIyxfwr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED347C433CA; Wed, 18 Oct 2023 15:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697642412; bh=64NbOJwL+HDqWyuM6JoXFyBcAlHXP3zz+QUuLv6Cm7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fTIyxfwrpTY5bgbva8rPbkcGlgqoZai0aO3PkJiKLsjwlaQN26q9Yhf7zRd2wjkRW WZduFe/lFbU/q+9u4epT/mVv1LqRuauO0bz5OWF23Kd8JMxngIYbgEwwc+f4kmivhh VJTyepbpLsgfF5FtZVGl8dMHPuvoQ8QD6No7cMYjk689j0+PdrMxAx2gcLvk6LY2TW Ety129FzUIr6FfwD15PVqI3wl9DSL9mvUBfMHnmNmKqGI6SnKNxfdm/eFbapyE1BFX gpiFW89j2Z6bS6GGInAnAKbVxMu33QTPYYdJA91bLmvH3+wqGmgTWgilv6JfdU0Nwc KdvBwAIq+VCYg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , bpf@vger.kernel.org Subject: [bpf-next PATCH v2 4/4] kbuild: refactor module BTF rule Date: Thu, 19 Oct 2023 00:19:50 +0900 Message-Id: <20231018151950.205265-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018151950.205265-1-masahiroy@kernel.org> References: <20231018151950.205265-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net 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 Reviewed-by: Nicolas Schier --- Changes in v2: - Fix if_changed_except to if_changed scripts/Makefile.modfinal | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 9fd7a26e4fe9..fc07854bb7b9 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 + +$(call if_changed,ld_ko_o) targets += $(modules:%.o=%.ko) $(modules:%.o=%.mod.o)