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

Centos7.5 build failure #2478

Closed
balasu opened this issue Aug 1, 2019 · 18 comments
Closed

Centos7.5 build failure #2478

balasu opened this issue Aug 1, 2019 · 18 comments

Comments

@balasu
Copy link

balasu commented Aug 1, 2019

Hi

I am trying to do build on centos7.5, getting below error on running make command. pl suggest what all dependencies needs to be installed

/root/bcc/src/cc/libbpf/src/libbpf.c: In function ‘bpf_program__attach_perf_event’:
/root/bcc/src/cc/libbpf/src/libbpf.c:4033:17: error: ‘PERF_EVENT_IOC_SET_BPF’ undeclared (first use in this function); did you mean PERF_EVENT_IOC_SET_OUTPUT’?
if (ioctl(pfd, PERF_EVENT_IOC_SET_BPF, prog_fd) < 0) {
^~~~~~~~~~~~~~~~~~~~~~
PERF_EVENT_IOC_SET_OUTPUT
/root/bcc/src/cc/libbpf/src/libbpf.c:4033:17: note: each undeclared identifier is reported only once for each function it appears in
/root/bcc/src/cc/libbpf/src/libbpf.c: In function ‘perf_buffer__new’:
/root/bcc/src/cc/libbpf/src/libbpf.c:4522:13: error: ‘PERF_COUNT_SW_BPF_OUTPUT’ undeclared (first use in this function); did you mean ‘PERF_COUNT_SW_CPU_CLOCK’?
.config = PERF_COUNT_SW_BPF_OUTPUT,
^~~~~~~~~~~~~~~~~~~~~~~~
PERF_COUNT_SW_CPU_CLOCK
make[2]: *** [src/cc/CMakeFiles/bpf-shared.dir/build.make:154: src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:131: src/cc/CMakeFiles/bpf-shared.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

@palmtenor
Copy link
Member

What is your Kernel version? Is your Kernel built with BPF enabled?

@balasu
Copy link
Author

balasu commented Aug 1, 2019

Hi
its 4.16.10-1.el7.elrepo.x86_64. assume this is the param to enable bpf

[root@localhost build]# sysctl -a | grep bpf
kernel.unprivileged_bpf_disabled = 0
net.core.bpf_jit_enable = 1
net.core.bpf_jit_harden = 0
net.core.bpf_jit_kallsyms = 0

@yonghong-song
Copy link
Collaborator

Most likely your system does not have an up-to-date /usr/include/linux/perf_event.h which contains a definition for PERF_EVENT_IOC_SET_BPF.

To solve your problem, we probably should sync uapi linux/perf_event.h to libbpf repo.

Could you file an issue against https://github.com/libbpf/libbpf?

@balasu
Copy link
Author

balasu commented Aug 2, 2019

Hi
I was able to overcme that err by updating kernel-headers rpm. now both make and make install are successful

install_manifest.txt
however i am not able to find bcc tools , kindly suggest.

[root@localhost build]# pwd
/root/bcc/build
[root@localhost build]# echo $PATH
/root/bcc/build/install/bin:/opt/rh/llvm-toolset-7/root/usr/lib64/cmake/llvm/:/root/go/bin:/root/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin
[root@localhost build]# ll
total 80
-rw-r--r-- 1 root root 25465 Aug 2 15:52 CMakeCache.txt
drwxr-xr-x 5 root root 4096 Aug 2 16:03 CMakeFiles
-rw-r--r-- 1 root root 1905 Aug 2 15:52 cmake_install.cmake
-rw-r--r-- 1 root root 346 Aug 2 15:52 CTestTestfile.cmake
drwxr-xr-x 7 root root 149 Aug 2 15:52 examples
-rw-r--r-- 1 root root 19812 Aug 2 16:03 install_manifest.txt
drwxr-xr-x 3 root root 105 Aug 2 15:55 introspection
-rw-r--r-- 1 root root 17505 Aug 2 15:52 Makefile
drwxr-xr-x 4 root root 106 Aug 2 15:52 man
drwxr-xr-x 6 root root 129 Aug 2 15:52 src
drwxr-xr-x 6 root root 147 Aug 2 15:52 tests
drwxr-xr-x 5 root root 116 Aug 2 15:52 tools
[root@localhost build]#

@yonghong-song
Copy link
Collaborator

The bcc tools stay in the source directory or in your install directory.

@balasu
Copy link
Author

balasu commented Aug 2, 2019

Hi
This directory is not created after make install. pl suggest
/root/bcc/build/install/

[root@localhost build]# ll
total 80
-rw-r--r-- 1 root root 25465 Aug 2 15:52 CMakeCache.txt
drwxr-xr-x 5 root root 4096 Aug 2 16:03 CMakeFiles
-rw-r--r-- 1 root root 1905 Aug 2 15:52 cmake_install.cmake
-rw-r--r-- 1 root root 346 Aug 2 15:52 CTestTestfile.cmake
drwxr-xr-x 7 root root 149 Aug 2 15:52 examples
-rw-r--r-- 1 root root 19812 Aug 2 16:03 install_manifest.txt
drwxr-xr-x 3 root root 105 Aug 2 15:55 introspection
-rw-r--r-- 1 root root 17505 Aug 2 15:52 Makefile
drwxr-xr-x 4 root root 106 Aug 2 15:52 man
drwxr-xr-x 6 root root 129 Aug 2 15:52 src
drwxr-xr-x 6 root root 147 Aug 2 15:52 tests
drwxr-xr-x 5 root root 116 Aug 2 15:52 tools
[root@localhost build]#

@yonghong-song
Copy link
Collaborator

the build prefix needs to be specified at cmake command line like
cmake3 .. -DCMAKE_INSTALL_PREFIX=/usr
you can check with INSTALL.md for details.

@balasu
Copy link
Author

balasu commented Aug 5, 2019

Hi Song
Thanks
i can see tools in /usr/share/bcc/tools
when i try to run ,getting below error
[root@localhost tools]# ./execsnoop
Traceback (most recent call last):
File "./execsnoop", line 21, in
from bcc import BPF
File "/usr/lib/python2.7/site-packages/bcc/init.py", line 26, in
from .libbcc import lib, bcc_symbol, bcc_symbol_option, bcc_stacktrace_build_id, _SYM_CB_TYPE
File "/usr/lib/python2.7/site-packages/bcc/libbcc.py", line 17, in
lib = ct.CDLL("libbcc.so.0", use_errno=True)
File "/usr/lib64/python2.7/ctypes/init.py", line 360, in init
self._handle = _dlopen(self._name, mode)
OSError: libclangFrontend.so.5: cannot open shared object file: No such file or directory

this file libclangFrontend.so.5 is present /opt/rh/llvm-toolset-7/root/usr/lib64/libclangFrontend.so.5
pl suggest configure for the execsnoop to pick this libclang library

@yonghong-song
Copy link
Collaborator

Some suggestions from online:
https://stackoverflow.com/questions/2980479/python-ctypes-loading-dll-from-from-a-relative-path
Maybe you try to put /opt/rh/llvm-toolset-7/root/usr/lib64 into your PATH env to see whether it helps or not? Yes, we may need to fix this for shared library environment. Maybe you can experiment and propose a fix. Thanks.

@balasu
Copy link
Author

balasu commented Aug 6, 2019

hi
in bashrc and bash_profile of user have set this. export PATH=$PATH:/opt/rh/llvm-toolset-7/root/usr/lib64/ however the same error comes.

[root@localhost tools]# source /root/.bash_profile
[root@localhost tools]# ./tcplife
Traceback (most recent call last):
File "./tcplife", line 26, in
from bcc import BPF
File "/usr/lib/python2.7/site-packages/bcc/init.py", line 26, in
from .libbcc import lib, bcc_symbol, bcc_symbol_option, bcc_stacktrace_build_id, _SYM_CB_TYPE
File "/usr/lib/python2.7/site-packages/bcc/libbcc.py", line 17, in
lib = ct.CDLL("libbcc.so.0", use_errno=True)
File "/usr/lib64/python2.7/ctypes/init.py", line 360, in init
self._handle = _dlopen(self._name, mode)
OSError: libclangFrontend.so.5: cannot open shared object file: No such file or directory

@yonghong-song
Copy link
Collaborator

Something like the below

diff --git a/src/python/bcc/libbcc.py b/src/python/bcc/libbcc.py
index e98bb140..180bcf8b 100644
--- a/src/python/bcc/libbcc.py
+++ b/src/python/bcc/libbcc.py
@@ -14,6 +14,7 @@
 
 import ctypes as ct
 
+lib = ct.CDLL("libclangFrontend.so.5", use_errno=True)
 lib = ct.CDLL("libbcc.so.0", use_errno=True)
 
 # keep in sync with bcc_common.h

might fix your issue.

If this does fix your issue, maybe we need to check ldd libbcc.so.0 and explicitly load certain libraries. I am not 100% sure what libraries to explicitly load, maybe those not in /lib64, /usr/lib directories. May need to check CDLL() implementation for clarity.

@balasu
Copy link
Author

balasu commented Aug 7, 2019

Hi
I did LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rh/llvm-toolset-7/root/usr/;export LD_LIBRARY_PATH

now getting like below

[root@localhost tools]# ./tcplife
modprobe: FATAL: Module kheaders not found.
Unable to find kernel headers. Try rebuilding kernel with CONFIG_IKHEADERS=m (module)
chdir(/lib/modules/4.16.10-1.el7.elrepo.x86_64/build): No such file or directory
Traceback (most recent call last):
File "./tcplife", line 456, in
b = BPF(text=bpf_text)
File "/usr/lib/python2.7/site-packages/bcc/init.py", line 347, in init
raise Exception("Failed to compile BPF module %s" % (src_file or ""))
Exception: Failed to compile BPF module

@balasu
Copy link
Author

balasu commented Aug 7, 2019

Hi Song
have updated the kernel and kernel devel to below
[root@localhost tools]# uname -a
Linux localhost.localdomain 5.2.7-1.el7.elrepo.x86_64 #1 SMP Tue Aug 6 14:33:51 EDT 2019 x86_64 x86_64 x86_64 GNU/Linux

getting segmentation fault, pl suggest
[root@localhost tools]# ./syscount
Segmentation fault

@palmtenor
Copy link
Member

Do you mind sharing a stack trace of the segfault?

@balasu
Copy link
Author

balasu commented Aug 8, 2019

Hi
please find the stack trace.

[root@localhost tools]# gdb python
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http:https://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
http:https://www.gnu.org/software/gdb/bugs/...
Reading symbols from /usr/bin/python2.7...Reading symbols from /usr/bin/python2.7...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Missing separate debuginfos, use: debuginfo-install python-2.7.5-69.el7_5.x86_64
(gdb) run tcplife
Starting program: /usr/bin/python tcplife
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
warning: JITed object file architecture unknown is not compatible with target architecture i386:x86-64.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6e8bff1 in __strlen_sse2_pminub () from /lib64/libc.so.6
(gdb) backtrace
#0 0x00007ffff6e8bff1 in __strlen_sse2_pminub () from /lib64/libc.so.6
#1 0x00007fffee1280b8 in __bpf_object__open.part.18 () from /lib64/libbcc.so.0
#2 0x00007fffee12bb77 in bpf_prog_load_xattr () from /lib64/libbcc.so.0
#3 0x00007fffee12bd3b in bpf_prog_load () from /lib64/libbcc.so.0
#4 0x00007ffff0393dcc in ffi_call_unix64 () from /lib64/libffi.so.6
#5 0x00007ffff03936f5 in ffi_call () from /lib64/libffi.so.6
#6 0x00007ffff05a6cd9 in _ctypes_callproc () from /usr/lib64/python2.7/lib-dynload/_ctypes.so
#7 0x00007ffff05a09e5 in PyCFuncPtr_call () from /usr/lib64/python2.7/lib-dynload/_ctypes.so
#8 0x00007ffff7a5aa63 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#9 0x00007ffff7aef236 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#10 0x00007ffff7af603d in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#11 0x00007ffff7af353c in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#12 0x00007ffff7af603d in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#13 0x00007ffff7af353c in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#14 0x00007ffff7af603d in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#15 0x00007ffff7a7fa6d in function_call () from /lib64/libpython2.7.so.1.0
#16 0x00007ffff7a5aa63 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#17 0x00007ffff7a69a55 in instancemethod_call () from /lib64/libpython2.7.so.1.0
#18 0x00007ffff7a5aa63 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#19 0x00007ffff7ab1a87 in slot_tp_init () from /lib64/libpython2.7.so.1.0
#20 0x00007ffff7ab079f in type_call () from /lib64/libpython2.7.so.1.0
#21 0x00007ffff7a5aa63 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#22 0x00007ffff7aef236 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#23 0x00007ffff7af603d in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#24 0x00007ffff7af6142 in PyEval_EvalCode () from /lib64/libpython2.7.so.1.0
#25 0x00007ffff7b0f57f in run_mod () from /lib64/libpython2.7.so.1.0
#26 0x00007ffff7b1073e in PyRun_FileExFlags () from /lib64/libpython2.7.so.1.0
#27 0x00007ffff7b119c9 in PyRun_SimpleFileExFlags () from /lib64/libpython2.7.so.1.0
#28 0x00007ffff7b22b7f in Py_Main () from /lib64/libpython2.7.so.1.0
#29 0x00007ffff6d3f445 in __libc_start_main () from /lib64/libc.so.6
#30 0x000000000040066e in _start ()
(gdb)

@rayroot
Copy link

rayroot commented Sep 17, 2019

@balasu
HI
I solved this problems by
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rh/llvm-toolset-7/root/usr/lib64/ ,
and not
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rh/llvm-toolset-7/root/usr/

Maybe you can try it ?

@ioworker0
Copy link

ioworker0 commented Jun 23, 2020

HI
I sloved this problem by

yum install kernel-headers

Maybe you can try it ?

@eytanaim
Copy link

I also needed to install kernel-devel package
yum install kernel-devel-$(uname -r)

@balasu balasu closed this as completed Nov 4, 2020
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

6 participants