bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Masahiro Yamada <masahiroy@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Michal Marek <michal.lkml@markovi.net>
Cc: Leon Romanovsky <leonro@nvidia.com>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	Edward Srouji <edwards@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	bpf@vger.kernel.org, kernel-team@fb.com, netdev@vger.kernel.org
Subject: [PATCH bpf-next] kbuild: Restore ability to build out-of-tree modules
Date: Tue,  1 Dec 2020 16:37:00 +0200	[thread overview]
Message-ID: <20201201143700.719828-1-leon@kernel.org> (raw)

From: Leon Romanovsky <leonro@nvidia.com>

The out-of-tree modules are built without vmlinux target and request
to recompile that target unconditionally causes to the following
compilation error.

[root@server kernel]# make
<..>
make -f ./scripts/Makefile.modpost
make -f ./scripts/Makefile.modfinal
make[3]: *** No rule to make target 'vmlinux', needed by '/my_temp/out-of-tree-module/kernel/test.ko'.  Stop.
make[2]: *** [scripts/Makefile.modpost:117: __modpost] Error 2
make[1]: *** [Makefile:1703: modules] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.10.0-rc5_for_upstream_base_2020_11_29_11_34'
make: *** [Makefile:80: modules] Error 2

As a solution separate between build paths that has vmlinux target and paths without.

Fixes: 5f9ae91f7c0d ("kbuild: Build kernel module BTFs if BTF is enabled and pahole supports it")
Reported-by: Edward Srouji <edwards@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
Not proficient enough in Makefile, but it fixes the issue.
---
 scripts/Makefile.modfinal | 5 +++++
 scripts/Makefile.modpost  | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal
index 02b892421f7a..8a7d0604e7d0 100644
--- a/scripts/Makefile.modfinal
+++ b/scripts/Makefile.modfinal
@@ -48,9 +48,14 @@ if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check),      \
 	$(cmd);                                                              \
 	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)

+ifdef MODPOST_VMLINUX
 # Re-generate module BTFs if either module's .ko or vmlinux changed
 $(modules): %.ko: %.o %.mod.o scripts/module.lds vmlinux FORCE
 	+$(call if_changed_except,ld_ko_o,vmlinux)
+else
+$(modules): %.ko: %.o %.mod.o scripts/module.lds FORCE
+	+$(call if_changed_except,ld_ko_o)
+endif
 ifdef CONFIG_DEBUG_INFO_BTF_MODULES
 	+$(if $(newer-prereqs),$(call cmd,btf_ko))
 endif
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index f54b6ac37ac2..f5aa5b422ad7 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -114,8 +114,12 @@ targets += $(output-symdump)

 __modpost: $(output-symdump)
 ifneq ($(KBUILD_MODPOST_NOFINAL),1)
+ifdef MODPOST_VMLINUX
+	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal MODPOST_VMLINUX=1
+else
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
 endif
+endif

 PHONY += FORCE
 FORCE:
--
2.28.0


             reply	other threads:[~2020-12-01 14:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01 14:37 Leon Romanovsky [this message]
2020-12-01 18:01 ` [PATCH bpf-next] kbuild: Restore ability to build out-of-tree modules Andrii Nakryiko
2020-12-01 19:32   ` Leon Romanovsky
2020-12-01 21:44     ` Andrii Nakryiko
2020-12-02  6:07       ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201201143700.719828-1-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=edwards@nvidia.com \
    --cc=kernel-team@fb.com \
    --cc=leonro@nvidia.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).