iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.61k stars 3.89k forks source link

unknown component LLVMBitWriter #4519

Open gitcoder6 opened 1 year ago

gitcoder6 commented 1 year ago

Hi,

I am new here. When to compile bcc from source in my sles VM, I got a line at the first step.

-- Found LLVM: /usr/include 13.0.1 (Use LLVM_ROOT envronment variable for another version of LLVM) -- Could NOT find LibDebuginfod (missing: LIBDEBUGINFOD_LIBRARIES LIBDEBUGINFOD_INCLUDE_DIRS) CMake Error at /usr/lib64/cmake/llvm/LLVM-Config.cmake:311 (message): unknown component LLVMBitWriter Call Stack (most recent call first): /usr/lib64/cmake/llvm/LLVM-Config.cmake:333 (expand_topologically) cmake/clang_libs.cmake:33 (llvm_expand_dependencies) src/cc/CMakeLists.txt:132 (include)

-- Configuring incomplete, errors occurred! See also "/root/bcc/build/CMakeFiles/CMakeOutput.log".

I googled a lot without any info.

From other mails, I think i can ignore LibDebuginfod msg, but probably "LLVMBitWriter" is making it fail. Kindly help me resolving this error.

in0rdr commented 1 year ago

I encounter the same issue on a new OpenSuse Tumbleweed installation

in0rdr commented 1 year ago

I noticed that I can replace llvm16 with llvm14:

sudo zypper install llvm14 llvm14-devel

However, doing so will lead to different errors:

CMake Error at CMakeLists.txt:169 (message):
  Unable to find clang libraries
Wh1isper commented 1 year ago

Maybe you can refer this: https://gitlab.archlinux.org/archlinux/packaging/packages/bcc/-/blob/main/PKGBUILD

  export CFLAGS+=" -ffat-lto-objects"
  export CXXFLAGS+=" -ffat-lto-objects"
  cmake .. -DENABLE_LLVM_SHARED=1

Works for me on Arch Linux

EDIT:

I think the key point is -DENABLE_LLVM_SHARED=1

https://github.com/iovisor/bcc/pull/4232 https://github.com/iovisor/bcc/issues/3333 https://github.com/iovisor/bcc/issues/1181

matthew-olson-intel commented 1 year ago

Calling cmake with -DENABLE_LLVM_SHARED=1 fixed the build in Arch Linux for me.

matthew-olson-intel commented 1 year ago

I started to simply edit INSTALL.md and suggest that all Arch Linux users should use -DENABLE_LLVM_SHARED=1, but I can't shake the feeling that this is just a hack. We should fix the actual root of the build problem, not avoid it, especially for distributions with newer LLVM versions; that is, instead of giving up and linking the shared library version, we should fix the bug which is causing LLVM to not be able to link statically.

matthew-olson-intel commented 1 year ago

After a bit of research, it seems that most major distributions (e.g. Arch, Debian (+Ubuntu), only provide the shared (e.g. libLLVM-15.so) library.

If that's the case, why does BCC default ENABLE_LLVM_SHARED to false? Don't want to tear down a Chesterton fence here.