All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Quentin Monnet <quentin@isovalent.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next v3 04/10] tools: runqslower: install libbpf headers when building
Date: Wed, 6 Oct 2021 11:20:46 -0700	[thread overview]
Message-ID: <CAEf4Bza4y5DjJfxQYDJEALQh+3SaukPtNJVLaLdMZK-SgpDpyw@mail.gmail.com> (raw)
In-Reply-To: <20211003192208.6297-5-quentin@isovalent.com>

On Sun, Oct 3, 2021 at 12:22 PM Quentin Monnet <quentin@isovalent.com> wrote:
>
> API headers from libbpf should not be accessed directly from the
> library's source directory. Instead, they should be exported with "make
> install_headers". Let's make sure that runqslower installs the
> headers properly when building.
>
> We use a libbpf_hdrs target to mark the logical dependency on libbpf's
> headers export for a number of object files, even though the headers
> should have been exported at this time (since bpftool needs them, and is
> required to generate the skeleton or the vmlinux.h).
>
> When descending from a parent Makefile, the specific output directories
> for building the library and exporting the headers are configurable with
> BPFOBJ_OUTPUT and BPF_DESTDIR, respectively. This is in addition to
> OUTPUT, on top of which those variables are constructed by default.
>
> Also adjust the Makefile for the BPF selftests. We pass a number of
> variables to the "make" invocation, because we want to point runqslower
> to the (target) libbpf shared with other tools, instead of building its
> own version. In addition, runqslower relies on (target) bpftool, and we
> also want to pass the proper variables to its Makefile so that bpftool
> itself reuses the same libbpf.
>
> Signed-off-by: Quentin Monnet <quentin@isovalent.com>
> ---
>  tools/bpf/runqslower/Makefile        | 22 +++++++++++++---------
>  tools/testing/selftests/bpf/Makefile | 15 +++++++++------
>  2 files changed, 22 insertions(+), 15 deletions(-)
>
> diff --git a/tools/bpf/runqslower/Makefile b/tools/bpf/runqslower/Makefile
> index 3818ec511fd2..049aef7e9a4c 100644
> --- a/tools/bpf/runqslower/Makefile
> +++ b/tools/bpf/runqslower/Makefile
> @@ -9,9 +9,9 @@ BPFTOOL ?= $(DEFAULT_BPFTOOL)
>  LIBBPF_SRC := $(abspath ../../lib/bpf)
>  BPFOBJ_OUTPUT := $(OUTPUT)libbpf/
>  BPFOBJ := $(BPFOBJ_OUTPUT)libbpf.a
> -BPF_INCLUDE := $(BPFOBJ_OUTPUT)
> -INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../lib)        \
> -       -I$(abspath ../../include/uapi)
> +BPF_DESTDIR := $(BPFOBJ_OUTPUT)
> +BPF_INCLUDE := $(BPF_DESTDIR)/include
> +INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../include/uapi)
>  CFLAGS := -g -Wall
>
>  # Try to detect best kernel BTF source
> @@ -33,7 +33,7 @@ endif
>
>  .DELETE_ON_ERROR:
>
> -.PHONY: all clean runqslower
> +.PHONY: all clean runqslower libbpf_hdrs
>  all: runqslower
>
>  runqslower: $(OUTPUT)/runqslower
> @@ -46,13 +46,15 @@ clean:
>         $(Q)$(RM) $(OUTPUT)runqslower
>         $(Q)$(RM) -r .output
>
> +libbpf_hdrs: $(BPFOBJ)
> +
>  $(OUTPUT)/runqslower: $(OUTPUT)/runqslower.o $(BPFOBJ)
>         $(QUIET_LINK)$(CC) $(CFLAGS) $^ -lelf -lz -o $@
>
>  $(OUTPUT)/runqslower.o: runqslower.h $(OUTPUT)/runqslower.skel.h             \
> -                       $(OUTPUT)/runqslower.bpf.o
> +                       $(OUTPUT)/runqslower.bpf.o libbpf_hdrs

this phony dependency will cause runqslower.o to be always rebuilt,
try running make multiple times with no changes inside
tools/bpf/runqslower. Can this be done just as an order-only
dependency?

>
> -$(OUTPUT)/runqslower.bpf.o: $(OUTPUT)/vmlinux.h runqslower.h
> +$(OUTPUT)/runqslower.bpf.o: $(OUTPUT)/vmlinux.h runqslower.h libbpf_hdrs
>
>  $(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(BPFTOOL)
>         $(QUIET_GEN)$(BPFTOOL) gen skeleton $< > $@

[...]

  reply	other threads:[~2021-10-06 18:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-03 19:21 [PATCH bpf-next v3 00/10] install libbpf headers when using the library Quentin Monnet
2021-10-03 19:21 ` [PATCH bpf-next v3 01/10] tools: bpftool: remove unused includes to <bpf/bpf_gen_internal.h> Quentin Monnet
2021-10-03 19:22 ` [PATCH bpf-next v3 02/10] tools: bpftool: install libbpf headers instead of including the dir Quentin Monnet
2021-10-03 19:22 ` [PATCH bpf-next v3 03/10] tools: resolve_btfids: install libbpf headers when building Quentin Monnet
2021-10-03 19:22 ` [PATCH bpf-next v3 04/10] tools: runqslower: " Quentin Monnet
2021-10-06 18:20   ` Andrii Nakryiko [this message]
2021-10-03 19:22 ` [PATCH bpf-next v3 05/10] bpf: preload: " Quentin Monnet
2021-10-06 18:21   ` Andrii Nakryiko
2021-10-03 19:22 ` [PATCH bpf-next v3 06/10] bpf: iterators: " Quentin Monnet
2021-10-03 19:22 ` [PATCH bpf-next v3 07/10] samples/bpf: " Quentin Monnet
2021-10-06 18:23   ` Andrii Nakryiko
2021-10-03 19:22 ` [PATCH bpf-next v3 08/10] samples/bpf: update .gitignore Quentin Monnet
2021-10-06 18:24   ` Andrii Nakryiko
2021-10-06 18:25     ` Andrii Nakryiko
2021-10-03 19:22 ` [PATCH bpf-next v3 09/10] selftests/bpf: better clean up for runqslower in test_bpftool_build.sh Quentin Monnet
2021-10-03 19:22 ` [PATCH bpf-next v3 10/10] tools: bpftool: add install-bin target to install binary only Quentin Monnet
2021-10-06 18:28 ` [PATCH bpf-next v3 00/10] install libbpf headers when using the library Andrii Nakryiko
2021-10-07 19:43   ` Quentin Monnet
2021-10-07 21:24     ` Andrii Nakryiko

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=CAEf4Bza4y5DjJfxQYDJEALQh+3SaukPtNJVLaLdMZK-SgpDpyw@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=quentin@isovalent.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.