delve ftbfs on amd64 due to bpftool

Bug #2021481 reported by Shengjing Zhu
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
delve (Ubuntu)
Fix Released
Undecided
Unassigned
linux (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

src/github.com/go-delve/delve/pkg/proc/internal/ebpf/helpers.go
WARNING: bpftool not found for kernel 6.1.0-9

  You may need to install the following packages for this specific kernel:
    linux-tools-6.1.0-9-amd64
    linux-cloud-tools-6.1.0-9-amd64

  You may also want to install one of the following packages to keep up to date:
    linux-tools-amd64
    linux-cloud-tools-amd64

The Debian package build-depends on bpftool. But bpftool is different in Debian and Ubuntu. On Ubuntu it's provided by linux-tools-common. However it seems it needs linux-tools-amd64 as well?

Revision history for this message
Shengjing Zhu (zhsj) wrote :

Actually it needs linux-tools for the running kernel. So it seems impossible to code it in debian/control as the running kernel version can't be predicted.

Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. While running an Ubuntu kernel (not a mainline or third-party kernel) please enter the following command in a terminal window:

apport-collect 2021481

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
Shengjing Zhu (zhsj)
Changed in linux (Ubuntu):
status: Incomplete → Confirmed
Changed in delve (Ubuntu):
status: New → Confirmed
Revision history for this message
Shengjing Zhu (zhsj) wrote (last edit ):

The bpftool is used in following command

`bpftool btf dump file /sys/kernel/btf/vmlinux format c`

Upstream statically encoded the generated output in source tree, https://github.com/go-delve/delve/blob/v1.20.2/pkg/proc/internal/ebpf/bpf/include/vmlinux.h

But the Debian package strips this vmlinux.h file and generates it at build time.

@Kernel team, what you think is more appreciated? If generating at build time, then we need a runnable bpftool command in build env.

tags: added: ftbfs update-excuse
Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

I tried to call bpftool directly instead of using the /usr/sbin/bpftool script: https://git.launchpad.net/~danilogondolfo/ubuntu/+source/delve/commit/?h=ubuntu/devel&id=2cf86a5394786f9ec8b2931d0c4c05af992be1c2

It kinda worked but then the build failed with:

In file included from /<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/github.com/go-delve/delve/pkg/proc/internal/ebpf/bpf/trace.bpf.c:1:
/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/github.com/go-delve/delve/pkg/proc/internal/ebpf/bpf/include/trace.bpf.h:10:17: error: use of undeclared identifier 'BPF_MAP_TYPE_RINGBUF'
   __uint(type, BPF_MAP_TYPE_RINGBUF);
                ^
/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/github.com/go-delve/delve/pkg/proc/internal/ebpf/bpf/include/trace.bpf.h:15:17: error: use of undeclared identifier 'BPF_MAP_TYPE_RINGBUF'
   __uint(type, BPF_MAP_TYPE_RINGBUF);
                ^
/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/src/github.com/go-delve/delve/pkg/proc/internal/ebpf/bpf/trace.bpf.c:243:37: error: use of undeclared identifier 'BPF_RB_FORCE_WAKEUP'
    bpf_ringbuf_submit(parsed_args, BPF_RB_FORCE_WAKEUP);
                                    ^
3 errors generated.
Error: clang: exit status 1

Looks like pkg/proc/internal/ebpf/bpf/include/trace.bpf.h is missing a #include <linux/bpf.h>

Maybe there is a better solution than this hack...

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package delve - 1.21.0-1

---------------
delve (1.21.0-1) unstable; urgency=medium

  * New upstream version 1.21.0
    + Read debug info file from correct directory in trace
      command (Closes: #1037284)
  * Don't generate vmlinux.h with bpftool (LP: #2021481)
    bpftool is not functional on Ubuntu builder
  * Bump golang-starlark-dev to 0.0~git20230726.7dadff3
  * Bump golang-github-google-go-dap-dev to 0.10.0

 -- Shengjing Zhu <email address hidden> Fri, 28 Jul 2023 22:00:15 +0800

Changed in delve (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Oibaf (oibaf) wrote :

It looks like this issue was fixed in delve.

Changed in linux (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.