Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for BPF support when CONFIG_DEBUG_INFO_BTF=y #129

Closed
dileks opened this issue Jan 11, 2021 · 18 comments · Fixed by #130
Closed

Option for BPF support when CONFIG_DEBUG_INFO_BTF=y #129

dileks opened this issue Jan 11, 2021 · 18 comments · Fixed by #130

Comments

@dileks
Copy link
Contributor

dileks commented Jan 11, 2021

Debian-kernel team started to set CONFIG_DEBUG_INFO_BTF=y.

First, this needs pahole binary from dwarves package (minimum: v1.16).

$ pahole --version
v1.19

Second, your LLVM toolchain needs BPF support enabled.

My selfmade LLVM toolchain v11.0.1 does not have this:

$ 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 has BPF support:

$ /usr/bin/llc-11 --version | grep -i bpf
   bpf        - BPF (host endian)
   bpfeb      - BPF (big endian)
   bpfel      - BPF (little endian)

Is it possible to have an option to enable BPF support?

Thanks.

[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

@msfjarvis
Copy link
Member

Any issues you see with just having it always enabled instead?

@dileks
Copy link
Contributor Author

dileks commented Jan 11, 2021

It breaks here with CONFIG_DEBUG_INFO_BTF=y:

+ 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

[1] https://lists.debian.org/debian-kernel/2021/01/msg00110.html

@dileks
Copy link
Contributor Author

dileks commented Jan 11, 2021

Just FYI:
I started a thread on BPF and linux-kbuild mailing-ist:
Check pahole availibity and BPF support of toolchain before starting a Linux kernel build

[1] https://lore.kernel.org/bpf/CA+icZUVuk5PVY4_HoCoY2ymd27UjuDi6kcAmFb_3=dqkvOA_Qw@mail.gmail.com/T/#u
[2] https://marc.info/?l=linux-kbuild&m=161036940824132&w=2

@dileks
Copy link
Contributor Author

dileks commented Jan 11, 2021

@msfjarvis

Do you have a quick (and dirty) fix?

@msfjarvis
Copy link
Member

@msfjarvis

Do you have a quick (and dirty) fix?

I do not.

@dileks
Copy link
Contributor Author

dileks commented Jan 11, 2021

[llvm-dev] BPF: How can I enable BPF support in my LLVM toolchain?

[1] https://lists.llvm.org/pipermail/llvm-dev/2021-January/147728.html

@dileks
Copy link
Contributor Author

dileks commented Jan 11, 2021

Add BPF to targets (see -t X86;BPF):

python3 ./build-llvm.py --no-update --build-type Release -p clang;lld -t X86;BPF --clang-vendor dileks -B /home/dileks/src/llvm-toolchain/build -I /home/dileks/src/llvm-toolchain/install --check-targets clang lld --build-stage1-only --install-stage1-only

Logs:

-- Targeting X86
-- Targeting BPF

@dileks
Copy link
Contributor Author

dileks commented Jan 11, 2021

It might be enough to add a hint to targets option in case of BPF?

@tstellar
Copy link

I ran into this same bug trying to build the Fedora kernel. The problem is that pahole segfaults at: scripts/link-vmlinux.sh:131. This looks to me like a bug in pahole.

@dileks
Copy link
Contributor Author

dileks commented Jan 11, 2021

@tstellar

Which version of pahole do you use?

@dileks
Copy link
Contributor Author

dileks commented Jan 11, 2021

BPF support looks good:

$ ./build/stage1/bin/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)
    x86    - 32-bit X86: Pentium-Pro and above
    x86-64 - 64-bit X86: EM64T and AMD64

@tstellar
Copy link

@tstellar

Which version of pahole do you use?

@dileks 1.19. This build: https://koji.fedoraproject.org/koji/buildinfo?buildID=1644955

@dileks
Copy link
Contributor Author

dileks commented Jan 11, 2021

@tstellar

Upstream Git pahole has btf_encoder fixes - post v1.19.

[1] https://git.kernel.org/pub/scm/devel/pahole/pahole.git/

nathanchance added a commit to nathanchance/tc-build that referenced this issue Jan 11, 2021
This is needed for CONFIG_DEBUG_INFO_BTF, which is becoming increasingly
more common. Add it to the list of targets that are enabled by default
so that it can be used without any issues.

Closes: ClangBuiltLinux#129
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
nathanchance added a commit to nathanchance/tc-build that referenced this issue Jan 11, 2021
This is needed for CONFIG_DEBUG_INFO_BTF, which is becoming increasingly
more common. Add it to the list of targets that are enabled by default
so that it can be used without any issues.

Closes: ClangBuiltLinux#129
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
@dileks
Copy link
Contributor Author

dileks commented Jan 11, 2021

Wow how fast, thanks!

@JiaHuann
Copy link

JiaHuann commented Sep 5, 2024

Why i meet this again in pahole 1.27.....

@ptr1337
Copy link
Member

ptr1337 commented Sep 5, 2024

Why i meet this again in pahole 1.27.....

Pahole needs to be patched currently. Should be too fixed in -git now.

@dileks
Copy link
Contributor Author

dileks commented Sep 5, 2024

ClangBuiltLinux/linux#2032
ClangBuiltLinux/linux#2032 (comment)

@JiaHuann
Copy link

JiaHuann commented Sep 6, 2024

为什么我在 pahole 1.27 中再次遇到这种情况......

Pahole 目前需要修补。现在应该在 -git 中修复了。

ClangBuiltLinux/linux#2032 ClangBuiltLinux/linux#2032(评论)

Thanks. Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants