Comments (13)
Please see #70, in case it's related. But also make sure you perform git submodule update --init --recursive
(recursive part is important).
from libbpf-bootstrap.
@qmonnet I think it would be easier and faster to submit bpftool fix separately
from libbpf-bootstrap.
interestingly, on fedora 35 the cmake
build (almost) work - I have to compile the bpftool
executable in bpftool/src
and copy it into the tools
subdirectory, otherwise getting this error:
[ 23%] Built target libbpf
[ 41%] Built target libbpf-build
[ 44%] [clang] Building BPF object: bootstrap
[ 47%] [skel] Building BPF skeleton: bootstrap
bash: line 1: /home/vagrant/gh/libbpf/libbpf-bootstrap/examples/c/../../tools/bpftool: No such file or directory
On rhel8, it doesn't work - skeleton/pid_iter.bpf.c:90:36: error: use of undeclared identifier 'BPF_LINK_TYPE_PERF_EVENT'; did you mean 'BPF_PROG_TYPE_PERF_EVENT'?
- the kernel must be too old.
from libbpf-bootstrap.
Never mind - was my bad clone as mentioned in xdp-project/xdp-tutorial#93 (comment). With the correct clone (git clone --recurse-submodules https://github.com/libbpf/libbpf-bootstrap
), the examples/c
build is clean on both rhel8 and fc35.
from libbpf-bootstrap.
actually I think this issue needs to be reopened. I carefully followed the instructions for the CMake build from https://github.com/libbpf/libbpf-bootstrap#c-examples (starting with git submodule update --init --recursive
), but it does not work - I'm getting the following error:
[ 17%] Built target libbpf-build
[ 20%] [clang] Building BPF object: uprobe
[ 23%] [skel] Building BPF skeleton: uprobe
bash: /home/dmitris/dev/hack/gh/libbpf/libbpf-bootstrap/examples/c/../../tools/bpftool: No such file or directory
make[2]: *** [CMakeFiles/uprobe.dir/build.make:74: uprobe.skel.h] Error 127
make[2]: *** Deleting file 'uprobe.skel.h'
make[1]: *** [CMakeFiles/Makefile2:93: CMakeFiles/uprobe.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Do we need to add CMakefile instructions to build bpftool
with the correct libbpf code, and copy the binary in the expected place?
from libbpf-bootstrap.
@dmitris do you still have a problem building examples?
from libbpf-bootstrap.
@ankryiko I'm getting this problem when building using the makefile instructions; I also get the error described in #70 if I try to use the cmake instructions.
FYI: I've cloned at commit 2b5b2bb, and git submodule status --recursive
gives:
1e1f48c18da9416e1d4c35ec9bce4ed77019b109 ../../blazesym (1e1f48c)
8ec897a0cd357fe9e13eec7d27d43e024891746b ../../bpftool (v6.8.0-1-g8ec897a)
86eb09863c1c0177e99c2c703092042d3cdba910 ../../bpftool/libbpf (v0.8.0)
4eb6485c08867edaa5a0a81c64ddb23580420340 ../../libbpf (v0.8.0-5-g4eb6485)
OS: Ubuntu 21.04
Kernel: Linux 5.11.0-49-generic x86_64
from libbpf-bootstrap.
@pynem I faced the same problem on Ubuntu 20.04 with 5.13.0-51-generic.
Quoting part of this stackoverflow answer
To compile without error, you need a kernel recent enough to have struct bpf_perf_link defined (it's 5.15+), and compiled with option CONFIG_PERF_EVENTS, as mentioned in the message you found.
For now, undoing the changes in libbpf/bpftool@d97300d (commenting out/deleting the additions to pid_iter.bpf.c
) works as a quick fix. Another way would be to apply the patch that @dmitris referred to.
diff --git a/src/skeleton/pid_iter.bpf.c b/src/skeleton/pid_iter.bpf.c
index eb05ea5..3f81545 100644
--- a/src/skeleton/pid_iter.bpf.c
+++ b/src/skeleton/pid_iter.bpf.c
@@ -38,17 +38,6 @@ static __always_inline __u32 get_obj_id(void *ent, enum bpf_obj_type type)
}
}
-/* could be used only with BPF_LINK_TYPE_PERF_EVENT links */
-static __u64 get_bpf_cookie(struct bpf_link *link)
-{
- struct bpf_perf_link *perf_link;
- struct perf_event *event;
-
- perf_link = container_of(link, struct bpf_perf_link, link);
- event = BPF_CORE_READ(perf_link, perf_file, private_data);
- return BPF_CORE_READ(event, bpf_cookie);
-}
-
SEC("iter/task_file")
int iter(struct bpf_iter__task_file *ctx)
{
@@ -80,19 +69,9 @@ int iter(struct bpf_iter__task_file *ctx)
if (file->f_op != fops)
return 0;
- __builtin_memset(&e, 0, sizeof(e));
e.pid = task->tgid;
e.id = get_obj_id(file->private_data, obj_type);
- if (obj_type == BPF_OBJ_LINK) {
- struct bpf_link *link = (struct bpf_link *) file->private_data;
-
- if (BPF_CORE_READ(link, type) == BPF_LINK_TYPE_PERF_EVENT) {
- e.has_bpf_cookie = true;
- e.bpf_cookie = get_bpf_cookie(link);
- }
- }
-
bpf_probe_read_kernel_str(&e.comm, sizeof(e.comm),
task->group_leader->comm);
bpf_seq_write(ctx->meta->seq, &e, sizeof(e));
from libbpf-bootstrap.
@algrebe Thanks for the information! Is there a version that will work with a 5.11 kernel?
from libbpf-bootstrap.
@qmonnet is there anything we can do to make bpftool a bit less demanding about how up-to-date host kernel on the build machine has to be? Should we just define some of those used constants?
from libbpf-bootstrap.
Related: libbpf/bpftool#17
My understanding here is that the patch from Alexander would solve the issue upstream. I tried to ping him about it some time ago but didn't get an answer.
I can maybe resubmit this patch this week, once it's merged we can pull it in the bpftool mirror and then in this repo. I'm not aware of any other object, beside struct bpf_perf_link
, which should be blocking for bpftool on older kernels at the moment.
How does that sound to you?
from libbpf-bootstrap.
@pynem can you try again and see if #92 helps?
from libbpf-bootstrap.
tried now and build works fine, thanks! 👍
from libbpf-bootstrap.
Related Issues (20)
- Make error - poisoned strlcpy HOT 1
- Android xmake fails HOT 10
- add xdp synproxy in c example? HOT 2
- run fentry examples in Loongarch cpu failed HOT 2
- error: unable to create target: 'No available targets are compatible with triple "bpf"' HOT 1
- Does libbpf-bootstrap support sk_msg/stream_parser & sk_msg/stream_parser hook ?
- example uprobe no output HOT 4
- (ARM64) Rust Example Tracecon Does Not Compile HOT 2
- [Android] Failed to find valid kernel BTF HOT 19
- How to read arbitrary len bytes using helper bpf_skb_load_bytes()? HOT 2
- To compile the Rust example in libbpf-bootstrap for use on the Android platform or arm64 , what should I do? HOT 1
- when compile the Rust example in libbpf-bootstrap for target arm64 ,why build.rs use vmlinux.h is x86 ? HOT 8
- unknown func bpf_kallsyms_lookup_name#179 HOT 1
- Can you please add a bpf_for() example? HOT 1
- minimal_ns doesn't compile HOT 1
- Compilation failed, missing a header file? HOT 6
- make failed under `examples/c` with `gimli = "^0.28"` HOT 10
- error: could not compile `gimli` (lib) HOT 2
- Make doesn't detect changes in the header files
- Compiling profile files in libbpf-bootstrap/examples/c/ HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libbpf-bootstrap.