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

How can I successfully build it on an older version of Linux, such as CentOS 7 #357

Open
gpt8763 opened this issue Nov 5, 2024 · 5 comments

Comments

@gpt8763
Copy link

gpt8763 commented Nov 5, 2024

In the document says that the feature of bpftime,"In this mode, bpftime can run eBPF programs in userspace without kernel, so it can be ported into low version of Linux "

"I would like to build bpftime on CentOS 7(kernel is 3.10.0-1160.el7.x86_64); however, I encountered an issue as the documentation specifies that it can only be built on Ubuntu Ubuntu 23.04. How can I successfully build it on an older version of Linux, such as CentOS 7?

[root@centos7 bpftime]# tail -f /home/ubuntu/bpftime/build/CMakeFiles/CMakeError.log
/usr/bin/cc -fno-omit-frame-pointer -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_d6624.dir/CheckFunctionExists.c.o -o cmTC_d6624 -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
gmake[2]: *** [cmTC_d6624] Error 1
gmake[2]: Leaving directory /home/ubuntu/bpftime/build/CMakeFiles/CMakeTmp' gmake[1]: *** [cmTC_d6624/fast] Error 2 gmake[1]: Leaving directory /home/ubuntu/bpftime/build/CMakeFiles/CMakeTmp'

[root@centos7 bpftime]# gcc --version
gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)

@Officeyutong
Copy link
Contributor

Does your system have glibc-devel installed?

See https://stackoverflow.com/questions/69731318/could-not-locate-usable-posix-threads-in-centos-7

@gpt8763
Copy link
Author

gpt8763 commented Nov 6, 2024

Package glibc-devel-2.17-326.el7_9.3.x86_64 already installed and latest version
Nothing to do

@gpt8763
Copy link
Author

gpt8763 commented Nov 21, 2024

[ 80%] Linking CXX shared library libbpftime-agent-transformer.so
[ 80%] Built target bpftime_text_segment_transformer
[ 80%] Building CXX object runtime/CMakeFiles/runtime.dir/src/attach/bpf_attach_ctx.cpp.o
In file included from /home/ubuntu/bpftime/runtime/src/attach/bpf_attach_ctx.cpp:8:
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:224:17: error: ‘__u32’ does not name a type
224 | __u32 prog_fd; /* eBPF program to attach /
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:225:17: error: ‘__u32’ does not name a type
225 | __u32 map_fd; /
struct_ops to attach /
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:228:17: error: ‘__u32’ does not name a type
228 | __u32 target_fd; /
object to attach to /
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:229:17: error: ‘__u32’ does not name a type
229 | __u32 target_ifindex; /
target ifindex /
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:231:9: error: ‘__u32’ does not name a type
231 | __u32 attach_type; /
attach type /
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:232:9: error: ‘__u32’ does not name a type
232 | __u32 flags; /
extra flags /
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:234:17: error: ‘__u32’ does not name a type
234 | __u32 target_btf_id; /
btf_id of target to attach to /
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:236:25: error: ‘__aligned_u64’ does not name a type
236 | __aligned_u64 iter_info; /
extra bpf_iter_link_info /
| ^~~~~~~~~~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:237:25: error: ‘__u32’ does not name a type
237 | __u32 iter_info_len; /
iter_info length */
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:244:25: error: ‘__u64’ does not name a type
244 | __u64 bpf_cookie;
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:247:25: error: ‘__u32’ does not name a type
247 | __u32 flags;
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:248:25: error: ‘__u32’ does not name a type
248 | __u32 cnt;
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:249:25: error: ‘__aligned_u64’ does not name a type
249 | __aligned_u64 syms;
| ^~~~~~~~~~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:250:25: error: ‘__aligned_u64’ does not name a type
250 | __aligned_u64 addrs;
| ^~~~~~~~~~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:251:25: error: ‘__aligned_u64’ does not name a type
251 | __aligned_u64 cookies;
| ^~~~~~~~~~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:255:25: error: ‘__u32’ does not name a type
255 | __u32 target_btf_id;
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:260:25: error: ‘__u64’ does not name a type
260 | __u64 cookie;
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:263:25: error: ‘__u32’ does not name a type
263 | __u32 pf;
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:264:25: error: ‘__u32’ does not name a type
264 | __u32 hooknum;
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:265:25: error: ‘__s32’ does not name a type
265 | __s32 priority;
| ^~~~~
/home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:266:25: error: ‘__u32’ does not name a type
266 | __u32 flags;
| ^~~~~
In file included from /home/ubuntu/bpftime/runtime/src/attach/bpf_attach_ctx.cpp:9:
/home/ubuntu/bpftime/runtime/src/handler/link_handler.hpp: In constructor ‘bpftime::bpf_link_handler::bpf_link_handler(bpf_link_create_args)’:
/home/ubuntu/bpftime/runtime/src/handler/link_handler.hpp:22:44: error: ‘struct bpf_link_create_args’ has no member named ‘prog_fd’
22 | : args(args), prog_id(args.prog_fd),
| ^~~~~~~
/home/ubuntu/bpftime/runtime/src/handler/link_handler.hpp:23:41: error: ‘struct bpf_link_create_args’ has no member named ‘target_fd’
23 | attach_target_id(args.target_fd)
| ^~~~~~~~~
In file included from /home/ubuntu/bpftime/runtime/src/handler/handler_manager.hpp:30,
from /home/ubuntu/bpftime/runtime/src/bpftime_shm_internal.hpp:15,
from /home/ubuntu/bpftime/runtime/src/attach/bpf_attach_ctx.cpp:19:
/home/ubuntu/bpftime/runtime/src/handler/map_handler.hpp: At global scope:
/home/ubuntu/bpftime/runtime/src/handler/map_handler.hpp:203:43: warning: ‘maybe_unused’ attribute ignored [-Wattributes]
203 | [[maybe_unused]] uint64_t flags = 0;
| ^
gmake[2]: *** [runtime/CMakeFiles/runtime.dir/build.make:79: runtime/CMakeFiles/runtime.dir/src/attach/bpf_attach_ctx.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1216: runtime/CMakeFiles/runtime.dir/all] Error 2
gmake: *** [Makefile:156: all] Error 2

