linux-kernelclangbpfbcc-bpf

How to compile BCC on Ubuntu 20.04?


I am trying to compile the BCC BPF framework (https://github.com/iovisor/bcc) on Ubuntu 20.04. I followed all the instructions for 18.04, but of course; they fail.

The issue i have seems to be clang-related though

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

How do i get BCC compiling on Ubuntu 20.04 ?


Solution

  • As of BCC v0.14.0-a28337a, I have to use llvm-7 instead of the latest LLVM. Also, -DPYTHON_CMD=python3 because Python2 is no longer installed in Ubuntu by default. Other dependencies listed in https://github.com/iovisor/bcc/blob/master/INSTALL.md#ubuntu---source are also required.

    I can build it on my Ubuntu 20.04 VM.

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