Re: Check pahole availibity and BPF support of toolchain before starting a Linux kernel build

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 1/11/21 1:30 PM, Sedat Dilek wrote:
On Mon, Jan 11, 2021 at 10:03 PM Andrii Nakryiko
<andrii.nakryiko@xxxxxxxxx> wrote:

On Mon, Jan 11, 2021 at 9:56 AM Sedat Dilek <sedat.dilek@xxxxxxxxx> wrote:

On Mon, Jan 11, 2021 at 5:05 PM Yonghong Song <yhs@xxxxxx> wrote:



On 1/11/21 4:48 AM, Sedat Dilek wrote:
Hi BPF maintainers and Mashiro,

Debian started to use CONFIG_DEBUG_INFO_BTF=y.

My kernel-build fails like this:

+ info BTFIDS vmlinux
+ [  != silent_ ]
+ printf   %-7s %s\n BTFIDS vmlinux
   BTFIDS  vmlinux
+ ./tools/bpf/resolve_btfids/resolve_btfids vmlinux
FAILED: load BTF from vmlinux: Invalid argument

The root cause is my selfmade LLVM toolchain has no BPF support.

linux build should depend on LLVM toolchain unless you use LLVM to build
kernel.


$ which llc
/home/dileks/src/llvm-toolchain/install/bin/llc

$ 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

Debian's llc-11 shows me BPF support is built-in.

I see the breakag approx. 3 hours after the start of my kernel-build -
in the stage "vmlinux".
After 2 faulures in my build (2x 3 hours of build-time) I have still
no finished Linux v5.11-rc3 kernel.
This is a bit frustrating.

You mean "BTFIDS  vmlinux" takes more than 3 hours here?
Maybe a bug in resolve_btfids due to somehow different ELF format
resolve_btfids need to handle?


[ CC Tom ]

OMG no.

3 hours up to running scripts/link-vmlinux.sh.

In the meantime I have built a LLVM toolchain with 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:
    bpf    - BPF (host endian)
    bpfeb  - BPF (big endian)
    bpfel  - BPF (little endian)

As Yonghong mentioned, you don't need BPF target support in Clang to
build the kernel, so the issue is elsewhere. It's somewhere between
generated DWARF (we've seen multiple bugs in DWARF over time),
pahole's BTF output and resolve_btfids's handling of that BTF. I've
CC'ed Jiri, who can help with resolve_btfids.

Meanwhile, if you can provide SHA from which you built Clang, kernel
config you used, and probably exact invocation of the build you used,
it would help reproduce the issue.


OK, I see I have here DWARF v5 support patchset applied and enabled.

Furthermore: I applied latest clang-cfi.

This is with LLVM v11.0.1 final aka 43ff75f2c3feef64f9d73328230d34dac8832a91.

Did you use llvm to compile kernel? If this is the case, latest pahole will segfault. I am using latest trunk llvm. It is possible that generated dwarf with llvm is different from generated dwarf with gcc
and pahole did not process it correctly. I did not get time to
debug this though.


My kernel-config is attached.

[1] https://patchwork.kernel.org/project/linux-kbuild/patch/20201204011129.2493105-1-ndesaulniers@xxxxxxxxxx/
[2] https://patchwork.kernel.org/project/linux-kbuild/patch/20201204011129.2493105-2-ndesaulniers@xxxxxxxxxx/
[3] https://github.com/samitolvanen/linux/commits/clang-cfi

    x86    - 32-bit X86: Pentium-43ff75f2c3feef64f9d73328230d34dac8832a91
Pro and above
    x86-64 - 64-bit X86: EM64T and AMD64

Tom reported BTF issues with pahole v1.19 (see [2] and [3]):
"I ran into this same bug trying to build the Fedora kBROKEN_5-11-rc3-CONFIG_DEBUG_INFO_BTF-y-FAILED-load-BTF-from-vmlinux.txt
ernel. The
problem is that pahole segfaults at: scripts/link-vmlinux.sh:131. This
looks to me like a bug in pahole."

pahole ToT (post v1.19) offers some BTF fixes - I have manually build
and use it.

Building a new Linux-kernel...

- Sedat -

[1] https://git.kernel.org/pub/scm/devel/pahole/pahole.git/
[2] https://github.com/ClangBuiltLinux/tc-build/issues/129#issuecomment-758026878
[3] https://github.com/ClangBuiltLinux/tc-build/issues/129#issuecomment-758056553

There are no significant bug fixes between pahole 1.19 and master that
would solve this problem, so let's try to repro this.


You are right pahole fom latest Git does not solve the issue.

+ info BTFIDS vmlinux
+ [  != silent_ ]
+ printf   %-7s %s\n BTFIDS vmlinux
  BTFIDS  vmlinux
+ ./tools/bpf/resolve_btfids/resolve_btfids vmlinux
FAILED: load BTF from vmlinux: Invalid argument

- Sedat -





What about doing pre-checks - means before doing a single line of
compilation - to check for:
1. Required binaries
2. Required support of whatever feature in compiler, linker, toolchain etc.

Recently, I fell over depmod binary not found in my PATH - in one of
the last steps (modfinal) of the kernel build.

Any ideas to improve the situation?
( ...and please no RTFM, see links below. )

Thanks.

Regards,
- Sedat -


[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/link-vmlinux.sh#n144
[1] https://salsa.debian.org/kernel-team/linux/-/commit/929891281c61ce4403ddd869664c949692644a2f
[2] https://www.kernel.org/doc/html/latest/bpf/bpf_devel_QA.html?highlight=pahole#llvm
[3] https://www.kernel.org/doc/html/latest/bpf/btf.html?highlight=pahole#btf-generation




[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux