bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tobias Klauser <tklauser@distanz.ch>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
Subject: Re: [PATCH bpf-next v2] bpftool: fix profiler build on systems without /usr/include/asm symlink
Date: Wed, 11 Mar 2020 20:42:43 +0100	[thread overview]
Message-ID: <20200311194242.htdih4w4ld4tgk5x@distanz.ch> (raw)
In-Reply-To: <20200311172650.r3gfkqbyftc32iax@ast-mbp.dhcp.thefacebook.com>

On 2020-03-11 at 18:26:50 +0100, Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote:
> On Wed, Mar 11, 2020 at 05:14:59PM +0100, Tobias Klauser 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.
> I think the issue is different.
> profiler.bpf.c should have picked up
> tools/include/uapi/linux/bpf.h (instead of global from /usr/inclde)
> which should have included
> tools/include/linux/types.h (instead of /usr/include/linux/types.h)
> we also have a workaround for some cases:
> ./tools/testing/selftests/bpf/include/uapi/linux/types.h

I just tried that. Unfortunately, this will pull in stdbool.h, stddef.h
and stdint.h libc header (via either linux/types.h header). This will
again require the libc6-dev-i386 package when building for the bpf
target. This is exactly the dependency that we'd like to avoid in
Cilium, also see https://github.com/cilium/cilium/pull/10204

I agree that we ideally shouldn't pull in the headers from the system,
but currently I don't see a way of doing that without still depending on
libc headers. Suggestions welcome...

> >   make: *** [Makefile:123: skeleton/profiler.bpf.o] Error 1
> > 
> > In certain cases (e.g. for container builds), installing gcc-multilib
> > and all its dependencies - which are otherwise not needed to build
> > bpftool - unnecessarily increases the image size.
> > 
> > Thus, fix this by adding /usr/include/$(uname -m)-linux-gnu to the
> > clang search path so <asm/types.h> can be found.
> In general perf builds fine on all sorts of distros and configs.
> I think bpftool should use the same includes from tools/
> and skeleton too.

I'll check how perf builds do it but I suspect they will also depend on
libc headers. This is fine for userspace tools, but we'd like to avoid
it for bpf programs.

- Tobias

  reply	other threads:[~2020-03-11 19:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 12:34 [PATCH] bpftool: fix iprofiler build on systems without /usr/include/asm symlink Tobias Klauser
2020-03-11 12:49 ` Toke Høiland-Jørgensen
2020-03-11 12:53   ` Tobias Klauser
2020-03-11 14:24     ` Toke Høiland-Jørgensen
2020-03-11 15:00       ` Tobias Klauser
2020-03-11 15:55 ` Song Liu
2020-03-11 16:06   ` Tobias Klauser
2020-03-11 16:14 ` [PATCH bpf-next v2] bpftool: fix profiler " Tobias Klauser
2020-03-11 17:26   ` Alexei Starovoitov
2020-03-11 19:42     ` Tobias Klauser [this message]
2020-03-12 10:30     ` Tobias Klauser

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:

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

  git send-email \
    --in-reply-to=20200311194242.htdih4w4ld4tgk5x@distanz.ch \
    --to=tklauser@distanz.ch \
    --cc=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \


* 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).