BPF: How can I enable BPF support in my LLVM toolchain?

Hi,

when building a Linux-kernel with CONFIG_DEBUG_INFO_BTF=y my build breaks.

This is because my selfmade LLVM toolchain v11.0.1 has no BPF support:

$ llc --version
LLVM (http://llvm.org/):
LLVM version 11.0.1
Optimized build.
Default target: x86_64-unknown-linux-gnu
Host CPU: sandybridge

Registered Targets:
   x86 - 32-bit X86: Pentium-Pro and above
   x86-64 - 64-bit X86: EM64T and AMD64

What system or binary requirements do I need and which CMAKE option(s)
need(s) to be set?
I hope this is not hardware-dependent (here: Intel SandyBridge).

Thanks in advance.

Regards,
- Sedat -

[1] https://github.com/ClangBuiltLinux/tc-build/issues/129

Hi,

when building a Linux-kernel with CONFIG_DEBUG_INFO_BTF=y my build breaks.

I commented on the GitHub issue about the root cause of this.

This is because my selfmade LLVM toolchain v11.0.1 has no BPF support:

$ llc --version
LLVM (http://llvm.org/):
  LLVM version 11.0.1
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: sandybridge

  Registered Targets:
    x86 - 32-bit X86: Pentium-Pro and above
    x86-64 - 64-bit X86: EM64T and AMD64

What system or binary requirements do I need and which CMAKE option(s)
need(s) to be set?

The LLVM_TARGETS_TO_BUILD CMake option controls which targets to build.

-Tom

> Hi,
>
> when building a Linux-kernel with CONFIG_DEBUG_INFO_BTF=y my build breaks.
>

I commented on the GitHub issue about the root cause of this.

> This is because my selfmade LLVM toolchain v11.0.1 has no BPF support:
>
> $ llc --version
> LLVM (http://llvm.org/):
> LLVM version 11.0.1
> Optimized build.
> Default target: x86_64-unknown-linux-gnu
> Host CPU: sandybridge
>
> Registered Targets:
> x86 - 32-bit X86: Pentium-Pro and above
> x86-64 - 64-bit X86: EM64T and AMD64
>
> What system or binary requirements do I need and which CMAKE option(s)
> need(s) to be set?

The LLVM_TARGETS_TO_BUILD CMake option controls which targets to build.

tc-build folks fixed that up.
See commit "build-llvm.py: Enable BPF backend by default".

Is there a BPF test-suite - like for clang and lld?

I have build pahole from Git - now building a new Linux kernel.

$ cd /path/to/pahole/git
$ git describe
v1.19-7-gb688e3597060

Will report later.

Regards,
- Sedat -

[1] https://github.com/ClangBuiltLinux/tc-build/commit/e796c046428a971404eec008c841f9dd7c1621e8

Hi,

when building a Linux-kernel with CONFIG_DEBUG_INFO_BTF=y my build breaks.

I commented on the GitHub issue about the root cause of this.

This is because my selfmade LLVM toolchain v11.0.1 has no BPF support:

$ llc --version
LLVM (http://llvm.org/):
   LLVM version 11.0.1
   Optimized build.
   Default target: x86_64-unknown-linux-gnu
   Host CPU: sandybridge

   Registered Targets:
     x86 - 32-bit X86: Pentium-Pro and above
     x86-64 - 64-bit X86: EM64T and AMD64

What system or binary requirements do I need and which CMAKE option(s)
need(s) to be set?

The LLVM_TARGETS_TO_BUILD CMake option controls which targets to build.

tc-build folks fixed that up.
See commit "build-llvm.py: Enable BPF backend by default".

Is there a BPF test-suite - like for clang and lld?

There's one in the kernel.

-Tom

>>
>>> Hi,
>>>
>>> when building a Linux-kernel with CONFIG_DEBUG_INFO_BTF=y my build breaks.
>>>
>>
>> I commented on the GitHub issue about the root cause of this.
>>
>>> This is because my selfmade LLVM toolchain v11.0.1 has no BPF support:
>>>
>>> $ llc --version
>>> LLVM (http://llvm.org/):
>>> LLVM version 11.0.1
>>> Optimized build.
>>> Default target: x86_64-unknown-linux-gnu
>>> Host CPU: sandybridge
>>>
>>> Registered Targets:
>>> x86 - 32-bit X86: Pentium-Pro and above
>>> x86-64 - 64-bit X86: EM64T and AMD64
>>>
>>> What system or binary requirements do I need and which CMAKE option(s)
>>> need(s) to be set?
>>
>> The LLVM_TARGETS_TO_BUILD CMake option controls which targets to build.
>>
>
> tc-build folks fixed that up.
> See commit "build-llvm.py: Enable BPF backend by default".
>
> Is there a BPF test-suite - like for clang and lld?
>

There's one in the kernel.

Can I run it before compiling a single-line of a Linux-kernel?
Does it test for BTF stuff?
How do I run it?

- Sedat -

Hi,

when building a Linux-kernel with CONFIG_DEBUG_INFO_BTF=y my build breaks.

I commented on the GitHub issue about the root cause of this.

This is because my selfmade LLVM toolchain v11.0.1 has no BPF support:

$ llc --version
LLVM (http://llvm.org/):
    LLVM version 11.0.1
    Optimized build.
    Default target: x86_64-unknown-linux-gnu
    Host CPU: sandybridge

    Registered Targets:
      x86 - 32-bit X86: Pentium-Pro and above
      x86-64 - 64-bit X86: EM64T and AMD64

What system or binary requirements do I need and which CMAKE option(s)
need(s) to be set?

The LLVM_TARGETS_TO_BUILD CMake option controls which targets to build.

tc-build folks fixed that up.
See commit "build-llvm.py: Enable BPF backend by default".

Is there a BPF test-suite - like for clang and lld?

There's one in the kernel.

Can I run it before compiling a single-line of a Linux-kernel?
Does it test for BTF stuff?

I don't know the answers to these questions.

How do I run it?

You can run it with:
make -C tools/testing/selftests/bpf

-Tom