-
Notifications
You must be signed in to change notification settings - Fork 180
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
introduce builtin memcmp etc., like bpf in cilium #32
Comments
In Cilium those builtins are useful to (1) reduce the BPF complexity and (2) reduce runtime overhead. I doubt (1) is an issue for pwru today and it's not clear if (2) would be noticeable. In Cilium's case, (1) is regularly an issue, but we didn't measure the performance difference for (2). |
I think for now we could rely on |
Yes, I introduced this earlier, but I had a problem compiling it, so I removed it. I can see how to fix it later. |
Rewrite static __always_inline bool
addr_equal(union addr a, u8 b[16]) {
if (__builtin_memcmp(&a, b, sizeof(a)) != 0) {
return false;
}
return true;
} After that, 2021/10/26 15:36:24 Loading objects: field KprobeSkb1: program kprobe_skb_1: call at 367: reference to missing symbol "memcmp" Looking at the symbol table by executing readelf, I found that [duanjiong@fedora pwru]$ readelf -s kprobepwru_bpfeb.o
158: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND memcmp My version of clang is as follows [duanjiong@fedora pwru]$ clang --version
clang version 12.0.1 (Fedora 12.0.1-1.fc34)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin |
Clang only supports those builtins in specific cases: https://clang.llvm.org/docs/LanguageExtensions.html#string-builtins. |
I encountered the same problem.
|
How do I use |
@thealexcons same issue for me. |
Is this related to llvm/llvm-project#26592 ? |
I am fairly sure that memcmp is fixed by using clang 15 or newer: |
When writing bpf programs, you may need to use some basic memory operations, such as memcmp, etc.
https://github.com/cilium/cilium/blob/master/bpf/include/bpf/builtins.h
The text was updated successfully, but these errors were encountered: