iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.36k stars 3.86k forks source link

/virtual/main.c:18:20: error: incompatible pointer to integer conversion passing 'void *' to parameter of type 'u64' (aka 'unsigned long long') #4898

Open NobinPegasus opened 8 months ago

NobinPegasus commented 8 months ago

While trying to run the bpf_tail_call_ function I'm facing the following error:

pegasus@pegasus:~/Documents/eBPF/learning-ebpf/chapter2$ sudo ./hello-tail.py 
[sudo] password for pegasus: 
/virtual/main.c:18:20: error: incompatible pointer to integer conversion passing 'void *' to parameter of type 'u64' (aka 'unsigned long long') [-Wint-conversion]
    bpf_tail_call_((void *)bpf_pseudo_fd(1, -1), ctx, opcode);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/virtual/include/bcc/helpers.h:552:25: note: passing argument to parameter 'map_fd' here
void bpf_tail_call_(u64 map_fd, void *ctx, int index) {
                        ^
1 error generated.
Traceback (most recent call last):
  File "/home/pegasus/Documents/eBPF/learning-ebpf/chapter2/./hello-tail.py", line 41, in <module>
    b = BPF(text=program)
        ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 479, in __init__
    raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>

Inside bcc/src/cc/export/helpers.h I've the following code:

void bpf_tail_call_(void *map_fd, void *ctx, int index) {
  ((void (*)(void *, u64, int))BPF_FUNC_tail_call)(ctx, (u64)map_fd, index);
}

I tried to install BCC using the following commands:

git clone https://github.com/iovisor/bcc.git
mkdir bcc/build; cd bcc/build
cmake ..
make
sudo make install
cmake -DPYTHON_CMD=python3 .. # build python3 binding
pushd src/python/
make
sudo make install
popd

Can anyone provide any suggestions, why am I still facing the same error? Although it's solved in the src My clang version:

pegasus@pegasus:~/Documents/eBPF/learning-ebpf/chapter2$ clang --version
Homebrew clang version 17.0.6
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/linuxbrew/.linuxbrew/bin