Re: Kernel 5.5.4 build fail for BPF-selftests with latest LLVM

Alexei Starovoitov
2020-02-20T17:26:22Z

On Thu, Feb 20, 2020 at 05:02:25PM +0000, Bird, Tim wrote:
>
>
> > -----Original Message-----
> > From: Jesper Dangaard Brouer
> >
> > On Wed, 19 Feb 2020 17:47:23 -0700
> > shuah <shuah@kernel.org> wrote:
> >
> > > On 2/19/20 5:27 PM, Alexei Starovoitov wrote:
> > > > On Wed, Feb 19, 2020 at 03:59:41PM -0600, Daniel Díaz wrote:
> > > >>>
> > > >>> When I download a specific kernel release, how can I know what LLVM
> > > >>> git-hash or version I need (to use BPF-selftests)?
> > > >
> > > > as discussed we're going to add documentation-like file that will
> > > > list required commits in tools.
> > > > This will be enforced for future llvm/pahole commits.
> > > >
> > > >>> Do you think it is reasonable to require end-users to compile their own
> > > >>> bleeding edge version of LLVM, to use BPF-selftests?
> > > >
> > > > absolutely.
>
> Is it just the BPF-selftests that require the bleeding edge version of LLVM,
> or do BPF features themselves need the latest LLVM. If the latter, then this
> is quite worrisome, and I fear the BPF developers are getting ahead of themselves.
> We don't usually have a kernel dependency on the latest compiler version (some
> recent security fixes are an anomaly). In fact deprecating support for older compiler
> versions has been quite slow and methodical over the years.
>
> It's quite dangerous to be baking stuff into the kernel that depends on features
> from compilers that haven't even made it to release yet.
>
> I'm sorry, but I'm coming into the middle of this thread. Can you please explain
> what the features are in the latest LLVM that are required for BPF-selftests?

Above is correct. bpf kernel features do depend on the latest pahole and llvm
features that did not make it into a release. That was the case for many years
now and still the case. The first commit 8 years ago relied on something that
can generate those instructions. For many years llvm was the only compiler that
could generate them. Right now there is GCC backend as well. New features (like
new instructions) depend on the compiler.

selftests/bpf are not testing kernel's bpf features. They are testing the whole
bpf ecosystem. They test llvm, pahole, libbpf, bpftool, and kernel together.
Hence it's a requirement to install the latest pahole and llvm.

When I'm talking about selftests/bpf I'm talking about all the tests in that
directory combined. There are several unit tests scattered across repos. The
unit tests for llvm bpf backend are inside llvm repo.
selftests/bpf/test_verifier and test_maps are unit tests for the verifier and
for maps. They are llvm independent. They test a combination of kernel and
libbpf only. But majority of the selftests/bpf are done via test_progs which
are the whole ecosystem tests.