@TheAhmad
Copy link

TheAhmad commented Nov 21, 2024

Hi @gpt8763,

I have successfully built bfptime on Ubuntu 18.04 and documented the steps here. Hope it helps!

Regards.

@Officeyutong
Copy link
Contributor

[ 80%] Linking CXX shared library libbpftime-agent-transformer.so [ 80%] Built target bpftime_text_segment_transformer [ 80%] Building CXX object runtime/CMakeFiles/runtime.dir/src/attach/bpf_attach_ctx.cpp.o In file included from /home/ubuntu/bpftime/runtime/src/attach/bpf_attach_ctx.cpp:8: /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:224:17: error: ‘__u32’ does not name a type 224 | __u32 prog_fd; /* eBPF program to attach _/ | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:225:17: error: ‘__u32’ does not name a type 225 | _u32 map_fd; / struct_ops to attach _/ | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:228:17: error: ‘__u32’ does not name a type 228 | _u32 target_fd; / object to attach to _/ | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:229:17: error: ‘__u32’ does not name a type 229 | _u32 target_ifindex; / target ifindex _/ | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:231:9: error: ‘__u32’ does not name a type 231 | _u32 attach_type; / attach type _/ | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:232:9: error: ‘__u32’ does not name a type 232 | _u32 flags; / extra flags _/ | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:234:17: error: ‘__u32’ does not name a type 234 | _u32 target_btf_id; / btf_id of target to attach to _/ | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:236:25: error: ‘__aligned_u64’ does not name a type 236 | _aligned_u64 iter_info; / extra bpf_iter_link_info _/ | ^~~~~~~~~~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:237:25: error: ‘__u32’ does not name a type 237 | _u32 iter_info_len; / iter_info length */ | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:244:25: error: ‘__u64’ does not name a type 244 | __u64 bpf_cookie; | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:247:25: error: ‘__u32’ does not name a type 247 | __u32 flags; | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:248:25: error: ‘__u32’ does not name a type 248 | __u32 cnt; | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:249:25: error: ‘__aligned_u64’ does not name a type 249 | __aligned_u64 syms; | ^~~~~~~~~~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:250:25: error: ‘__aligned_u64’ does not name a type 250 | __aligned_u64 addrs; | ^~~~~~~~~~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:251:25: error: ‘__aligned_u64’ does not name a type 251 | __aligned_u64 cookies; | ^~~~~~~~~~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:255:25: error: ‘__u32’ does not name a type 255 | __u32 target_btf_id; | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:260:25: error: ‘__u64’ does not name a type 260 | __u64 cookie; | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:263:25: error: ‘__u32’ does not name a type 263 | __u32 pf; | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:264:25: error: ‘__u32’ does not name a type 264 | __u32 hooknum; | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:265:25: error: ‘__s32’ does not name a type 265 | __s32 priority; | ^~~~~ /home/ubuntu/bpftime/runtime/../runtime/include/bpftime_shm.hpp:266:25: error: ‘__u32’ does not name a type 266 | __u32 flags; | ^~~~~ In file included from /home/ubuntu/bpftime/runtime/src/attach/bpf_attach_ctx.cpp:9: /home/ubuntu/bpftime/runtime/src/handler/link_handler.hpp: In constructor ‘bpftime::bpf_link_handler::bpf_link_handler(bpf_link_create_args)’: /home/ubuntu/bpftime/runtime/src/handler/link_handler.hpp:22:44: error: ‘struct bpf_link_create_args’ has no member named ‘prog_fd’ 22 | : args(args), prog_id(args.prog_fd), | ^~~~~~~ /home/ubuntu/bpftime/runtime/src/handler/link_handler.hpp:23:41: error: ‘struct bpf_link_create_args’ has no member named ‘target_fd’ 23 | attach_target_id(args.target_fd) | ^~~~~~~~~ In file included from /home/ubuntu/bpftime/runtime/src/handler/handler_manager.hpp:30, from /home/ubuntu/bpftime/runtime/src/bpftime_shm_internal.hpp:15, from /home/ubuntu/bpftime/runtime/src/attach/bpf_attach_ctx.cpp:19: /home/ubuntu/bpftime/runtime/src/handler/map_handler.hpp: At global scope: /home/ubuntu/bpftime/runtime/src/handler/map_handler.hpp:203:43: warning: ‘maybe_unused’ attribute ignored [-Wattributes] 203 | [[maybe_unused]] uint64_t flags = 0; | ^ gmake[2]: *** [runtime/CMakeFiles/runtime.dir/build.make:79: runtime/CMakeFiles/runtime.dir/src/attach/bpf_attach_ctx.cpp.o] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:1216: runtime/CMakeFiles/runtime.dir/all] Error 2 gmake: *** [Makefile:156: all] Error 2

Try replacing __u32 to uint32_t, __u64 to uint64_t, etc

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

No branches or pull requests

3 participants