BPF List
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: Alexey Gladkov <legion@kernel.org>,
	linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
	linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH v3] bpf: Remove custom build rule
Date: Thu, 29 Aug 2024 11:12:46 +0100	[thread overview]
Message-ID: <235234d8-a223-4170-876a-6ccbf552c09c@oracle.com> (raw)
In-Reply-To: <20240828181028.4166334-1-legion@kernel.org>

On 28/08/2024 19:10, Alexey Gladkov wrote:
> According to the documentation, when building a kernel with the C=2
> parameter, all source files should be checked. But this does not happen
> for the kernel/bpf/ directory.
> 
> $ touch kernel/bpf/core.c
> $ make C=2 CHECK=true kernel/bpf/core.o
> 
> Outputs:
> 
>   CHECK   scripts/mod/empty.c
>   CALL    scripts/checksyscalls.sh
>   DESCEND objtool
>   INSTALL libsubcmd_headers
>   CC      kernel/bpf/core.o
> 
> As can be seen the compilation is done, but CHECK is not executed. This
> happens because kernel/bpf/Makefile has defined its own rule for
> compilation and forgotten the macro that does the check.
> 
> There is no need to duplicate the build code, and this rule can be
> removed to use generic rules.
> 
> Signed-off-by: Alexey Gladkov <legion@kernel.org>

Tested-by: Alan Maguire <alan.maguire@oracle.com>

The aim from the BPF side is just to share the btf_iter.c,
btf_relocate.c and relo_core.c files for both libbpf and kernel build.
Those files need to live in tools/lib/bpf because the libbpf standalone
repo on github is built from tools/lib/bpf.

Since the approach in this patch continues to support that while it
doesn't break other things like check targets it's definitely preferred.

Thanks for the fix!

Alan

> ---
>  kernel/bpf/Makefile       | 6 ------
>  kernel/bpf/btf_iter.c     | 2 ++
>  kernel/bpf/btf_relocate.c | 2 ++
>  kernel/bpf/relo_core.c    | 2 ++
>  4 files changed, 6 insertions(+), 6 deletions(-)
>  create mode 100644 kernel/bpf/btf_iter.c
>  create mode 100644 kernel/bpf/btf_relocate.c
>  create mode 100644 kernel/bpf/relo_core.c
> 
> diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
> index 0291eef9ce92..9b9c151b5c82 100644
> --- a/kernel/bpf/Makefile
> +++ b/kernel/bpf/Makefile
> @@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/
>  obj-$(CONFIG_BPF_SYSCALL) += relo_core.o
>  obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o
>  obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o
> -
> -# Some source files are common to libbpf.
> -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf
> -
> -$(obj)/%.o: %.c FORCE
> -	$(call if_changed_rule,cc_o_c)
> diff --git a/kernel/bpf/btf_iter.c b/kernel/bpf/btf_iter.c
> new file mode 100644
> index 000000000000..eab8493a1669
> --- /dev/null
> +++ b/kernel/bpf/btf_iter.c
> @@ -0,0 +1,2 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include "../../tools/lib/bpf/btf_iter.c"
> diff --git a/kernel/bpf/btf_relocate.c b/kernel/bpf/btf_relocate.c
> new file mode 100644
> index 000000000000..8c89c7b59ef8
> --- /dev/null
> +++ b/kernel/bpf/btf_relocate.c
> @@ -0,0 +1,2 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include "../../tools/lib/bpf/btf_relocate.c"
> diff --git a/kernel/bpf/relo_core.c b/kernel/bpf/relo_core.c
> new file mode 100644
> index 000000000000..6a36fbc0e5ab
> --- /dev/null
> +++ b/kernel/bpf/relo_core.c
> @@ -0,0 +1,2 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +#include "../../tools/lib/bpf/relo_core.c"

  parent reply	other threads:[~2024-08-29 10:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28 15:25 [PATCH v1] bpf: Add missing force_checksrc macro Alexey Gladkov
2024-08-28 16:32 ` Masahiro Yamada
2024-08-28 17:06   ` [PATCH v2] bpf: Remove custom build rule Alexey Gladkov
2024-08-28 17:22     ` Masahiro Yamada
2024-08-28 17:49       ` Alexey Gladkov
2024-08-28 18:10       ` [PATCH v3] " Alexey Gladkov
2024-08-28 18:32         ` Masahiro Yamada
2024-08-28 19:14         ` Oleg Nesterov
2024-08-29 10:12         ` Alan Maguire [this message]
2024-08-29 19:24         ` Alexei Starovoitov
2024-08-30  7:43           ` [PATCH v4] " Alexey Gladkov
2024-08-30 16:00             ` patchwork-bot+netdevbpf

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=235234d8-a223-4170-876a-6ccbf552c09c@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=legion@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=oleg@redhat.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