linux-kernel - 如何在Ubuntu 20.04上编译BCC?

标签 linux-kernel clang bpf bcc-bpf

我正在尝试在 Ubuntu 20.04 上编译 BCC BPF 框架 ( https://github.com/iovisor/bcc )。我遵循了 18.04 的所有说明,但是当然;他们失败了。

我遇到的问题似乎与 clang 相关

In file included from /usr/local/include/clang/Frontend/CompilerInstance.h:15,
                 from /home/matt/code/bpf/bcc/src/cc/frontends/clang/loader.cc:43:
/usr/local/include/clang/Frontend/CompilerInvocation.h:157:15: note: candidate: ‘static bool clang::CompilerInvocation::CreateFromArgs(clang::CompilerInvocation&, llvm::ArrayRef<const char*>, clang::DiagnosticsEngine&)’
  157 |   static bool CreateFromArgs(CompilerInvocation &Res,
      |               ^~~~~~~~~~~~~~
/usr/local/include/clang/Frontend/CompilerInvocation.h:157:15: note:   candidate expects 3 arguments, 4 provided
make[2]: *** [src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/build.make:63: src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/loader.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:982: src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

如何在 Ubuntu 20.04 上进行 BCC 编译?

最佳答案

从 BCC v0.14.0-a28337a 开始,我必须使用 llvm-7 而不是最新的 LLVM。另外,需要 -DPYTHON_CMD=python3 或安装 Python2(或 python 命令),因为默认情况下不再安装 Python2。 https://github.com/iovisor/bcc/blob/master/INSTALL.md#ubuntu---source 中列出的其他依赖项也是必需的。

我可以在我的 Ubuntu 20.04 VM 上构建它。

cmake -Bbuild -DPYTHON_CMD=python3 -DCMAKE_PREFIX_PATH=/usr/lib/llvm-7
make -Cbuild -j$(nproc)

关于linux-kernel - 如何在Ubuntu 20.04上编译BCC?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61978175/

相关文章:

c++ - 什么时候实例化模板类的特殊成员函数?

golang、ebpf 和函数持续时间

c - 在 4.3.0-sabayon linux 中编译 'hello world' 内核模块时遇到问题

c - 如何在 C 中获取初始化的非顺序数组索引

c++ - 限定名称和使用声明的 clang 错误消息

networking - 在TCPdump中解构BPF过滤器

linux - 编译时找不到外部头文件

c - 为什么两个连续共享内存区域上的 mremap 会导致 SIGBUS?

c - Linux内核中的udp_deliver api在哪里?

android - 编译 Android 内核时需要 ARM 寄存器