From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Tobias Klauser <tklauser@distanz.ch>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
Alexei Starovoitov <ast@kernel.org>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
bpf <bpf@vger.kernel.org>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Quentin Monnet <quentin@isovalent.com>
Subject: Re: [PATCH bpf-next v2] bpftool: use linux/types.h from source tree for profiler build
Date: Thu, 12 Mar 2020 10:59:55 -0700 [thread overview]
Message-ID: <CAEf4BzakzbN4+PVa4TFsOhH=Pnt_4mhPknH74kwsRkOApkKhOg@mail.gmail.com> (raw)
In-Reply-To: <20200312130330.32239-1-tklauser@distanz.ch>
On Thu, Mar 12, 2020 at 6:04 AM Tobias Klauser <tklauser@distanz.ch> wrote:
>
> When compiling bpftool on a system where the /usr/include/asm symlink
> doesn't exist (e.g. on an Ubuntu system without gcc-multilib installed),
> the build fails with:
>
> CLANG skeleton/profiler.bpf.o
> In file included from skeleton/profiler.bpf.c:4:
> In file included from /usr/include/linux/bpf.h:11:
> /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found
> #include <asm/types.h>
> ^~~~~~~~~~~~~
> 1 error generated.
> make: *** [Makefile:123: skeleton/profiler.bpf.o] Error 1
>
> This indicates that the build is using linux/types.h from system headers
> instead of source tree headers.
>
> To fix this, adjust the clang search path to include the necessary
> headers from tools/testing/selftests/bpf/include/uapi and
> tools/include/uapi. Also use __bitwise__ instead of __bitwise in
> skeleton/profiler.h to avoid clashing with the definition in
> tools/testing/selftests/bpf/include/uapi/linux/types.h.
>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Song Liu <songliubraving@fb.com>
> Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
> Cc: Quentin Monnet <quentin@isovalent.com>
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> ---
> tools/bpf/bpftool/Makefile | 5 ++++-
> tools/bpf/bpftool/skeleton/profiler.h | 17 ++++++++---------
> 2 files changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> index 20a90d8450f8..f294f6c1e795 100644
> --- a/tools/bpf/bpftool/Makefile
> +++ b/tools/bpf/bpftool/Makefile
> @@ -120,7 +120,10 @@ $(OUTPUT)_bpftool: $(_OBJS) $(LIBBPF)
> $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(_OBJS) $(LIBS)
>
> skeleton/profiler.bpf.o: skeleton/profiler.bpf.c
> - $(QUIET_CLANG)$(CLANG) -I$(srctree)/tools/lib -g -O2 -target bpf -c $< -o $@
> + $(QUIET_CLANG)$(CLANG) \
> + -I$(srctree)/tools/include/uapi/ \
> + -I$(srctree)/tools/testing/selftests/bpf/include/uapi \
Seems like I'm spoiling all the fun today :) But why are we ok with
bpftool build depending on selftests? This just makes it even harder
to have a stand-alone bpftool build eventually (similar to libbpf's
Github).
> + -I$(srctree)/tools/lib -g -O2 -target bpf -c $< -o $@
>
> profiler.skel.h: $(OUTPUT)_bpftool skeleton/profiler.bpf.o
> $(QUIET_GEN)$(OUTPUT)./_bpftool gen skeleton skeleton/profiler.bpf.o > $@
> diff --git a/tools/bpf/bpftool/skeleton/profiler.h b/tools/bpf/bpftool/skeleton/profiler.h
> index e03b53eae767..1f767e9510f7 100644
> --- a/tools/bpf/bpftool/skeleton/profiler.h
> +++ b/tools/bpf/bpftool/skeleton/profiler.h
> @@ -32,16 +32,15 @@ enum {
> #else
> #define __bitwise__
> #endif
> -#define __bitwise __bitwise__
>
> -typedef __u16 __bitwise __le16;
> -typedef __u16 __bitwise __be16;
> -typedef __u32 __bitwise __le32;
> -typedef __u32 __bitwise __be32;
> -typedef __u64 __bitwise __le64;
> -typedef __u64 __bitwise __be64;
> +typedef __u16 __bitwise__ __le16;
> +typedef __u16 __bitwise__ __be16;
> +typedef __u32 __bitwise__ __le32;
> +typedef __u32 __bitwise__ __be32;
> +typedef __u64 __bitwise__ __le64;
> +typedef __u64 __bitwise__ __be64;
>
> -typedef __u16 __bitwise __sum16;
> -typedef __u32 __bitwise __wsum;
> +typedef __u16 __bitwise__ __sum16;
> +typedef __u32 __bitwise__ __wsum;
>
> #endif /* __PROFILER_H */
> --
> 2.25.1
>
next prev parent reply other threads:[~2020-03-12 18:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-12 10:53 [PATCH] bpftool: use linux/types.h from source tree for profiler build Tobias Klauser
2020-03-12 12:48 ` Quentin Monnet
2020-03-12 12:54 ` Tobias Klauser
2020-03-12 13:03 ` [PATCH bpf-next v2] " Tobias Klauser
2020-03-12 14:15 ` Quentin Monnet
2020-03-12 15:38 ` Daniel Borkmann
2020-03-12 17:59 ` Andrii Nakryiko [this message]
2020-03-12 18:38 ` Daniel Borkmann
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='CAEf4BzakzbN4+PVa4TFsOhH=Pnt_4mhPknH74kwsRkOApkKhOg@mail.gmail.com' \
--to=andrii.nakryiko@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=quentin@isovalent.com \
--cc=songliubraving@fb.com \
--cc=tklauser@distanz.ch \
--cc=yhs@fb.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).