gobpf icon indicating copy to clipboard operation
gobpf copied to clipboard

Build failed with libbcc `0.19.0-21d866e2`

Open prateeknischal opened this issue 3 years ago • 1 comments

When trying to run one of the examples, I get a build failed with the following error

# github.com/iovisor/gobpf/bcc
bcc/module.go:98:40: too many arguments in call to _Cfunc_bpf_module_create_c_from_string
        have (*_Ctype_char, number, **_Ctype_char, _Ctype_int, _Ctype__Bool, nil)
        want (*_Ctype_char, _Ctype_uint, **_Ctype_char, _Ctype_int, _Ctype__Bool)
bcc/module.go:230:28: too many arguments in call to _C2func_bcc_func_load
        have (unsafe.Pointer, _Ctype_int, *_Ctype_char, *_Ctype_struct_bpf_insn, _Ctype_int, *_Ctype_char, _Ctype_uint, _Ctype_int, *_Ctype_char, _Ctype_uint, nil)
        want (unsafe.Pointer, _Ctype_int, *_Ctype_char, *_Ctype_struct_bpf_insn, _Ctype_int, *_Ctype_char, _Ctype_uint, _Ctype_int, *_Ctype_char, _Ctype_uint)
bcc/module.go:261:33: too many arguments in call to _C2func_bpf_attach_uprobe
        have (_Ctype_int, uint32, *_Ctype_char, *_Ctype_char, _Ctype_ulong, _Ctype_int, number)
        want (_Ctype_int, uint32, *_Ctype_char, *_Ctype_char, _Ctype_ulong, _Ctype_int)

The definitions for the functions seem to have dropped the last attribute. I am running the libbcc version 0.19.0-21d866e2 looked up from bcc_version.h.

root@linux-dev:/usr/include/bcc# grep -r bcc_func_load . -A 3
./bcc_common.h:int bcc_func_load(void *program, int prog_type, const char *name,
./bcc_common.h-                  const struct bpf_insn *insns, int prog_len,
./bcc_common.h-                  const char *license, unsigned kern_version,
./bcc_common.h-                  int log_level, char *log_buf, unsigned log_buf_size);
--
./bpf_module.h:  int bcc_func_load(int prog_type, const char *name,
./bpf_module.h-                    const struct bpf_insn *insns, int prog_len,
./bpf_module.h-                    const char *license, unsigned kern_version,
./bpf_module.h-                    int log_level, char *log_buf, unsigned log_buf_size);

After modification of the function definitions, I am able to run the examples, but as

sudo -E /usr/local/go/bin/go run examples/bcc/execsnoop/*.go 

and not as

$ sudo -E /usr/local/go/bin/go run examples/bcc/execsnoop/execsnoop.go
# command-line-arguments
examples/bcc/execsnoop/execsnoop.go:241:10: undefined: newOutput

Environment info

$ lsb_release --all
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

$ go version
go version go1.15.6 linux/amd64

$ uname -a
Linux linux-dev 5.4.0-70-generic #78-Ubuntu SMP Fri Mar 19 13:29:52 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ apt show libbcc
Package: libbcc
Version: 0.10.0-1
Priority: optional
Section: misc
Source: bcc
Maintainer: Brenden Blanco <[email protected]>
Installed-Size: 58.3 MB
Provides: libbpfcc, libbpfcc-dev
Depends: libc6, libstdc++6, libelf1
Conflicts: libbpfcc, libbpfcc-dev
Homepage: https://github.com/iovisor/bcc
Download-Size: 15.8 MB
APT-Manual-Installed: no
APT-Sources: https://repo.iovisor.org/apt/bionic bionic/main amd64 Packages
Description: Shared Library for BPF Compiler Collection (BCC)
 Shared Library for BPF Compiler Collection to control BPF programs
 from userspace.

prateeknischal avatar Apr 15 '21 15:04 prateeknischal

The go binding should be made working with the newest version of bcc, there shall be special tag added for any changes that map to certain commit in the bcc repo. Hopefully can cut releases alongside BCC release (if BCC has releases).

justicezyx avatar Jul 31 '22 07:07 justicezyx