Message ID | 20200312105335.10465-1-tklauser@distanz.ch |
---|---|
State | Changes Requested |
Delegated to: | BPF Maintainers |
Headers | show |
Series | bpftool: use linux/types.h from source tree for profiler build | expand |
2020-03-12 11:53 UTC+0100 ~ Tobias Klauser <tklauser@distanz.ch> > 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 undef __bitwise in skeleton/profiler.h avoid > clashing with the empty 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> > Signed-off-by: Tobias Klauser <tklauser@distanz.ch> > diff --git a/tools/bpf/bpftool/skeleton/profiler.h b/tools/bpf/bpftool/skeleton/profiler.h > index e03b53eae767..95358c0df5ef 100644 > --- a/tools/bpf/bpftool/skeleton/profiler.h > +++ b/tools/bpf/bpftool/skeleton/profiler.h > @@ -27,6 +27,7 @@ enum { > true = 1, > }; > > +#undef __bitwise > #ifdef __CHECKER__ > #define __bitwise__ __attribute__((bitwise)) > #else > Even with the #undef above, I get warnings on __bitwise being redefined in tools/testing/selftests/bpf/include/uapi/linux/types.h. Can we maybe just find another name (or number of underscores) for the macro in skeleton/profiler.h? Makefile change works well otherwise, thanks (tested on Ubuntu with and without gcc-multilib). Quentin
On 2020-03-12 at 13:48:21 +0100, Quentin Monnet <quentin@isovalent.com> wrote: > 2020-03-12 11:53 UTC+0100 ~ Tobias Klauser <tklauser@distanz.ch> > > 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 undef __bitwise in skeleton/profiler.h avoid > > clashing with the empty 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> > > Signed-off-by: Tobias Klauser <tklauser@distanz.ch> > > > diff --git a/tools/bpf/bpftool/skeleton/profiler.h b/tools/bpf/bpftool/skeleton/profiler.h > > index e03b53eae767..95358c0df5ef 100644 > > --- a/tools/bpf/bpftool/skeleton/profiler.h > > +++ b/tools/bpf/bpftool/skeleton/profiler.h > > @@ -27,6 +27,7 @@ enum { > > true = 1, > > }; > > > > +#undef __bitwise > > #ifdef __CHECKER__ > > #define __bitwise__ __attribute__((bitwise)) > > #else > > > > Even with the #undef above, I get warnings on __bitwise being redefined > in tools/testing/selftests/bpf/include/uapi/linux/types.h. Can we maybe > just find another name (or number of underscores) for the macro in > skeleton/profiler.h? Good point. It seems I actually didn't test this properly. Will change the typedefs to use the existing __bitwise__. > Makefile change works well otherwise, thanks (tested on Ubuntu with and > without gcc-multilib). Thanks for testing. - Tobias
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 \ + -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..95358c0df5ef 100644 --- a/tools/bpf/bpftool/skeleton/profiler.h +++ b/tools/bpf/bpftool/skeleton/profiler.h @@ -27,6 +27,7 @@ enum { true = 1, }; +#undef __bitwise #ifdef __CHECKER__ #define __bitwise__ __attribute__((bitwise)) #else
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 undef __bitwise in skeleton/profiler.h avoid clashing with the empty 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> Signed-off-by: Tobias Klauser <tklauser@distanz.ch> --- tools/bpf/bpftool/Makefile | 5 ++++- tools/bpf/bpftool/skeleton/profiler.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)