iovisor / bcc

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

libbcc.a doesn't contain llvm/clang related defination. statically link failed!! #4796

Open JimLeeee opened 1 year ago

JimLeeee commented 1 year ago

I try to link bcc statically . but failed due to some llvm function not found. I checked the libbcc.a file. readelf -l libbcc.a |grep File File: libbcc.a(bcc_common.cc.o) File: libbcc.a(bpf_module.cc.o) File: libbcc.a(bcc_btf.cc.o) File: libbcc.a(exported_files.cc.o) File: libbcc.a(bcc_debug.cc.o) File: libbcc.a(bpf_module_rw_engine.cc.o) File: libbcc.a(table_storage.cc.o) File: libbcc.a(shared_table.cc.o) File: libbcc.a(bpffs_table.cc.o) File: libbcc.a(json_map_decl_visitor.cc.o) File: libbcc.a(common.cc.o) File: libbcc.a(usdt.cc.o) File: libbcc.a(usdt_args.cc.o) File: libbcc.a(bcc_syms.cc.o) File: libbcc.a(bcc_elf.c.o) File: libbcc.a(bcc_perf_map.c.o) File: libbcc.a(bcc_proc.c.o) File: libbcc.a(bcc_zip.c.o) File: libbcc.a(BPF.cc.o) File: libbcc.a(BPFTable.cc.o) File: libbcc.a(loader.cc.o) File: libbcc.a(b_frontend_action.cc.o) File: libbcc.a(tp_frontend_action.cc.o) File: libbcc.a(kbuild_helper.cc.o)

In the https://github.com/iovisor/bcc/blob/master/CMakeLists.txt and https://github.com/iovisor/bcc/blob/master/cmake/clang_libs.cmake I see some defination related with llvm.But why the final .a file did not contain it ? I'm on ubuntu 22. Also tried centos8 pls have a look

chenhengqi commented 1 year ago

You should link against LLVM libraries instead, try llvm-config --libs --link-static.