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

python-bcc works only if clang-libs Installed, fails with only clang16-libs Installed #4973

Open
vzhereb9 opened this issue Apr 25, 2024 · 0 comments

Comments

@vzhereb9
Copy link

This issue has been reproduced on RHEL 9.x and RHEL-based distributions such as Alma and Rocky 9.x, but it may be a common error across other distributions as well.

Installed Clang packages:

[root@localhost ~]# rpm -qa | grep clang
clang-resource-filesystem-16.0.6-1.el9.x86_64
clang16-resource-filesystem-16.0.6-6.el9.x86_64
clang16-libs-16.0.6-6.el9.x86_64

To reproduce and address the issue, follow these steps:

Attempt to install BCC and related packages:

[root@localhost ~]# yum install bcc bcc-tools python3-bcc
Last metadata expiration check: 0:28:52 ago on Thu 25 Apr 2024 11:08:28 AM MSK.
Dependencies resolved.
==================================================================================================================================================
 Package                                Architecture                  Version                              Repository                        Size
==================================================================================================================================================
Installing:
 bcc                                    x86_64                        0.26.0-4.el9                         appstream                        617 k
 bcc-tools                              x86_64                        0.26.0-4.el9                         appstream                        465 k
 python3-bcc                            noarch                        0.26.0-4.el9                         appstream                         92 k
Installing dependencies:
 python3-netaddr                        noarch                        0.8.0-5.el9                          appstream                        1.5 M

Transaction Summary
==================================================================================================================================================
Install  4 Packages

Total download size: 2.7 M
Installed size: 14 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): bcc-tools-0.26.0-4.el9.x86_64.rpm                                                                          1.2 MB/s | 465 kB     00:00
(2/4): bcc-0.26.0-4.el9.x86_64.rpm                                                                                1.5 MB/s | 617 kB     00:00
(3/4): python3-netaddr-0.8.0-5.el9.noarch.rpm                                                                     3.2 MB/s | 1.5 MB     00:00
(4/4): python3-bcc-0.26.0-4.el9.noarch.rpm                                                                        1.0 MB/s |  92 kB     00:00
--------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                             3.1 MB/s | 2.7 MB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                          1/1
  Installing       : python3-netaddr-0.8.0-5.el9.noarch                                                                                       1/4
  Installing       : python3-bcc-0.26.0-4.el9.noarch                                                                                          2/4
  Installing       : bcc-0.26.0-4.el9.x86_64                                                                                                  3/4
  Installing       : bcc-tools-0.26.0-4.el9.x86_64                                                                                            4/4
  Running scriptlet: bcc-tools-0.26.0-4.el9.x86_64                                                                                            4/4
  Verifying        : python3-netaddr-0.8.0-5.el9.noarch                                                                                       1/4
  Verifying        : bcc-tools-0.26.0-4.el9.x86_64                                                                                            2/4
  Verifying        : bcc-0.26.0-4.el9.x86_64                                                                                                  3/4
  Verifying        : python3-bcc-0.26.0-4.el9.noarch                                                                                          4/4

Installed:
  bcc-0.26.0-4.el9.x86_64       bcc-tools-0.26.0-4.el9.x86_64       python3-bcc-0.26.0-4.el9.noarch       python3-netaddr-0.8.0-5.el9.noarch

Complete!

Installation completed successfully

Try running Python and importing BCC:

[root@localhost ~]# python3
Python 3.9.16 (main, Dec  8 2022, 00:00:00)
[GCC 11.3.1 20221121 (Red Hat 11.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bcc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/bcc/__init__.py", line 26, in <module>
    from .libbcc import lib, bcc_symbol, bcc_symbol_option, bcc_stacktrace_build_id, _SYM_CB_TYPE
  File "/usr/lib/python3.9/site-packages/bcc/libbcc.py", line 17, in <module>
    lib = ct.CDLL("libbcc.so.0", use_errno=True)
  File "/usr/lib64/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libclang-cpp.so.16: cannot open shared object file: No such file or directory
>>>

Install clang-libs:

[root@localhost ~]# yum install clang-libs
Last metadata expiration check: 0:32:17 ago on Thu 25 Apr 2024 11:08:28 AM MSK.
Dependencies resolved.
==================================================================================================================================================
 Package                            Architecture                   Version                                Repository                         Size
==================================================================================================================================================
Installing:
 clang-libs                         x86_64                         16.0.6-1.el9                           appstream                          22 M

Transaction Summary
==================================================================================================================================================
Install  1 Package

Total download size: 22 M
Installed size: 114 M
Is this ok [y/N]: y
Downloading Packages:
clang-libs-16.0.6-1.el9.x86_64.rpm                                                                                5.4 MB/s |  22 MB     00:04
--------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                             5.1 MB/s |  22 MB     00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                          1/1
  Installing       : clang-libs-16.0.6-1.el9.x86_64                                                                                           1/1
  Running scriptlet: clang-libs-16.0.6-1.el9.x86_64                                                                                           1/1
  Verifying        : clang-libs-16.0.6-1.el9.x86_64                                                                                           1/1

Installed:
  clang-libs-16.0.6-1.el9.x86_64

Complete!

Installation completed successfully

After installing clang-libs, Python import BCC without any errors.

[root@localhost ~]# python3
Python 3.9.16 (main, Dec  8 2022, 00:00:00)
[GCC 11.3.1 20221121 (Red Hat 11.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bcc
>>>

It's important to note that the issue likely stems from incorrect paths to libclang-cpp.so. For clang-libs, the correct path is /usr/lib64/libclang-cpp.so.16, while for clang16-libs, it's /usr/lib64/llvm16/lib/libclang-cpp.so.16. Therefore, it's necessary to identify and correct the incorrect path being used by BCC.

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

1 participant