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

clang15 prevents automatic conversion of void * to u64 #4467

Closed
Y7n05h opened this issue Feb 8, 2023 · 0 comments · Fixed by #4468
Closed

clang15 prevents automatic conversion of void * to u64 #4467

Y7n05h opened this issue Feb 8, 2023 · 0 comments · Fixed by #4468

Comments

@Y7n05h
Copy link
Contributor

Y7n05h commented Feb 8, 2023

When map.call() appears in the code, an implicit type conversion from void* to u64 is required, but this is not allowed in clang15.

/virtual/main.c:24: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, 2);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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/admin/Templates/tmp.rhOt4STjdi/1.py", line 2, in <module>
    b = BPF(src_file="example.c")
  File "/usr/lib/python3.10/site-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 b'example.c'

To reproduce the problem:
You need to use clang15. Then run the map.call() example in the documentation.

Although I couldn't find this change in the clang15 changelog (maybe I didn't look carefully), it is indeed not allowed.
Here is a comparison of the output of clang14 and clang15 for a similar problem. You can see that in clang14, that's just a warning. But in the output of clang15, we get an error.

Y7n05h added a commit to Y7n05h/bcc that referenced this issue Feb 8, 2023
clang15 prevents implicit type conversion of void * to u64
fix iovisor#4467

Signed-off-by: Y7n05h <[email protected]>
Y7n05h added a commit to Y7n05h/bcc that referenced this issue Feb 9, 2023
clang15 prevents implicit type conversion of void * to u64
fix iovisor#4467

Signed-off-by: Y7n05h <[email protected]>
chenhengqi pushed a commit that referenced this issue Feb 9, 2023
clang15 prevents implicit type conversion of void * to u64
fix #4467

Signed-off-by: Y7n05h <[email protected]>
captain5050 pushed a commit to captain5050/bcc that referenced this issue Oct 12, 2023
clang15 prevents implicit type conversion of void * to u64
fix iovisor#4467

Signed-off-by: Y7n05h <[email protected]>
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.

1 participant